qcs405.c 267 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/clk.h>
  5. #include <linux/delay.h>
  6. #include <linux/gpio.h>
  7. #include <linux/of_gpio.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/slab.h>
  10. #include <linux/i2c.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/pm_qos.h>
  16. #include <linux/regulator/consumer.h>
  17. #include <sound/core.h>
  18. #include <sound/soc.h>
  19. #include <sound/soc-dapm.h>
  20. #include <sound/pcm.h>
  21. #include <sound/pcm_params.h>
  22. #include <sound/info.h>
  23. #include <dsp/audio_notifier.h>
  24. #include <dsp/q6afe-v2.h>
  25. #include <dsp/q6core.h>
  26. #include <dsp/msm_mdf.h>
  27. #include "device_event.h"
  28. #include "msm-pcm-routing-v2.h"
  29. #include <asoc/msm-cdc-pinctrl.h>
  30. #include "codecs/wcd9335.h"
  31. #include "codecs/wsa881x.h"
  32. #include "codecs/csra66x0/csra66x0.h"
  33. #include <dt-bindings/sound/audio-codec-port-types.h>
  34. #include "codecs/bolero/bolero-cdc.h"
  35. #include "codecs/bolero/wsa-macro.h"
  36. #define DRV_NAME "qcs405-asoc-snd"
  37. #define __CHIPSET__ "QCS405 "
  38. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  39. #define DEV_NAME_STR_LEN 32
  40. #define SAMPLING_RATE_8KHZ 8000
  41. #define SAMPLING_RATE_11P025KHZ 11025
  42. #define SAMPLING_RATE_16KHZ 16000
  43. #define SAMPLING_RATE_22P05KHZ 22050
  44. #define SAMPLING_RATE_32KHZ 32000
  45. #define SAMPLING_RATE_44P1KHZ 44100
  46. #define SAMPLING_RATE_48KHZ 48000
  47. #define SAMPLING_RATE_88P2KHZ 88200
  48. #define SAMPLING_RATE_96KHZ 96000
  49. #define SAMPLING_RATE_176P4KHZ 176400
  50. #define SAMPLING_RATE_192KHZ 192000
  51. #define SAMPLING_RATE_352P8KHZ 352800
  52. #define SAMPLING_RATE_384KHZ 384000
  53. #define SPDIF_TX_CORE_CLK_163_P84_MHZ 163840000
  54. #define TLMM_EAST_SPARE 0x07BA0000
  55. #define TLMM_SPDIF_HDMI_ARC_CTL 0x07BA2000
  56. #define WSA8810_NAME_1 "wsa881x.20170211"
  57. #define WSA8810_NAME_2 "wsa881x.20170212"
  58. #define WCN_CDC_SLIM_RX_CH_MAX 2
  59. #define WCN_CDC_SLIM_TX_CH_MAX 4
  60. #define TDM_CHANNEL_MAX 8
  61. #define BT_SLIM_TX SLIM_TX_9
  62. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  63. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  64. enum {
  65. SLIM_RX_0 = 0,
  66. SLIM_RX_1,
  67. SLIM_RX_2,
  68. SLIM_RX_3,
  69. SLIM_RX_4,
  70. SLIM_RX_5,
  71. SLIM_RX_6,
  72. SLIM_RX_7,
  73. SLIM_RX_MAX,
  74. };
  75. enum {
  76. SLIM_TX_0 = 0,
  77. SLIM_TX_1,
  78. SLIM_TX_2,
  79. SLIM_TX_3,
  80. SLIM_TX_4,
  81. SLIM_TX_5,
  82. SLIM_TX_6,
  83. SLIM_TX_7,
  84. SLIM_TX_8,
  85. SLIM_TX_9,
  86. SLIM_TX_MAX,
  87. };
  88. enum {
  89. PRIM_MI2S = 0,
  90. SEC_MI2S,
  91. TERT_MI2S,
  92. QUAT_MI2S,
  93. QUIN_MI2S,
  94. SEN_MI2S,
  95. MI2S_MAX,
  96. };
  97. enum {
  98. PRIM_META_MI2S = 0,
  99. SEC_META_MI2S,
  100. META_MI2S_MAX,
  101. };
  102. enum {
  103. PRIM_AUX_PCM = 0,
  104. SEC_AUX_PCM,
  105. TERT_AUX_PCM,
  106. QUAT_AUX_PCM,
  107. QUIN_AUX_PCM,
  108. SEN_AUX_PCM,
  109. AUX_PCM_MAX,
  110. };
  111. enum {
  112. WSA_CDC_DMA_RX_0 = 0,
  113. WSA_CDC_DMA_RX_1,
  114. CDC_DMA_RX_MAX,
  115. };
  116. enum {
  117. WSA_CDC_DMA_TX_0 = 0,
  118. WSA_CDC_DMA_TX_1,
  119. WSA_CDC_DMA_TX_2,
  120. VA_CDC_DMA_TX_0,
  121. VA_CDC_DMA_TX_1,
  122. CDC_DMA_TX_MAX,
  123. };
  124. enum {
  125. PRIM_SPDIF_RX = 0,
  126. SEC_SPDIF_RX,
  127. SPDIF_RX_MAX,
  128. };
  129. enum {
  130. PRIM_SPDIF_TX = 0,
  131. SEC_SPDIF_TX,
  132. SPDIF_TX_MAX,
  133. };
  134. struct mi2s_conf {
  135. struct mutex lock;
  136. u32 ref_cnt;
  137. u32 msm_is_mi2s_master;
  138. };
  139. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  140. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  141. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  142. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  143. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT,
  144. Q6AFE_LPASS_CLK_ID_QUI_MI2S_EBIT,
  145. Q6AFE_LPASS_CLK_ID_SEN_MI2S_EBIT
  146. };
  147. struct meta_mi2s_conf {
  148. u32 num_member_ports;
  149. u32 member_port[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  150. bool clk_enable[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  151. };
  152. struct dev_config {
  153. u32 sample_rate;
  154. u32 bit_format;
  155. u32 channels;
  156. };
  157. struct msm_wsa881x_dev_info {
  158. struct device_node *of_node;
  159. u32 index;
  160. };
  161. struct msm_csra66x0_dev_info {
  162. struct device_node *of_node;
  163. u32 index;
  164. };
  165. struct msm_asoc_mach_data {
  166. struct snd_info_entry *codec_root;
  167. struct device_node *dmic_01_gpio_p; /* used by pinctrl API */
  168. struct device_node *dmic_23_gpio_p; /* used by pinctrl API */
  169. struct device_node *dmic_45_gpio_p; /* used by pinctrl API */
  170. struct device_node *dmic_67_gpio_p; /* used by pinctrl API */
  171. struct device_node *lineout_booster_gpio_p; /* used by pinctrl API */
  172. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  173. int dmic_01_gpio_cnt;
  174. int dmic_23_gpio_cnt;
  175. int dmic_45_gpio_cnt;
  176. int dmic_67_gpio_cnt;
  177. struct regulator *tdm_micb_supply;
  178. u32 tdm_micb_voltage;
  179. u32 tdm_micb_current;
  180. bool codec_is_csra;
  181. };
  182. struct msm_asoc_wcd93xx_codec {
  183. void* (*get_afe_config_fn)(struct snd_soc_component *component,
  184. enum afe_config_type config_type);
  185. };
  186. static const char *const pin_states[] = {"sleep", "i2s-active",
  187. "tdm-active"};
  188. enum {
  189. TDM_0 = 0,
  190. TDM_1,
  191. TDM_2,
  192. TDM_3,
  193. TDM_4,
  194. TDM_5,
  195. TDM_6,
  196. TDM_7,
  197. TDM_PORT_MAX,
  198. };
  199. enum {
  200. TDM_PRI = 0,
  201. TDM_SEC,
  202. TDM_TERT,
  203. TDM_QUAT,
  204. TDM_QUIN,
  205. TDM_INTERFACE_MAX,
  206. };
  207. struct tdm_port {
  208. u32 mode;
  209. u32 channel;
  210. };
  211. /* TDM default config */
  212. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  213. { /* PRI TDM */
  214. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  215. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  216. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  217. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  218. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  219. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  220. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  221. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  222. },
  223. { /* SEC TDM */
  224. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  225. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  226. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  227. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  228. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  229. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  230. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  231. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  232. },
  233. { /* TERT TDM */
  234. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  235. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  236. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  237. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  238. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  239. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  240. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  241. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  242. },
  243. { /* QUAT TDM */
  244. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  245. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  246. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  247. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  248. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  249. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  250. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  251. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  252. },
  253. { /* QUIN TDM */
  254. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  255. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  256. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  257. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  258. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  259. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  260. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  261. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  262. }
  263. };
  264. /* TDM default config */
  265. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  266. { /* PRI TDM */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  272. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  273. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  274. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  275. },
  276. { /* SEC TDM */
  277. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  278. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  279. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  280. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  281. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  282. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  283. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  284. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  285. },
  286. { /* TERT TDM */
  287. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  288. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  291. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  292. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  294. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  295. },
  296. { /* QUAT TDM */
  297. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  298. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  299. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  300. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  301. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  302. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  303. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  304. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  305. },
  306. { /* QUIN TDM */
  307. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  308. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  309. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  310. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  311. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  312. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  313. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  314. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  315. }
  316. };
  317. /* Default configuration of slimbus channels */
  318. static struct dev_config slim_rx_cfg[] = {
  319. [SLIM_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  320. [SLIM_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  321. [SLIM_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  322. [SLIM_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  323. [SLIM_RX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  324. [SLIM_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  325. [SLIM_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  326. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  327. };
  328. static struct dev_config slim_tx_cfg[] = {
  329. [SLIM_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  330. [SLIM_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  331. [SLIM_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  332. [SLIM_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  333. [SLIM_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  334. [SLIM_TX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  335. [SLIM_TX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  336. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  337. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  338. [SLIM_TX_9] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  339. };
  340. /* Default configuration of Codec DMA Interface Tx */
  341. static struct dev_config cdc_dma_rx_cfg[] = {
  342. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  343. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  344. };
  345. /* Default configuration of Codec DMA Interface Rx */
  346. static struct dev_config cdc_dma_tx_cfg[] = {
  347. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  348. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  349. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  350. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  351. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  352. };
  353. static struct dev_config usb_rx_cfg = {
  354. .sample_rate = SAMPLING_RATE_48KHZ,
  355. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  356. .channels = 2,
  357. };
  358. static struct dev_config usb_tx_cfg = {
  359. .sample_rate = SAMPLING_RATE_48KHZ,
  360. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  361. .channels = 1,
  362. };
  363. static struct dev_config proxy_rx_cfg = {
  364. .sample_rate = SAMPLING_RATE_48KHZ,
  365. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  366. .channels = 2,
  367. };
  368. /* Default configuration of MI2S channels */
  369. static struct dev_config mi2s_rx_cfg[] = {
  370. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  371. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  372. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  373. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  374. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  375. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  376. };
  377. static struct dev_config meta_mi2s_rx_cfg[] = {
  378. [PRIM_META_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  379. [SEC_META_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  380. };
  381. /* Default configuration of SPDIF channels */
  382. static struct dev_config spdif_rx_cfg[] = {
  383. [PRIM_SPDIF_RX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  384. [SEC_SPDIF_RX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  385. };
  386. static struct dev_config spdif_tx_cfg[] = {
  387. [PRIM_SPDIF_TX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  388. [SEC_SPDIF_TX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  389. };
  390. static struct dev_config mi2s_tx_cfg[] = {
  391. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  392. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  393. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  394. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  395. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  396. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  397. };
  398. static struct dev_config aux_pcm_rx_cfg[] = {
  399. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  400. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  401. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  402. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  403. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  404. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  405. };
  406. static struct dev_config aux_pcm_tx_cfg[] = {
  407. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  408. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  409. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  410. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  411. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  412. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  413. };
  414. static struct dev_config afe_lb_tx_cfg = {
  415. .sample_rate = SAMPLING_RATE_48KHZ,
  416. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  417. .channels = 2,
  418. };
  419. static int msm_vi_feed_tx_ch = 2;
  420. static const char *const slim_rx_ch_text[] = {"One", "Two"};
  421. static const char *const slim_tx_ch_text[] = {"One", "Two", "Three", "Four",
  422. "Five", "Six", "Seven",
  423. "Eight"};
  424. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  425. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  426. "S32_LE"};
  427. static char const *slim_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  428. "KHZ_32", "KHZ_44P1", "KHZ_48",
  429. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  430. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  431. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  432. "KHZ_44P1", "KHZ_48",
  433. "KHZ_88P2", "KHZ_96"};
  434. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  435. "Five", "Six", "Seven",
  436. "Eight"};
  437. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  438. "Six", "Seven", "Eight"};
  439. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  440. "KHZ_16", "KHZ_22P05",
  441. "KHZ_32", "KHZ_44P1", "KHZ_48",
  442. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  443. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  444. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  445. "Five", "Six", "Seven", "Eight"};
  446. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  447. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  448. "KHZ_48", "KHZ_176P4",
  449. "KHZ_352P8"};
  450. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  451. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  452. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  453. "KHZ_48", "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  454. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  455. static const char *const mi2s_ch_text[] = {
  456. "One", "Two", "Three", "Four", "Five", "Six", "Seven",
  457. "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
  458. "Fourteen", "Fifteen", "Sixteen"
  459. };
  460. static const char *const meta_mi2s_ch_text[] = {
  461. "One", "Two", "Three", "Four", "Five", "Six", "Seven",
  462. "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
  463. "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",
  464. "Nineteen", "Twenty", "TwentyOne", "TwentyTwo", "TwentyThree",
  465. "TwentyFour", "TwentyFive", "TwentySix", "TwentySeven",
  466. "TwentyEight", "TwentyNine", "Thirty", "ThirtyOne", "ThirtyTwo"
  467. };
  468. static const char *const qos_text[] = {"Disable", "Enable"};
  469. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  470. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  471. "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
  472. "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen"};
  473. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  474. "KHZ_16", "KHZ_22P05",
  475. "KHZ_32", "KHZ_44P1", "KHZ_48",
  476. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  477. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  478. static const char *spdif_rate_text[] = {"KHZ_32", "KHZ_44P1", "KHZ_48",
  479. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  480. "KHZ_192"};
  481. static const char *spdif_ch_text[] = {"One", "Two"};
  482. static const char *spdif_bit_format_text[] = {"S16_LE", "S24_LE"};
  483. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_chs, slim_rx_ch_text);
  484. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_chs, slim_rx_ch_text);
  485. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_chs, slim_tx_ch_text);
  486. static SOC_ENUM_SINGLE_EXT_DECL(slim_1_tx_chs, slim_tx_ch_text);
  487. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_chs, slim_rx_ch_text);
  488. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_chs, slim_rx_ch_text);
  489. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  490. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  491. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  492. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  493. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_format, bit_format_text);
  494. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_format, bit_format_text);
  495. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_format, bit_format_text);
  496. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_format, bit_format_text);
  497. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  498. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  499. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_sample_rate, slim_sample_rate_text);
  500. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_sample_rate, slim_sample_rate_text);
  501. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_sample_rate, slim_sample_rate_text);
  502. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_sample_rate, slim_sample_rate_text);
  503. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_sample_rate, slim_sample_rate_text);
  504. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  505. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_sink, bt_sample_rate_text);
  506. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  507. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  508. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  509. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  510. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  511. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  512. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  513. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  514. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  515. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  516. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  517. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  518. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  519. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  520. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  521. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  522. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  523. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  524. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  525. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  526. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  527. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  528. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  529. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  530. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  531. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_sample_rate, mi2s_rate_text);
  532. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  533. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  534. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  535. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  536. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  537. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_sample_rate, mi2s_rate_text);
  538. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  539. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  540. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  541. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  542. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  543. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  544. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  545. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  546. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  547. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  548. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_chs, mi2s_ch_text);
  549. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_chs, mi2s_ch_text);
  550. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  551. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  552. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  553. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  554. static SOC_ENUM_SINGLE_EXT_DECL(prim_meta_mi2s_rx_sample_rate, mi2s_rate_text);
  555. static SOC_ENUM_SINGLE_EXT_DECL(sec_meta_mi2s_rx_sample_rate, mi2s_rate_text);
  556. static SOC_ENUM_SINGLE_EXT_DECL(prim_meta_mi2s_rx_chs, meta_mi2s_ch_text);
  557. static SOC_ENUM_SINGLE_EXT_DECL(sec_meta_mi2s_rx_chs, meta_mi2s_ch_text);
  558. static SOC_ENUM_SINGLE_EXT_DECL(prim_meta_mi2s_rx_format, bit_format_text);
  559. static SOC_ENUM_SINGLE_EXT_DECL(sec_meta_mi2s_rx_format, bit_format_text);
  560. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  561. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  562. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  563. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  564. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  565. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  566. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  567. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  568. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  569. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  570. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  571. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  572. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  573. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  574. cdc_dma_sample_rate_text);
  575. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  576. cdc_dma_sample_rate_text);
  577. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  578. cdc_dma_sample_rate_text);
  579. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  580. cdc_dma_sample_rate_text);
  581. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  582. cdc_dma_sample_rate_text);
  583. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  584. cdc_dma_sample_rate_text);
  585. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  586. cdc_dma_sample_rate_text);
  587. static SOC_ENUM_SINGLE_EXT_DECL(spdif_rx_sample_rate, spdif_rate_text);
  588. static SOC_ENUM_SINGLE_EXT_DECL(spdif_tx_sample_rate, spdif_rate_text);
  589. static SOC_ENUM_SINGLE_EXT_DECL(spdif_rx_chs, spdif_ch_text);
  590. static SOC_ENUM_SINGLE_EXT_DECL(spdif_tx_chs, spdif_ch_text);
  591. static SOC_ENUM_SINGLE_EXT_DECL(spdif_rx_format, spdif_bit_format_text);
  592. static SOC_ENUM_SINGLE_EXT_DECL(spdif_tx_format, spdif_bit_format_text);
  593. static SOC_ENUM_SINGLE_EXT_DECL(afe_lb_tx_chs, cdc_dma_tx_ch_text);
  594. static SOC_ENUM_SINGLE_EXT_DECL(afe_lb_tx_format, bit_format_text);
  595. static SOC_ENUM_SINGLE_EXT_DECL(afe_lb_tx_sample_rate,
  596. cdc_dma_sample_rate_text);
  597. static struct platform_device *spdev;
  598. static bool is_initial_boot;
  599. static bool codec_reg_done;
  600. static struct snd_soc_aux_dev *msm_aux_dev;
  601. static struct snd_soc_codec_conf *msm_codec_conf;
  602. static struct msm_asoc_wcd93xx_codec msm_codec_fn;
  603. static int msm_snd_enable_codec_ext_clk(struct snd_soc_component *component,
  604. int enable, bool dapm);
  605. static int msm_wsa881x_init(struct snd_soc_component *component);
  606. static int msm_snd_vad_cfg_put(struct snd_kcontrol *kcontrol,
  607. struct snd_ctl_elem_value *ucontrol);
  608. static struct snd_soc_dapm_route wcd_audio_paths[] = {
  609. {"MIC BIAS1", NULL, "MCLK TX"},
  610. {"MIC BIAS2", NULL, "MCLK TX"},
  611. {"MIC BIAS3", NULL, "MCLK TX"},
  612. {"MIC BIAS4", NULL, "MCLK TX"},
  613. };
  614. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  615. {
  616. AFE_API_VERSION_I2S_CONFIG,
  617. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  618. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  619. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  620. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  621. 0,
  622. },
  623. {
  624. AFE_API_VERSION_I2S_CONFIG,
  625. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  626. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  627. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  628. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  629. 0,
  630. },
  631. {
  632. AFE_API_VERSION_I2S_CONFIG,
  633. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  634. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  635. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  636. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  637. 0,
  638. },
  639. {
  640. AFE_API_VERSION_I2S_CONFIG,
  641. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  642. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  643. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  644. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  645. 0,
  646. },
  647. {
  648. AFE_API_VERSION_I2S_CONFIG,
  649. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  650. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  651. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  652. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  653. 0,
  654. },
  655. {
  656. AFE_API_VERSION_I2S_CONFIG,
  657. Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT,
  658. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  659. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  660. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  661. 0,
  662. }
  663. };
  664. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  665. static struct meta_mi2s_conf meta_mi2s_intf_conf[META_MI2S_MAX];
  666. static int msm_island_vad_get_portid_from_beid(int32_t be_id, int *port_id)
  667. {
  668. *port_id = 0xFFFF;
  669. switch (be_id) {
  670. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  671. *port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_0;
  672. break;
  673. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  674. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  675. break;
  676. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  677. *port_id = AFE_PORT_ID_QUINARY_TDM_TX;
  678. break;
  679. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  680. *port_id = AFE_PORT_ID_QUINARY_PCM_TX;
  681. break;
  682. default:
  683. return -EINVAL;
  684. }
  685. return 0;
  686. }
  687. static int qcs405_send_island_vad_config(int32_t be_id)
  688. {
  689. int rc = 0;
  690. int port_id = 0xFFFF;
  691. rc = msm_island_vad_get_portid_from_beid(be_id, &port_id);
  692. if (rc) {
  693. pr_debug("%s: Invalid island interface\n", __func__);
  694. } else {
  695. /*
  696. * send island mode config
  697. * This should be the first configuration
  698. */
  699. rc = afe_send_port_island_mode(port_id);
  700. if (rc) {
  701. pr_err("%s: afe send island mode failed %d\n",
  702. __func__, rc);
  703. return rc;
  704. }
  705. rc = afe_send_port_vad_cfg_params(port_id);
  706. if (rc) {
  707. pr_err("%s: afe send vad config failed %d\n",
  708. __func__, rc);
  709. return rc;
  710. }
  711. }
  712. return 0;
  713. }
  714. static int slim_get_sample_rate_val(int sample_rate)
  715. {
  716. int sample_rate_val = 0;
  717. switch (sample_rate) {
  718. case SAMPLING_RATE_8KHZ:
  719. sample_rate_val = 0;
  720. break;
  721. case SAMPLING_RATE_16KHZ:
  722. sample_rate_val = 1;
  723. break;
  724. case SAMPLING_RATE_32KHZ:
  725. sample_rate_val = 2;
  726. break;
  727. case SAMPLING_RATE_44P1KHZ:
  728. sample_rate_val = 3;
  729. break;
  730. case SAMPLING_RATE_48KHZ:
  731. sample_rate_val = 4;
  732. break;
  733. case SAMPLING_RATE_88P2KHZ:
  734. sample_rate_val = 5;
  735. break;
  736. case SAMPLING_RATE_96KHZ:
  737. sample_rate_val = 6;
  738. break;
  739. case SAMPLING_RATE_176P4KHZ:
  740. sample_rate_val = 7;
  741. break;
  742. case SAMPLING_RATE_192KHZ:
  743. sample_rate_val = 8;
  744. break;
  745. case SAMPLING_RATE_352P8KHZ:
  746. sample_rate_val = 9;
  747. break;
  748. case SAMPLING_RATE_384KHZ:
  749. sample_rate_val = 10;
  750. break;
  751. default:
  752. sample_rate_val = 4;
  753. break;
  754. }
  755. return sample_rate_val;
  756. }
  757. static int slim_get_sample_rate(int value)
  758. {
  759. int sample_rate = 0;
  760. switch (value) {
  761. case 0:
  762. sample_rate = SAMPLING_RATE_8KHZ;
  763. break;
  764. case 1:
  765. sample_rate = SAMPLING_RATE_16KHZ;
  766. break;
  767. case 2:
  768. sample_rate = SAMPLING_RATE_32KHZ;
  769. break;
  770. case 3:
  771. sample_rate = SAMPLING_RATE_44P1KHZ;
  772. break;
  773. case 4:
  774. sample_rate = SAMPLING_RATE_48KHZ;
  775. break;
  776. case 5:
  777. sample_rate = SAMPLING_RATE_88P2KHZ;
  778. break;
  779. case 6:
  780. sample_rate = SAMPLING_RATE_96KHZ;
  781. break;
  782. case 7:
  783. sample_rate = SAMPLING_RATE_176P4KHZ;
  784. break;
  785. case 8:
  786. sample_rate = SAMPLING_RATE_192KHZ;
  787. break;
  788. case 9:
  789. sample_rate = SAMPLING_RATE_352P8KHZ;
  790. break;
  791. case 10:
  792. sample_rate = SAMPLING_RATE_384KHZ;
  793. break;
  794. default:
  795. sample_rate = SAMPLING_RATE_48KHZ;
  796. break;
  797. }
  798. return sample_rate;
  799. }
  800. static int slim_get_bit_format_val(int bit_format)
  801. {
  802. int val = 0;
  803. switch (bit_format) {
  804. case SNDRV_PCM_FORMAT_S32_LE:
  805. val = 3;
  806. break;
  807. case SNDRV_PCM_FORMAT_S24_3LE:
  808. val = 2;
  809. break;
  810. case SNDRV_PCM_FORMAT_S24_LE:
  811. val = 1;
  812. break;
  813. case SNDRV_PCM_FORMAT_S16_LE:
  814. default:
  815. val = 0;
  816. break;
  817. }
  818. return val;
  819. }
  820. static int slim_get_bit_format(int val)
  821. {
  822. int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  823. switch (val) {
  824. case 0:
  825. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  826. break;
  827. case 1:
  828. bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
  829. break;
  830. case 2:
  831. bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
  832. break;
  833. case 3:
  834. bit_fmt = SNDRV_PCM_FORMAT_S32_LE;
  835. break;
  836. default:
  837. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  838. break;
  839. }
  840. return bit_fmt;
  841. }
  842. static int slim_get_port_idx(struct snd_kcontrol *kcontrol)
  843. {
  844. int port_id = 0;
  845. if (strnstr(kcontrol->id.name, "SLIM_0_RX", sizeof("SLIM_0_RX"))) {
  846. port_id = SLIM_RX_0;
  847. } else if (strnstr(kcontrol->id.name,
  848. "SLIM_2_RX", sizeof("SLIM_2_RX"))) {
  849. port_id = SLIM_RX_2;
  850. } else if (strnstr(kcontrol->id.name,
  851. "SLIM_5_RX", sizeof("SLIM_5_RX"))) {
  852. port_id = SLIM_RX_5;
  853. } else if (strnstr(kcontrol->id.name,
  854. "SLIM_6_RX", sizeof("SLIM_6_RX"))) {
  855. port_id = SLIM_RX_6;
  856. } else if (strnstr(kcontrol->id.name,
  857. "SLIM_0_TX", sizeof("SLIM_0_TX"))) {
  858. port_id = SLIM_TX_0;
  859. } else if (strnstr(kcontrol->id.name,
  860. "SLIM_1_TX", sizeof("SLIM_1_TX"))) {
  861. port_id = SLIM_TX_1;
  862. } else {
  863. pr_err("%s: unsupported channel: %s",
  864. __func__, kcontrol->id.name);
  865. return -EINVAL;
  866. }
  867. return port_id;
  868. }
  869. static int slim_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  870. struct snd_ctl_elem_value *ucontrol)
  871. {
  872. int ch_num = slim_get_port_idx(kcontrol);
  873. if (ch_num < 0)
  874. return ch_num;
  875. ucontrol->value.enumerated.item[0] =
  876. slim_get_sample_rate_val(slim_rx_cfg[ch_num].sample_rate);
  877. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  878. ch_num, slim_rx_cfg[ch_num].sample_rate,
  879. ucontrol->value.enumerated.item[0]);
  880. return 0;
  881. }
  882. static int slim_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  883. struct snd_ctl_elem_value *ucontrol)
  884. {
  885. int ch_num = slim_get_port_idx(kcontrol);
  886. if (ch_num < 0)
  887. return ch_num;
  888. slim_rx_cfg[ch_num].sample_rate =
  889. slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  890. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  891. ch_num, slim_rx_cfg[ch_num].sample_rate,
  892. ucontrol->value.enumerated.item[0]);
  893. return 0;
  894. }
  895. static int slim_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  896. struct snd_ctl_elem_value *ucontrol)
  897. {
  898. int ch_num = slim_get_port_idx(kcontrol);
  899. if (ch_num < 0)
  900. return ch_num;
  901. ucontrol->value.enumerated.item[0] =
  902. slim_get_sample_rate_val(slim_tx_cfg[ch_num].sample_rate);
  903. pr_debug("%s: slim[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  904. ch_num, slim_tx_cfg[ch_num].sample_rate,
  905. ucontrol->value.enumerated.item[0]);
  906. return 0;
  907. }
  908. static int slim_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  909. struct snd_ctl_elem_value *ucontrol)
  910. {
  911. int sample_rate = 0;
  912. int ch_num = slim_get_port_idx(kcontrol);
  913. if (ch_num < 0)
  914. return ch_num;
  915. sample_rate = slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  916. if (sample_rate == SAMPLING_RATE_44P1KHZ) {
  917. pr_err("%s: Unsupported sample rate %d: for Tx path\n",
  918. __func__, sample_rate);
  919. return -EINVAL;
  920. }
  921. slim_tx_cfg[ch_num].sample_rate = sample_rate;
  922. pr_debug("%s: slim[%d]_tx_sample_rate = %d, value = %d\n", __func__,
  923. ch_num, slim_tx_cfg[ch_num].sample_rate,
  924. ucontrol->value.enumerated.item[0]);
  925. return 0;
  926. }
  927. static int slim_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  928. struct snd_ctl_elem_value *ucontrol)
  929. {
  930. int ch_num = slim_get_port_idx(kcontrol);
  931. if (ch_num < 0)
  932. return ch_num;
  933. ucontrol->value.enumerated.item[0] =
  934. slim_get_bit_format_val(slim_rx_cfg[ch_num].bit_format);
  935. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  936. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  937. ucontrol->value.enumerated.item[0]);
  938. return 0;
  939. }
  940. static int slim_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  941. struct snd_ctl_elem_value *ucontrol)
  942. {
  943. int ch_num = slim_get_port_idx(kcontrol);
  944. if (ch_num < 0)
  945. return ch_num;
  946. slim_rx_cfg[ch_num].bit_format =
  947. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  948. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  949. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  950. ucontrol->value.enumerated.item[0]);
  951. return 0;
  952. }
  953. static int slim_tx_bit_format_get(struct snd_kcontrol *kcontrol,
  954. struct snd_ctl_elem_value *ucontrol)
  955. {
  956. int ch_num = slim_get_port_idx(kcontrol);
  957. if (ch_num < 0)
  958. return ch_num;
  959. ucontrol->value.enumerated.item[0] =
  960. slim_get_bit_format_val(slim_tx_cfg[ch_num].bit_format);
  961. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  962. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  963. ucontrol->value.enumerated.item[0]);
  964. return 0;
  965. }
  966. static int slim_tx_bit_format_put(struct snd_kcontrol *kcontrol,
  967. struct snd_ctl_elem_value *ucontrol)
  968. {
  969. int ch_num = slim_get_port_idx(kcontrol);
  970. if (ch_num < 0)
  971. return ch_num;
  972. slim_tx_cfg[ch_num].bit_format =
  973. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  974. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  975. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  976. ucontrol->value.enumerated.item[0]);
  977. return 0;
  978. }
  979. static int slim_rx_ch_get(struct snd_kcontrol *kcontrol,
  980. struct snd_ctl_elem_value *ucontrol)
  981. {
  982. int ch_num = slim_get_port_idx(kcontrol);
  983. if (ch_num < 0)
  984. return ch_num;
  985. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  986. ch_num, slim_rx_cfg[ch_num].channels);
  987. ucontrol->value.enumerated.item[0] = slim_rx_cfg[ch_num].channels - 1;
  988. return 0;
  989. }
  990. static int slim_rx_ch_put(struct snd_kcontrol *kcontrol,
  991. struct snd_ctl_elem_value *ucontrol)
  992. {
  993. int ch_num = slim_get_port_idx(kcontrol);
  994. if (ch_num < 0)
  995. return ch_num;
  996. slim_rx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  997. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  998. ch_num, slim_rx_cfg[ch_num].channels);
  999. return 1;
  1000. }
  1001. static int slim_tx_ch_get(struct snd_kcontrol *kcontrol,
  1002. struct snd_ctl_elem_value *ucontrol)
  1003. {
  1004. int ch_num = slim_get_port_idx(kcontrol);
  1005. if (ch_num < 0)
  1006. return ch_num;
  1007. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  1008. ch_num, slim_tx_cfg[ch_num].channels);
  1009. ucontrol->value.enumerated.item[0] = slim_tx_cfg[ch_num].channels - 1;
  1010. return 0;
  1011. }
  1012. static int slim_tx_ch_put(struct snd_kcontrol *kcontrol,
  1013. struct snd_ctl_elem_value *ucontrol)
  1014. {
  1015. int ch_num = slim_get_port_idx(kcontrol);
  1016. if (ch_num < 0)
  1017. return ch_num;
  1018. slim_tx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  1019. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  1020. ch_num, slim_tx_cfg[ch_num].channels);
  1021. return 1;
  1022. }
  1023. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  1024. struct snd_ctl_elem_value *ucontrol)
  1025. {
  1026. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  1027. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  1028. ucontrol->value.integer.value[0]);
  1029. return 0;
  1030. }
  1031. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  1032. struct snd_ctl_elem_value *ucontrol)
  1033. {
  1034. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  1035. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  1036. return 1;
  1037. }
  1038. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  1039. struct snd_ctl_elem_value *ucontrol)
  1040. {
  1041. /*
  1042. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  1043. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  1044. * value.
  1045. */
  1046. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  1047. case SAMPLING_RATE_96KHZ:
  1048. ucontrol->value.integer.value[0] = 5;
  1049. break;
  1050. case SAMPLING_RATE_88P2KHZ:
  1051. ucontrol->value.integer.value[0] = 4;
  1052. break;
  1053. case SAMPLING_RATE_48KHZ:
  1054. ucontrol->value.integer.value[0] = 3;
  1055. break;
  1056. case SAMPLING_RATE_44P1KHZ:
  1057. ucontrol->value.integer.value[0] = 2;
  1058. break;
  1059. case SAMPLING_RATE_16KHZ:
  1060. ucontrol->value.integer.value[0] = 1;
  1061. break;
  1062. case SAMPLING_RATE_8KHZ:
  1063. default:
  1064. ucontrol->value.integer.value[0] = 0;
  1065. break;
  1066. }
  1067. pr_debug("%s: sample rate = %d", __func__,
  1068. slim_rx_cfg[SLIM_RX_7].sample_rate);
  1069. return 0;
  1070. }
  1071. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  1072. struct snd_ctl_elem_value *ucontrol)
  1073. {
  1074. switch (ucontrol->value.integer.value[0]) {
  1075. case 1:
  1076. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1077. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1078. break;
  1079. case 2:
  1080. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1081. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1082. break;
  1083. case 3:
  1084. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1085. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1086. break;
  1087. case 4:
  1088. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1089. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1090. break;
  1091. case 5:
  1092. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1093. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1094. break;
  1095. case 0:
  1096. default:
  1097. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1098. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1099. break;
  1100. }
  1101. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  1102. __func__,
  1103. slim_rx_cfg[SLIM_RX_7].sample_rate,
  1104. slim_tx_cfg[SLIM_TX_7].sample_rate,
  1105. ucontrol->value.enumerated.item[0]);
  1106. return 0;
  1107. }
  1108. static int msm_bt_sample_rate_sink_get(struct snd_kcontrol *kcontrol,
  1109. struct snd_ctl_elem_value *ucontrol)
  1110. {
  1111. switch (slim_tx_cfg[BT_SLIM_TX].sample_rate) {
  1112. case SAMPLING_RATE_96KHZ:
  1113. ucontrol->value.integer.value[0] = 5;
  1114. break;
  1115. case SAMPLING_RATE_88P2KHZ:
  1116. ucontrol->value.integer.value[0] = 4;
  1117. break;
  1118. case SAMPLING_RATE_48KHZ:
  1119. ucontrol->value.integer.value[0] = 3;
  1120. break;
  1121. case SAMPLING_RATE_44P1KHZ:
  1122. ucontrol->value.integer.value[0] = 2;
  1123. break;
  1124. case SAMPLING_RATE_16KHZ:
  1125. ucontrol->value.integer.value[0] = 1;
  1126. break;
  1127. case SAMPLING_RATE_8KHZ:
  1128. default:
  1129. ucontrol->value.integer.value[0] = 0;
  1130. break;
  1131. }
  1132. pr_debug("%s: sample rate = %d", __func__,
  1133. slim_tx_cfg[BT_SLIM_TX].sample_rate);
  1134. return 0;
  1135. }
  1136. static int msm_bt_sample_rate_sink_put(struct snd_kcontrol *kcontrol,
  1137. struct snd_ctl_elem_value *ucontrol)
  1138. {
  1139. switch (ucontrol->value.integer.value[0]) {
  1140. case 1:
  1141. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_16KHZ;
  1142. break;
  1143. case 2:
  1144. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_44P1KHZ;
  1145. break;
  1146. case 3:
  1147. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_48KHZ;
  1148. break;
  1149. case 4:
  1150. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_88P2KHZ;
  1151. break;
  1152. case 5:
  1153. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_96KHZ;
  1154. break;
  1155. case 0:
  1156. default:
  1157. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_8KHZ;
  1158. break;
  1159. }
  1160. pr_debug("%s: sample rate = %d, value = %d\n",
  1161. __func__,
  1162. slim_tx_cfg[BT_SLIM_TX].sample_rate,
  1163. ucontrol->value.enumerated.item[0]);
  1164. return 0;
  1165. }
  1166. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  1167. {
  1168. int idx = 0;
  1169. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  1170. sizeof("WSA_CDC_DMA_RX_0")))
  1171. idx = WSA_CDC_DMA_RX_0;
  1172. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  1173. sizeof("WSA_CDC_DMA_RX_0")))
  1174. idx = WSA_CDC_DMA_RX_1;
  1175. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  1176. sizeof("WSA_CDC_DMA_TX_0")))
  1177. idx = WSA_CDC_DMA_TX_0;
  1178. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  1179. sizeof("WSA_CDC_DMA_TX_1")))
  1180. idx = WSA_CDC_DMA_TX_1;
  1181. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  1182. sizeof("WSA_CDC_DMA_TX_2")))
  1183. idx = WSA_CDC_DMA_TX_2;
  1184. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  1185. sizeof("VA_CDC_DMA_TX_0")))
  1186. idx = VA_CDC_DMA_TX_0;
  1187. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  1188. sizeof("VA_CDC_DMA_TX_1")))
  1189. idx = VA_CDC_DMA_TX_1;
  1190. else {
  1191. pr_err("%s: unsupported port: %s\n",
  1192. __func__, kcontrol->id.name);
  1193. return -EINVAL;
  1194. }
  1195. return idx;
  1196. }
  1197. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  1198. struct snd_ctl_elem_value *ucontrol)
  1199. {
  1200. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1201. if (ch_num < 0)
  1202. return ch_num;
  1203. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1204. cdc_dma_rx_cfg[ch_num].channels - 1);
  1205. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  1206. return 0;
  1207. }
  1208. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  1209. struct snd_ctl_elem_value *ucontrol)
  1210. {
  1211. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1212. if (ch_num < 0)
  1213. return ch_num;
  1214. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1215. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1216. cdc_dma_rx_cfg[ch_num].channels);
  1217. return 1;
  1218. }
  1219. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  1220. struct snd_ctl_elem_value *ucontrol)
  1221. {
  1222. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1223. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  1224. case SNDRV_PCM_FORMAT_S32_LE:
  1225. ucontrol->value.integer.value[0] = 3;
  1226. break;
  1227. case SNDRV_PCM_FORMAT_S24_3LE:
  1228. ucontrol->value.integer.value[0] = 2;
  1229. break;
  1230. case SNDRV_PCM_FORMAT_S24_LE:
  1231. ucontrol->value.integer.value[0] = 1;
  1232. break;
  1233. case SNDRV_PCM_FORMAT_S16_LE:
  1234. default:
  1235. ucontrol->value.integer.value[0] = 0;
  1236. break;
  1237. }
  1238. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  1239. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  1240. ucontrol->value.integer.value[0]);
  1241. return 0;
  1242. }
  1243. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  1244. struct snd_ctl_elem_value *ucontrol)
  1245. {
  1246. int rc = 0;
  1247. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1248. switch (ucontrol->value.integer.value[0]) {
  1249. case 3:
  1250. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1251. break;
  1252. case 2:
  1253. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1254. break;
  1255. case 1:
  1256. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1257. break;
  1258. case 0:
  1259. default:
  1260. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1261. break;
  1262. }
  1263. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  1264. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  1265. ucontrol->value.integer.value[0]);
  1266. return rc;
  1267. }
  1268. static int cdc_dma_get_sample_rate_val(int sample_rate)
  1269. {
  1270. int sample_rate_val = 0;
  1271. switch (sample_rate) {
  1272. case SAMPLING_RATE_8KHZ:
  1273. sample_rate_val = 0;
  1274. break;
  1275. case SAMPLING_RATE_11P025KHZ:
  1276. sample_rate_val = 1;
  1277. break;
  1278. case SAMPLING_RATE_16KHZ:
  1279. sample_rate_val = 2;
  1280. break;
  1281. case SAMPLING_RATE_22P05KHZ:
  1282. sample_rate_val = 3;
  1283. break;
  1284. case SAMPLING_RATE_32KHZ:
  1285. sample_rate_val = 4;
  1286. break;
  1287. case SAMPLING_RATE_44P1KHZ:
  1288. sample_rate_val = 5;
  1289. break;
  1290. case SAMPLING_RATE_48KHZ:
  1291. sample_rate_val = 6;
  1292. break;
  1293. case SAMPLING_RATE_88P2KHZ:
  1294. sample_rate_val = 7;
  1295. break;
  1296. case SAMPLING_RATE_96KHZ:
  1297. sample_rate_val = 8;
  1298. break;
  1299. case SAMPLING_RATE_176P4KHZ:
  1300. sample_rate_val = 9;
  1301. break;
  1302. case SAMPLING_RATE_192KHZ:
  1303. sample_rate_val = 10;
  1304. break;
  1305. case SAMPLING_RATE_352P8KHZ:
  1306. sample_rate_val = 11;
  1307. break;
  1308. case SAMPLING_RATE_384KHZ:
  1309. sample_rate_val = 12;
  1310. break;
  1311. default:
  1312. sample_rate_val = 6;
  1313. break;
  1314. }
  1315. return sample_rate_val;
  1316. }
  1317. static int cdc_dma_get_sample_rate(int value)
  1318. {
  1319. int sample_rate = 0;
  1320. switch (value) {
  1321. case 0:
  1322. sample_rate = SAMPLING_RATE_8KHZ;
  1323. break;
  1324. case 1:
  1325. sample_rate = SAMPLING_RATE_11P025KHZ;
  1326. break;
  1327. case 2:
  1328. sample_rate = SAMPLING_RATE_16KHZ;
  1329. break;
  1330. case 3:
  1331. sample_rate = SAMPLING_RATE_22P05KHZ;
  1332. break;
  1333. case 4:
  1334. sample_rate = SAMPLING_RATE_32KHZ;
  1335. break;
  1336. case 5:
  1337. sample_rate = SAMPLING_RATE_44P1KHZ;
  1338. break;
  1339. case 6:
  1340. sample_rate = SAMPLING_RATE_48KHZ;
  1341. break;
  1342. case 7:
  1343. sample_rate = SAMPLING_RATE_88P2KHZ;
  1344. break;
  1345. case 8:
  1346. sample_rate = SAMPLING_RATE_96KHZ;
  1347. break;
  1348. case 9:
  1349. sample_rate = SAMPLING_RATE_176P4KHZ;
  1350. break;
  1351. case 10:
  1352. sample_rate = SAMPLING_RATE_192KHZ;
  1353. break;
  1354. case 11:
  1355. sample_rate = SAMPLING_RATE_352P8KHZ;
  1356. break;
  1357. case 12:
  1358. sample_rate = SAMPLING_RATE_384KHZ;
  1359. break;
  1360. default:
  1361. sample_rate = SAMPLING_RATE_48KHZ;
  1362. break;
  1363. }
  1364. return sample_rate;
  1365. }
  1366. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1367. struct snd_ctl_elem_value *ucontrol)
  1368. {
  1369. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1370. if (ch_num < 0)
  1371. return ch_num;
  1372. ucontrol->value.enumerated.item[0] =
  1373. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  1374. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  1375. cdc_dma_rx_cfg[ch_num].sample_rate);
  1376. return 0;
  1377. }
  1378. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1379. struct snd_ctl_elem_value *ucontrol)
  1380. {
  1381. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1382. if (ch_num < 0)
  1383. return ch_num;
  1384. cdc_dma_rx_cfg[ch_num].sample_rate =
  1385. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1386. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  1387. __func__, ucontrol->value.enumerated.item[0],
  1388. cdc_dma_rx_cfg[ch_num].sample_rate);
  1389. return 0;
  1390. }
  1391. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  1392. struct snd_ctl_elem_value *ucontrol)
  1393. {
  1394. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1395. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  1396. cdc_dma_tx_cfg[ch_num].channels);
  1397. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  1398. return 0;
  1399. }
  1400. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  1401. struct snd_ctl_elem_value *ucontrol)
  1402. {
  1403. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1404. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1405. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  1406. cdc_dma_tx_cfg[ch_num].channels);
  1407. return 1;
  1408. }
  1409. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1410. struct snd_ctl_elem_value *ucontrol)
  1411. {
  1412. int sample_rate_val;
  1413. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1414. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  1415. case SAMPLING_RATE_384KHZ:
  1416. sample_rate_val = 12;
  1417. break;
  1418. case SAMPLING_RATE_352P8KHZ:
  1419. sample_rate_val = 11;
  1420. break;
  1421. case SAMPLING_RATE_192KHZ:
  1422. sample_rate_val = 10;
  1423. break;
  1424. case SAMPLING_RATE_176P4KHZ:
  1425. sample_rate_val = 9;
  1426. break;
  1427. case SAMPLING_RATE_96KHZ:
  1428. sample_rate_val = 8;
  1429. break;
  1430. case SAMPLING_RATE_88P2KHZ:
  1431. sample_rate_val = 7;
  1432. break;
  1433. case SAMPLING_RATE_48KHZ:
  1434. sample_rate_val = 6;
  1435. break;
  1436. case SAMPLING_RATE_44P1KHZ:
  1437. sample_rate_val = 5;
  1438. break;
  1439. case SAMPLING_RATE_32KHZ:
  1440. sample_rate_val = 4;
  1441. break;
  1442. case SAMPLING_RATE_22P05KHZ:
  1443. sample_rate_val = 3;
  1444. break;
  1445. case SAMPLING_RATE_16KHZ:
  1446. sample_rate_val = 2;
  1447. break;
  1448. case SAMPLING_RATE_11P025KHZ:
  1449. sample_rate_val = 1;
  1450. break;
  1451. case SAMPLING_RATE_8KHZ:
  1452. sample_rate_val = 0;
  1453. break;
  1454. default:
  1455. sample_rate_val = 6;
  1456. break;
  1457. }
  1458. ucontrol->value.integer.value[0] = sample_rate_val;
  1459. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  1460. cdc_dma_tx_cfg[ch_num].sample_rate);
  1461. return 0;
  1462. }
  1463. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1464. struct snd_ctl_elem_value *ucontrol)
  1465. {
  1466. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1467. switch (ucontrol->value.integer.value[0]) {
  1468. case 12:
  1469. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  1470. break;
  1471. case 11:
  1472. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  1473. break;
  1474. case 10:
  1475. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  1476. break;
  1477. case 9:
  1478. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  1479. break;
  1480. case 8:
  1481. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  1482. break;
  1483. case 7:
  1484. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  1485. break;
  1486. case 6:
  1487. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  1488. break;
  1489. case 5:
  1490. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  1491. break;
  1492. case 4:
  1493. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  1494. break;
  1495. case 3:
  1496. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  1497. break;
  1498. case 2:
  1499. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  1500. break;
  1501. case 1:
  1502. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  1503. break;
  1504. case 0:
  1505. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  1506. break;
  1507. default:
  1508. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  1509. break;
  1510. }
  1511. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  1512. __func__, ucontrol->value.integer.value[0],
  1513. cdc_dma_tx_cfg[ch_num].sample_rate);
  1514. return 0;
  1515. }
  1516. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  1517. struct snd_ctl_elem_value *ucontrol)
  1518. {
  1519. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1520. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  1521. case SNDRV_PCM_FORMAT_S32_LE:
  1522. ucontrol->value.integer.value[0] = 3;
  1523. break;
  1524. case SNDRV_PCM_FORMAT_S24_3LE:
  1525. ucontrol->value.integer.value[0] = 2;
  1526. break;
  1527. case SNDRV_PCM_FORMAT_S24_LE:
  1528. ucontrol->value.integer.value[0] = 1;
  1529. break;
  1530. case SNDRV_PCM_FORMAT_S16_LE:
  1531. default:
  1532. ucontrol->value.integer.value[0] = 0;
  1533. break;
  1534. }
  1535. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  1536. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  1537. ucontrol->value.integer.value[0]);
  1538. return 0;
  1539. }
  1540. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  1541. struct snd_ctl_elem_value *ucontrol)
  1542. {
  1543. int rc = 0;
  1544. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1545. switch (ucontrol->value.integer.value[0]) {
  1546. case 3:
  1547. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1548. break;
  1549. case 2:
  1550. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1551. break;
  1552. case 1:
  1553. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1554. break;
  1555. case 0:
  1556. default:
  1557. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1558. break;
  1559. }
  1560. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  1561. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  1562. ucontrol->value.integer.value[0]);
  1563. return rc;
  1564. }
  1565. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1566. struct snd_ctl_elem_value *ucontrol)
  1567. {
  1568. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1569. usb_rx_cfg.channels);
  1570. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1571. return 0;
  1572. }
  1573. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1574. struct snd_ctl_elem_value *ucontrol)
  1575. {
  1576. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1577. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1578. return 1;
  1579. }
  1580. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1581. struct snd_ctl_elem_value *ucontrol)
  1582. {
  1583. int sample_rate_val;
  1584. switch (usb_rx_cfg.sample_rate) {
  1585. case SAMPLING_RATE_384KHZ:
  1586. sample_rate_val = 12;
  1587. break;
  1588. case SAMPLING_RATE_352P8KHZ:
  1589. sample_rate_val = 11;
  1590. break;
  1591. case SAMPLING_RATE_192KHZ:
  1592. sample_rate_val = 10;
  1593. break;
  1594. case SAMPLING_RATE_176P4KHZ:
  1595. sample_rate_val = 9;
  1596. break;
  1597. case SAMPLING_RATE_96KHZ:
  1598. sample_rate_val = 8;
  1599. break;
  1600. case SAMPLING_RATE_88P2KHZ:
  1601. sample_rate_val = 7;
  1602. break;
  1603. case SAMPLING_RATE_48KHZ:
  1604. sample_rate_val = 6;
  1605. break;
  1606. case SAMPLING_RATE_44P1KHZ:
  1607. sample_rate_val = 5;
  1608. break;
  1609. case SAMPLING_RATE_32KHZ:
  1610. sample_rate_val = 4;
  1611. break;
  1612. case SAMPLING_RATE_22P05KHZ:
  1613. sample_rate_val = 3;
  1614. break;
  1615. case SAMPLING_RATE_16KHZ:
  1616. sample_rate_val = 2;
  1617. break;
  1618. case SAMPLING_RATE_11P025KHZ:
  1619. sample_rate_val = 1;
  1620. break;
  1621. case SAMPLING_RATE_8KHZ:
  1622. default:
  1623. sample_rate_val = 0;
  1624. break;
  1625. }
  1626. ucontrol->value.integer.value[0] = sample_rate_val;
  1627. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  1628. usb_rx_cfg.sample_rate);
  1629. return 0;
  1630. }
  1631. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1632. struct snd_ctl_elem_value *ucontrol)
  1633. {
  1634. switch (ucontrol->value.integer.value[0]) {
  1635. case 12:
  1636. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1637. break;
  1638. case 11:
  1639. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1640. break;
  1641. case 10:
  1642. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1643. break;
  1644. case 9:
  1645. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1646. break;
  1647. case 8:
  1648. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1649. break;
  1650. case 7:
  1651. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1652. break;
  1653. case 6:
  1654. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1655. break;
  1656. case 5:
  1657. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1658. break;
  1659. case 4:
  1660. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1661. break;
  1662. case 3:
  1663. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1664. break;
  1665. case 2:
  1666. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1667. break;
  1668. case 1:
  1669. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1670. break;
  1671. case 0:
  1672. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1673. break;
  1674. default:
  1675. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1676. break;
  1677. }
  1678. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  1679. __func__, ucontrol->value.integer.value[0],
  1680. usb_rx_cfg.sample_rate);
  1681. return 0;
  1682. }
  1683. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  1684. struct snd_ctl_elem_value *ucontrol)
  1685. {
  1686. switch (usb_rx_cfg.bit_format) {
  1687. case SNDRV_PCM_FORMAT_S32_LE:
  1688. ucontrol->value.integer.value[0] = 3;
  1689. break;
  1690. case SNDRV_PCM_FORMAT_S24_3LE:
  1691. ucontrol->value.integer.value[0] = 2;
  1692. break;
  1693. case SNDRV_PCM_FORMAT_S24_LE:
  1694. ucontrol->value.integer.value[0] = 1;
  1695. break;
  1696. case SNDRV_PCM_FORMAT_S16_LE:
  1697. default:
  1698. ucontrol->value.integer.value[0] = 0;
  1699. break;
  1700. }
  1701. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1702. __func__, usb_rx_cfg.bit_format,
  1703. ucontrol->value.integer.value[0]);
  1704. return 0;
  1705. }
  1706. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  1707. struct snd_ctl_elem_value *ucontrol)
  1708. {
  1709. int rc = 0;
  1710. switch (ucontrol->value.integer.value[0]) {
  1711. case 3:
  1712. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1713. break;
  1714. case 2:
  1715. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1716. break;
  1717. case 1:
  1718. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1719. break;
  1720. case 0:
  1721. default:
  1722. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1723. break;
  1724. }
  1725. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1726. __func__, usb_rx_cfg.bit_format,
  1727. ucontrol->value.integer.value[0]);
  1728. return rc;
  1729. }
  1730. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1731. struct snd_ctl_elem_value *ucontrol)
  1732. {
  1733. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1734. usb_tx_cfg.channels);
  1735. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1736. return 0;
  1737. }
  1738. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1739. struct snd_ctl_elem_value *ucontrol)
  1740. {
  1741. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1742. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1743. return 1;
  1744. }
  1745. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1746. struct snd_ctl_elem_value *ucontrol)
  1747. {
  1748. int sample_rate_val;
  1749. switch (usb_tx_cfg.sample_rate) {
  1750. case SAMPLING_RATE_384KHZ:
  1751. sample_rate_val = 12;
  1752. break;
  1753. case SAMPLING_RATE_352P8KHZ:
  1754. sample_rate_val = 11;
  1755. break;
  1756. case SAMPLING_RATE_192KHZ:
  1757. sample_rate_val = 10;
  1758. break;
  1759. case SAMPLING_RATE_176P4KHZ:
  1760. sample_rate_val = 9;
  1761. break;
  1762. case SAMPLING_RATE_96KHZ:
  1763. sample_rate_val = 8;
  1764. break;
  1765. case SAMPLING_RATE_88P2KHZ:
  1766. sample_rate_val = 7;
  1767. break;
  1768. case SAMPLING_RATE_48KHZ:
  1769. sample_rate_val = 6;
  1770. break;
  1771. case SAMPLING_RATE_44P1KHZ:
  1772. sample_rate_val = 5;
  1773. break;
  1774. case SAMPLING_RATE_32KHZ:
  1775. sample_rate_val = 4;
  1776. break;
  1777. case SAMPLING_RATE_22P05KHZ:
  1778. sample_rate_val = 3;
  1779. break;
  1780. case SAMPLING_RATE_16KHZ:
  1781. sample_rate_val = 2;
  1782. break;
  1783. case SAMPLING_RATE_11P025KHZ:
  1784. sample_rate_val = 1;
  1785. break;
  1786. case SAMPLING_RATE_8KHZ:
  1787. sample_rate_val = 0;
  1788. break;
  1789. default:
  1790. sample_rate_val = 6;
  1791. break;
  1792. }
  1793. ucontrol->value.integer.value[0] = sample_rate_val;
  1794. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  1795. usb_tx_cfg.sample_rate);
  1796. return 0;
  1797. }
  1798. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1799. struct snd_ctl_elem_value *ucontrol)
  1800. {
  1801. switch (ucontrol->value.integer.value[0]) {
  1802. case 12:
  1803. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1804. break;
  1805. case 11:
  1806. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1807. break;
  1808. case 10:
  1809. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1810. break;
  1811. case 9:
  1812. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1813. break;
  1814. case 8:
  1815. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1816. break;
  1817. case 7:
  1818. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1819. break;
  1820. case 6:
  1821. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1822. break;
  1823. case 5:
  1824. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1825. break;
  1826. case 4:
  1827. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1828. break;
  1829. case 3:
  1830. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1831. break;
  1832. case 2:
  1833. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1834. break;
  1835. case 1:
  1836. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1837. break;
  1838. case 0:
  1839. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1840. break;
  1841. default:
  1842. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1843. break;
  1844. }
  1845. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  1846. __func__, ucontrol->value.integer.value[0],
  1847. usb_tx_cfg.sample_rate);
  1848. return 0;
  1849. }
  1850. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  1851. struct snd_ctl_elem_value *ucontrol)
  1852. {
  1853. switch (usb_tx_cfg.bit_format) {
  1854. case SNDRV_PCM_FORMAT_S32_LE:
  1855. ucontrol->value.integer.value[0] = 3;
  1856. break;
  1857. case SNDRV_PCM_FORMAT_S24_3LE:
  1858. ucontrol->value.integer.value[0] = 2;
  1859. break;
  1860. case SNDRV_PCM_FORMAT_S24_LE:
  1861. ucontrol->value.integer.value[0] = 1;
  1862. break;
  1863. case SNDRV_PCM_FORMAT_S16_LE:
  1864. default:
  1865. ucontrol->value.integer.value[0] = 0;
  1866. break;
  1867. }
  1868. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1869. __func__, usb_tx_cfg.bit_format,
  1870. ucontrol->value.integer.value[0]);
  1871. return 0;
  1872. }
  1873. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  1874. struct snd_ctl_elem_value *ucontrol)
  1875. {
  1876. int rc = 0;
  1877. switch (ucontrol->value.integer.value[0]) {
  1878. case 3:
  1879. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1880. break;
  1881. case 2:
  1882. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1883. break;
  1884. case 1:
  1885. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1886. break;
  1887. case 0:
  1888. default:
  1889. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1890. break;
  1891. }
  1892. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1893. __func__, usb_tx_cfg.bit_format,
  1894. ucontrol->value.integer.value[0]);
  1895. return rc;
  1896. }
  1897. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1898. struct snd_ctl_elem_value *ucontrol)
  1899. {
  1900. pr_debug("%s: proxy_rx channels = %d\n",
  1901. __func__, proxy_rx_cfg.channels);
  1902. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1903. return 0;
  1904. }
  1905. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1906. struct snd_ctl_elem_value *ucontrol)
  1907. {
  1908. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1909. pr_debug("%s: proxy_rx channels = %d\n",
  1910. __func__, proxy_rx_cfg.channels);
  1911. return 1;
  1912. }
  1913. static int tdm_get_sample_rate(int value)
  1914. {
  1915. int sample_rate = 0;
  1916. switch (value) {
  1917. case 0:
  1918. sample_rate = SAMPLING_RATE_8KHZ;
  1919. break;
  1920. case 1:
  1921. sample_rate = SAMPLING_RATE_16KHZ;
  1922. break;
  1923. case 2:
  1924. sample_rate = SAMPLING_RATE_32KHZ;
  1925. break;
  1926. case 3:
  1927. sample_rate = SAMPLING_RATE_48KHZ;
  1928. break;
  1929. case 4:
  1930. sample_rate = SAMPLING_RATE_176P4KHZ;
  1931. break;
  1932. case 5:
  1933. sample_rate = SAMPLING_RATE_352P8KHZ;
  1934. break;
  1935. default:
  1936. sample_rate = SAMPLING_RATE_48KHZ;
  1937. break;
  1938. }
  1939. return sample_rate;
  1940. }
  1941. static int aux_pcm_get_sample_rate(int value)
  1942. {
  1943. int sample_rate;
  1944. switch (value) {
  1945. case 1:
  1946. sample_rate = SAMPLING_RATE_16KHZ;
  1947. break;
  1948. case 0:
  1949. default:
  1950. sample_rate = SAMPLING_RATE_8KHZ;
  1951. break;
  1952. }
  1953. return sample_rate;
  1954. }
  1955. static int tdm_get_sample_rate_val(int sample_rate)
  1956. {
  1957. int sample_rate_val = 0;
  1958. switch (sample_rate) {
  1959. case SAMPLING_RATE_8KHZ:
  1960. sample_rate_val = 0;
  1961. break;
  1962. case SAMPLING_RATE_16KHZ:
  1963. sample_rate_val = 1;
  1964. break;
  1965. case SAMPLING_RATE_32KHZ:
  1966. sample_rate_val = 2;
  1967. break;
  1968. case SAMPLING_RATE_48KHZ:
  1969. sample_rate_val = 3;
  1970. break;
  1971. case SAMPLING_RATE_176P4KHZ:
  1972. sample_rate_val = 4;
  1973. break;
  1974. case SAMPLING_RATE_352P8KHZ:
  1975. sample_rate_val = 5;
  1976. break;
  1977. default:
  1978. sample_rate_val = 3;
  1979. break;
  1980. }
  1981. return sample_rate_val;
  1982. }
  1983. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1984. {
  1985. int sample_rate_val;
  1986. switch (sample_rate) {
  1987. case SAMPLING_RATE_16KHZ:
  1988. sample_rate_val = 1;
  1989. break;
  1990. case SAMPLING_RATE_8KHZ:
  1991. default:
  1992. sample_rate_val = 0;
  1993. break;
  1994. }
  1995. return sample_rate_val;
  1996. }
  1997. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1998. struct tdm_port *port)
  1999. {
  2000. if (port) {
  2001. if (strnstr(kcontrol->id.name, "PRI",
  2002. sizeof(kcontrol->id.name))) {
  2003. port->mode = TDM_PRI;
  2004. } else if (strnstr(kcontrol->id.name, "SEC",
  2005. sizeof(kcontrol->id.name))) {
  2006. port->mode = TDM_SEC;
  2007. } else if (strnstr(kcontrol->id.name, "TERT",
  2008. sizeof(kcontrol->id.name))) {
  2009. port->mode = TDM_TERT;
  2010. } else if (strnstr(kcontrol->id.name, "QUAT",
  2011. sizeof(kcontrol->id.name))) {
  2012. port->mode = TDM_QUAT;
  2013. } else if (strnstr(kcontrol->id.name, "QUIN",
  2014. sizeof(kcontrol->id.name))) {
  2015. port->mode = TDM_QUIN;
  2016. } else {
  2017. pr_err("%s: unsupported mode in: %s",
  2018. __func__, kcontrol->id.name);
  2019. return -EINVAL;
  2020. }
  2021. if (strnstr(kcontrol->id.name, "RX_0",
  2022. sizeof(kcontrol->id.name)) ||
  2023. strnstr(kcontrol->id.name, "TX_0",
  2024. sizeof(kcontrol->id.name))) {
  2025. port->channel = TDM_0;
  2026. } else if (strnstr(kcontrol->id.name, "RX_1",
  2027. sizeof(kcontrol->id.name)) ||
  2028. strnstr(kcontrol->id.name, "TX_1",
  2029. sizeof(kcontrol->id.name))) {
  2030. port->channel = TDM_1;
  2031. } else if (strnstr(kcontrol->id.name, "RX_2",
  2032. sizeof(kcontrol->id.name)) ||
  2033. strnstr(kcontrol->id.name, "TX_2",
  2034. sizeof(kcontrol->id.name))) {
  2035. port->channel = TDM_2;
  2036. } else if (strnstr(kcontrol->id.name, "RX_3",
  2037. sizeof(kcontrol->id.name)) ||
  2038. strnstr(kcontrol->id.name, "TX_3",
  2039. sizeof(kcontrol->id.name))) {
  2040. port->channel = TDM_3;
  2041. } else if (strnstr(kcontrol->id.name, "RX_4",
  2042. sizeof(kcontrol->id.name)) ||
  2043. strnstr(kcontrol->id.name, "TX_4",
  2044. sizeof(kcontrol->id.name))) {
  2045. port->channel = TDM_4;
  2046. } else if (strnstr(kcontrol->id.name, "RX_5",
  2047. sizeof(kcontrol->id.name)) ||
  2048. strnstr(kcontrol->id.name, "TX_5",
  2049. sizeof(kcontrol->id.name))) {
  2050. port->channel = TDM_5;
  2051. } else if (strnstr(kcontrol->id.name, "RX_6",
  2052. sizeof(kcontrol->id.name)) ||
  2053. strnstr(kcontrol->id.name, "TX_6",
  2054. sizeof(kcontrol->id.name))) {
  2055. port->channel = TDM_6;
  2056. } else if (strnstr(kcontrol->id.name, "RX_7",
  2057. sizeof(kcontrol->id.name)) ||
  2058. strnstr(kcontrol->id.name, "TX_7",
  2059. sizeof(kcontrol->id.name))) {
  2060. port->channel = TDM_7;
  2061. } else {
  2062. pr_err("%s: unsupported channel in: %s",
  2063. __func__, kcontrol->id.name);
  2064. return -EINVAL;
  2065. }
  2066. } else
  2067. return -EINVAL;
  2068. return 0;
  2069. }
  2070. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2071. struct snd_ctl_elem_value *ucontrol)
  2072. {
  2073. struct tdm_port port;
  2074. int ret = tdm_get_port_idx(kcontrol, &port);
  2075. if (ret) {
  2076. pr_err("%s: unsupported control: %s",
  2077. __func__, kcontrol->id.name);
  2078. } else {
  2079. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  2080. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  2081. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  2082. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  2083. ucontrol->value.enumerated.item[0]);
  2084. }
  2085. return ret;
  2086. }
  2087. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2088. struct snd_ctl_elem_value *ucontrol)
  2089. {
  2090. struct tdm_port port;
  2091. int ret = tdm_get_port_idx(kcontrol, &port);
  2092. if (ret) {
  2093. pr_err("%s: unsupported control: %s",
  2094. __func__, kcontrol->id.name);
  2095. } else {
  2096. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  2097. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2098. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  2099. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  2100. ucontrol->value.enumerated.item[0]);
  2101. }
  2102. return ret;
  2103. }
  2104. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2105. struct snd_ctl_elem_value *ucontrol)
  2106. {
  2107. struct tdm_port port;
  2108. int ret = tdm_get_port_idx(kcontrol, &port);
  2109. if (ret) {
  2110. pr_err("%s: unsupported control: %s",
  2111. __func__, kcontrol->id.name);
  2112. } else {
  2113. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  2114. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  2115. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  2116. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  2117. ucontrol->value.enumerated.item[0]);
  2118. }
  2119. return ret;
  2120. }
  2121. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2122. struct snd_ctl_elem_value *ucontrol)
  2123. {
  2124. struct tdm_port port;
  2125. int ret = tdm_get_port_idx(kcontrol, &port);
  2126. if (ret) {
  2127. pr_err("%s: unsupported control: %s",
  2128. __func__, kcontrol->id.name);
  2129. } else {
  2130. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  2131. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2132. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  2133. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  2134. ucontrol->value.enumerated.item[0]);
  2135. }
  2136. return ret;
  2137. }
  2138. static int tdm_get_format(int value)
  2139. {
  2140. int format = 0;
  2141. switch (value) {
  2142. case 0:
  2143. format = SNDRV_PCM_FORMAT_S16_LE;
  2144. break;
  2145. case 1:
  2146. format = SNDRV_PCM_FORMAT_S24_LE;
  2147. break;
  2148. case 2:
  2149. format = SNDRV_PCM_FORMAT_S32_LE;
  2150. break;
  2151. default:
  2152. format = SNDRV_PCM_FORMAT_S16_LE;
  2153. break;
  2154. }
  2155. return format;
  2156. }
  2157. static int tdm_get_format_val(int format)
  2158. {
  2159. int value = 0;
  2160. switch (format) {
  2161. case SNDRV_PCM_FORMAT_S16_LE:
  2162. value = 0;
  2163. break;
  2164. case SNDRV_PCM_FORMAT_S24_LE:
  2165. value = 1;
  2166. break;
  2167. case SNDRV_PCM_FORMAT_S32_LE:
  2168. value = 2;
  2169. break;
  2170. default:
  2171. value = 0;
  2172. break;
  2173. }
  2174. return value;
  2175. }
  2176. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  2177. struct snd_ctl_elem_value *ucontrol)
  2178. {
  2179. struct tdm_port port;
  2180. int ret = tdm_get_port_idx(kcontrol, &port);
  2181. if (ret) {
  2182. pr_err("%s: unsupported control: %s",
  2183. __func__, kcontrol->id.name);
  2184. } else {
  2185. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  2186. tdm_rx_cfg[port.mode][port.channel].bit_format);
  2187. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  2188. tdm_rx_cfg[port.mode][port.channel].bit_format,
  2189. ucontrol->value.enumerated.item[0]);
  2190. }
  2191. return ret;
  2192. }
  2193. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  2194. struct snd_ctl_elem_value *ucontrol)
  2195. {
  2196. struct tdm_port port;
  2197. int ret = tdm_get_port_idx(kcontrol, &port);
  2198. if (ret) {
  2199. pr_err("%s: unsupported control: %s",
  2200. __func__, kcontrol->id.name);
  2201. } else {
  2202. tdm_rx_cfg[port.mode][port.channel].bit_format =
  2203. tdm_get_format(ucontrol->value.enumerated.item[0]);
  2204. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  2205. tdm_rx_cfg[port.mode][port.channel].bit_format,
  2206. ucontrol->value.enumerated.item[0]);
  2207. }
  2208. return ret;
  2209. }
  2210. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  2211. struct snd_ctl_elem_value *ucontrol)
  2212. {
  2213. struct tdm_port port;
  2214. int ret = tdm_get_port_idx(kcontrol, &port);
  2215. if (ret) {
  2216. pr_err("%s: unsupported control: %s",
  2217. __func__, kcontrol->id.name);
  2218. } else {
  2219. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  2220. tdm_tx_cfg[port.mode][port.channel].bit_format);
  2221. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  2222. tdm_tx_cfg[port.mode][port.channel].bit_format,
  2223. ucontrol->value.enumerated.item[0]);
  2224. }
  2225. return ret;
  2226. }
  2227. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  2228. struct snd_ctl_elem_value *ucontrol)
  2229. {
  2230. struct tdm_port port;
  2231. int ret = tdm_get_port_idx(kcontrol, &port);
  2232. if (ret) {
  2233. pr_err("%s: unsupported control: %s",
  2234. __func__, kcontrol->id.name);
  2235. } else {
  2236. tdm_tx_cfg[port.mode][port.channel].bit_format =
  2237. tdm_get_format(ucontrol->value.enumerated.item[0]);
  2238. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  2239. tdm_tx_cfg[port.mode][port.channel].bit_format,
  2240. ucontrol->value.enumerated.item[0]);
  2241. }
  2242. return ret;
  2243. }
  2244. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  2245. struct snd_ctl_elem_value *ucontrol)
  2246. {
  2247. struct tdm_port port;
  2248. int ret = tdm_get_port_idx(kcontrol, &port);
  2249. if (ret) {
  2250. pr_err("%s: unsupported control: %s",
  2251. __func__, kcontrol->id.name);
  2252. } else {
  2253. ucontrol->value.enumerated.item[0] =
  2254. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  2255. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  2256. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  2257. ucontrol->value.enumerated.item[0]);
  2258. }
  2259. return ret;
  2260. }
  2261. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  2262. struct snd_ctl_elem_value *ucontrol)
  2263. {
  2264. struct tdm_port port;
  2265. int ret = tdm_get_port_idx(kcontrol, &port);
  2266. if (ret) {
  2267. pr_err("%s: unsupported control: %s",
  2268. __func__, kcontrol->id.name);
  2269. } else {
  2270. tdm_rx_cfg[port.mode][port.channel].channels =
  2271. ucontrol->value.enumerated.item[0] + 1;
  2272. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  2273. tdm_rx_cfg[port.mode][port.channel].channels,
  2274. ucontrol->value.enumerated.item[0] + 1);
  2275. }
  2276. return ret;
  2277. }
  2278. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  2279. struct snd_ctl_elem_value *ucontrol)
  2280. {
  2281. struct tdm_port port;
  2282. int ret = tdm_get_port_idx(kcontrol, &port);
  2283. if (ret) {
  2284. pr_err("%s: unsupported control: %s",
  2285. __func__, kcontrol->id.name);
  2286. } else {
  2287. ucontrol->value.enumerated.item[0] =
  2288. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  2289. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  2290. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  2291. ucontrol->value.enumerated.item[0]);
  2292. }
  2293. return ret;
  2294. }
  2295. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  2296. struct snd_ctl_elem_value *ucontrol)
  2297. {
  2298. struct tdm_port port;
  2299. int ret = tdm_get_port_idx(kcontrol, &port);
  2300. if (ret) {
  2301. pr_err("%s: unsupported control: %s",
  2302. __func__, kcontrol->id.name);
  2303. } else {
  2304. tdm_tx_cfg[port.mode][port.channel].channels =
  2305. ucontrol->value.enumerated.item[0] + 1;
  2306. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  2307. tdm_tx_cfg[port.mode][port.channel].channels,
  2308. ucontrol->value.enumerated.item[0] + 1);
  2309. }
  2310. return ret;
  2311. }
  2312. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  2313. {
  2314. int idx;
  2315. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  2316. sizeof("PRIM_AUX_PCM")))
  2317. idx = PRIM_AUX_PCM;
  2318. else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  2319. sizeof("SEC_AUX_PCM")))
  2320. idx = SEC_AUX_PCM;
  2321. else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  2322. sizeof("TERT_AUX_PCM")))
  2323. idx = TERT_AUX_PCM;
  2324. else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  2325. sizeof("QUAT_AUX_PCM")))
  2326. idx = QUAT_AUX_PCM;
  2327. else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  2328. sizeof("QUIN_AUX_PCM")))
  2329. idx = QUIN_AUX_PCM;
  2330. else if (strnstr(kcontrol->id.name, "SEN_AUX_PCM",
  2331. sizeof("SENN_AUX_PCM")))
  2332. idx = SEN_AUX_PCM;
  2333. else {
  2334. pr_err("%s: unsupported port: %s",
  2335. __func__, kcontrol->id.name);
  2336. idx = -EINVAL;
  2337. }
  2338. return idx;
  2339. }
  2340. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2341. struct snd_ctl_elem_value *ucontrol)
  2342. {
  2343. int idx = aux_pcm_get_port_idx(kcontrol);
  2344. if (idx < 0)
  2345. return idx;
  2346. aux_pcm_rx_cfg[idx].sample_rate =
  2347. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2348. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2349. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2350. ucontrol->value.enumerated.item[0]);
  2351. return 0;
  2352. }
  2353. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2354. struct snd_ctl_elem_value *ucontrol)
  2355. {
  2356. int idx = aux_pcm_get_port_idx(kcontrol);
  2357. if (idx < 0)
  2358. return idx;
  2359. ucontrol->value.enumerated.item[0] =
  2360. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  2361. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2362. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2363. ucontrol->value.enumerated.item[0]);
  2364. return 0;
  2365. }
  2366. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2367. struct snd_ctl_elem_value *ucontrol)
  2368. {
  2369. int idx = aux_pcm_get_port_idx(kcontrol);
  2370. if (idx < 0)
  2371. return idx;
  2372. aux_pcm_tx_cfg[idx].sample_rate =
  2373. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2374. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2375. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2376. ucontrol->value.enumerated.item[0]);
  2377. return 0;
  2378. }
  2379. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2380. struct snd_ctl_elem_value *ucontrol)
  2381. {
  2382. int idx = aux_pcm_get_port_idx(kcontrol);
  2383. if (idx < 0)
  2384. return idx;
  2385. ucontrol->value.enumerated.item[0] =
  2386. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  2387. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2388. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2389. ucontrol->value.enumerated.item[0]);
  2390. return 0;
  2391. }
  2392. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2393. {
  2394. int idx;
  2395. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  2396. sizeof("PRIM_MI2S_RX")))
  2397. idx = PRIM_MI2S;
  2398. else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  2399. sizeof("SEC_MI2S_RX")))
  2400. idx = SEC_MI2S;
  2401. else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  2402. sizeof("TERT_MI2S_RX")))
  2403. idx = TERT_MI2S;
  2404. else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  2405. sizeof("QUAT_MI2S_RX")))
  2406. idx = QUAT_MI2S;
  2407. else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  2408. sizeof("QUIN_MI2S_RX")))
  2409. idx = QUIN_MI2S;
  2410. else if (strnstr(kcontrol->id.name, "SEN_MI2S_RX",
  2411. sizeof("SEN_MI2S_RX")))
  2412. idx = SEN_MI2S;
  2413. else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  2414. sizeof("PRIM_MI2S_TX")))
  2415. idx = PRIM_MI2S;
  2416. else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  2417. sizeof("SEC_MI2S_TX")))
  2418. idx = SEC_MI2S;
  2419. else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  2420. sizeof("TERT_MI2S_TX")))
  2421. idx = TERT_MI2S;
  2422. else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  2423. sizeof("QUAT_MI2S_TX")))
  2424. idx = QUAT_MI2S;
  2425. else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  2426. sizeof("QUIN_MI2S_TX")))
  2427. idx = QUIN_MI2S;
  2428. else if (strnstr(kcontrol->id.name, "SEN_MI2S_TX",
  2429. sizeof("SEN_MI2S_TX")))
  2430. idx = SEN_MI2S;
  2431. else {
  2432. pr_err("%s: unsupported channel: %s",
  2433. __func__, kcontrol->id.name);
  2434. idx = -EINVAL;
  2435. }
  2436. return idx;
  2437. }
  2438. static int mi2s_get_sample_rate_val(int sample_rate)
  2439. {
  2440. int sample_rate_val;
  2441. switch (sample_rate) {
  2442. case SAMPLING_RATE_8KHZ:
  2443. sample_rate_val = 0;
  2444. break;
  2445. case SAMPLING_RATE_11P025KHZ:
  2446. sample_rate_val = 1;
  2447. break;
  2448. case SAMPLING_RATE_16KHZ:
  2449. sample_rate_val = 2;
  2450. break;
  2451. case SAMPLING_RATE_22P05KHZ:
  2452. sample_rate_val = 3;
  2453. break;
  2454. case SAMPLING_RATE_32KHZ:
  2455. sample_rate_val = 4;
  2456. break;
  2457. case SAMPLING_RATE_44P1KHZ:
  2458. sample_rate_val = 5;
  2459. break;
  2460. case SAMPLING_RATE_48KHZ:
  2461. sample_rate_val = 6;
  2462. break;
  2463. case SAMPLING_RATE_88P2KHZ:
  2464. sample_rate_val = 7;
  2465. break;
  2466. case SAMPLING_RATE_96KHZ:
  2467. sample_rate_val = 8;
  2468. break;
  2469. case SAMPLING_RATE_176P4KHZ:
  2470. sample_rate_val = 9;
  2471. break;
  2472. case SAMPLING_RATE_192KHZ:
  2473. sample_rate_val = 10;
  2474. break;
  2475. case SAMPLING_RATE_352P8KHZ:
  2476. sample_rate_val = 11;
  2477. break;
  2478. case SAMPLING_RATE_384KHZ:
  2479. sample_rate_val = 12;
  2480. break;
  2481. default:
  2482. sample_rate_val = 6;
  2483. break;
  2484. }
  2485. return sample_rate_val;
  2486. }
  2487. static int mi2s_get_sample_rate(int value)
  2488. {
  2489. int sample_rate;
  2490. switch (value) {
  2491. case 0:
  2492. sample_rate = SAMPLING_RATE_8KHZ;
  2493. break;
  2494. case 1:
  2495. sample_rate = SAMPLING_RATE_11P025KHZ;
  2496. break;
  2497. case 2:
  2498. sample_rate = SAMPLING_RATE_16KHZ;
  2499. break;
  2500. case 3:
  2501. sample_rate = SAMPLING_RATE_22P05KHZ;
  2502. break;
  2503. case 4:
  2504. sample_rate = SAMPLING_RATE_32KHZ;
  2505. break;
  2506. case 5:
  2507. sample_rate = SAMPLING_RATE_44P1KHZ;
  2508. break;
  2509. case 6:
  2510. sample_rate = SAMPLING_RATE_48KHZ;
  2511. break;
  2512. case 7:
  2513. sample_rate = SAMPLING_RATE_88P2KHZ;
  2514. break;
  2515. case 8:
  2516. sample_rate = SAMPLING_RATE_96KHZ;
  2517. break;
  2518. case 9:
  2519. sample_rate = SAMPLING_RATE_176P4KHZ;
  2520. break;
  2521. case 10:
  2522. sample_rate = SAMPLING_RATE_192KHZ;
  2523. break;
  2524. case 11:
  2525. sample_rate = SAMPLING_RATE_352P8KHZ;
  2526. break;
  2527. case 12:
  2528. sample_rate = SAMPLING_RATE_384KHZ;
  2529. break;
  2530. default:
  2531. sample_rate = SAMPLING_RATE_48KHZ;
  2532. break;
  2533. }
  2534. return sample_rate;
  2535. }
  2536. static int mi2s_auxpcm_get_format(int value)
  2537. {
  2538. int format;
  2539. switch (value) {
  2540. case 0:
  2541. format = SNDRV_PCM_FORMAT_S16_LE;
  2542. break;
  2543. case 1:
  2544. format = SNDRV_PCM_FORMAT_S24_LE;
  2545. break;
  2546. case 2:
  2547. format = SNDRV_PCM_FORMAT_S24_3LE;
  2548. break;
  2549. case 3:
  2550. format = SNDRV_PCM_FORMAT_S32_LE;
  2551. break;
  2552. default:
  2553. format = SNDRV_PCM_FORMAT_S16_LE;
  2554. break;
  2555. }
  2556. return format;
  2557. }
  2558. static int mi2s_auxpcm_get_format_value(int format)
  2559. {
  2560. int value;
  2561. switch (format) {
  2562. case SNDRV_PCM_FORMAT_S16_LE:
  2563. value = 0;
  2564. break;
  2565. case SNDRV_PCM_FORMAT_S24_LE:
  2566. value = 1;
  2567. break;
  2568. case SNDRV_PCM_FORMAT_S24_3LE:
  2569. value = 2;
  2570. break;
  2571. case SNDRV_PCM_FORMAT_S32_LE:
  2572. value = 3;
  2573. break;
  2574. default:
  2575. value = 0;
  2576. break;
  2577. }
  2578. return value;
  2579. }
  2580. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2581. struct snd_ctl_elem_value *ucontrol)
  2582. {
  2583. int idx = mi2s_get_port_idx(kcontrol);
  2584. if (idx < 0)
  2585. return idx;
  2586. mi2s_rx_cfg[idx].sample_rate =
  2587. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2588. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2589. idx, mi2s_rx_cfg[idx].sample_rate,
  2590. ucontrol->value.enumerated.item[0]);
  2591. return 0;
  2592. }
  2593. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2594. struct snd_ctl_elem_value *ucontrol)
  2595. {
  2596. int idx = mi2s_get_port_idx(kcontrol);
  2597. if (idx < 0)
  2598. return idx;
  2599. ucontrol->value.enumerated.item[0] =
  2600. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  2601. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2602. idx, mi2s_rx_cfg[idx].sample_rate,
  2603. ucontrol->value.enumerated.item[0]);
  2604. return 0;
  2605. }
  2606. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2607. struct snd_ctl_elem_value *ucontrol)
  2608. {
  2609. int idx = mi2s_get_port_idx(kcontrol);
  2610. if (idx < 0)
  2611. return idx;
  2612. mi2s_tx_cfg[idx].sample_rate =
  2613. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2614. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2615. idx, mi2s_tx_cfg[idx].sample_rate,
  2616. ucontrol->value.enumerated.item[0]);
  2617. return 0;
  2618. }
  2619. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2620. struct snd_ctl_elem_value *ucontrol)
  2621. {
  2622. int idx = mi2s_get_port_idx(kcontrol);
  2623. if (idx < 0)
  2624. return idx;
  2625. ucontrol->value.enumerated.item[0] =
  2626. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  2627. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2628. idx, mi2s_tx_cfg[idx].sample_rate,
  2629. ucontrol->value.enumerated.item[0]);
  2630. return 0;
  2631. }
  2632. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2633. struct snd_ctl_elem_value *ucontrol)
  2634. {
  2635. int idx = mi2s_get_port_idx(kcontrol);
  2636. if (idx < 0)
  2637. return idx;
  2638. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2639. idx, mi2s_rx_cfg[idx].channels);
  2640. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2641. return 0;
  2642. }
  2643. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2644. struct snd_ctl_elem_value *ucontrol)
  2645. {
  2646. int idx = mi2s_get_port_idx(kcontrol);
  2647. if (idx < 0)
  2648. return idx;
  2649. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2650. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2651. idx, mi2s_rx_cfg[idx].channels);
  2652. return 1;
  2653. }
  2654. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2655. struct snd_ctl_elem_value *ucontrol)
  2656. {
  2657. int idx = mi2s_get_port_idx(kcontrol);
  2658. if (idx < 0)
  2659. return idx;
  2660. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2661. idx, mi2s_tx_cfg[idx].channels);
  2662. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2663. return 0;
  2664. }
  2665. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2666. struct snd_ctl_elem_value *ucontrol)
  2667. {
  2668. int idx = mi2s_get_port_idx(kcontrol);
  2669. if (idx < 0)
  2670. return idx;
  2671. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2672. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2673. idx, mi2s_tx_cfg[idx].channels);
  2674. return 1;
  2675. }
  2676. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2677. struct snd_ctl_elem_value *ucontrol)
  2678. {
  2679. int idx = mi2s_get_port_idx(kcontrol);
  2680. if (idx < 0)
  2681. return idx;
  2682. ucontrol->value.enumerated.item[0] =
  2683. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  2684. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2685. idx, mi2s_rx_cfg[idx].bit_format,
  2686. ucontrol->value.enumerated.item[0]);
  2687. return 0;
  2688. }
  2689. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2690. struct snd_ctl_elem_value *ucontrol)
  2691. {
  2692. struct msm_asoc_mach_data *pdata = NULL;
  2693. struct snd_soc_component *component = NULL;
  2694. struct snd_soc_card *card = NULL;
  2695. int idx = mi2s_get_port_idx(kcontrol);
  2696. component = snd_soc_kcontrol_component(kcontrol);
  2697. card = kcontrol->private_data;
  2698. pdata = snd_soc_card_get_drvdata(card);
  2699. if (idx < 0)
  2700. return idx;
  2701. /* check for PRIM_MI2S and CSRAx config to allow 24bit BE config only */
  2702. if ((PRIM_MI2S == idx) && (true==pdata->codec_is_csra))
  2703. {
  2704. mi2s_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2705. pr_debug("%s: Keeping default format idx[%d]_rx_format = %d, item = %d\n",
  2706. __func__, idx, mi2s_rx_cfg[idx].bit_format,
  2707. ucontrol->value.enumerated.item[0]);
  2708. } else {
  2709. mi2s_rx_cfg[idx].bit_format =
  2710. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2711. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2712. idx, mi2s_rx_cfg[idx].bit_format,
  2713. ucontrol->value.enumerated.item[0]);
  2714. }
  2715. return 0;
  2716. }
  2717. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  2718. struct snd_ctl_elem_value *ucontrol)
  2719. {
  2720. int idx = mi2s_get_port_idx(kcontrol);
  2721. if (idx < 0)
  2722. return idx;
  2723. ucontrol->value.enumerated.item[0] =
  2724. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2725. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2726. idx, mi2s_tx_cfg[idx].bit_format,
  2727. ucontrol->value.enumerated.item[0]);
  2728. return 0;
  2729. }
  2730. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2731. struct snd_ctl_elem_value *ucontrol)
  2732. {
  2733. int idx = mi2s_get_port_idx(kcontrol);
  2734. if (idx < 0)
  2735. return idx;
  2736. mi2s_tx_cfg[idx].bit_format =
  2737. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2738. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2739. idx, mi2s_tx_cfg[idx].bit_format,
  2740. ucontrol->value.enumerated.item[0]);
  2741. return 0;
  2742. }
  2743. static int msm_meta_mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2744. {
  2745. int idx = 0;
  2746. if (strnstr(kcontrol->id.name, "PRIM_META_MI2S_RX",
  2747. sizeof("PRIM_META_MI2S_RX"))) {
  2748. idx = PRIM_META_MI2S;
  2749. } else if (strnstr(kcontrol->id.name, "SEC_META_MI2S_RX",
  2750. sizeof("SEC_META_MI2S_RX"))) {
  2751. idx = SEC_META_MI2S;
  2752. } else {
  2753. pr_err("%s: unsupported port: %s",
  2754. __func__, kcontrol->id.name);
  2755. idx = -EINVAL;
  2756. }
  2757. return idx;
  2758. }
  2759. static int msm_meta_mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2760. struct snd_ctl_elem_value *ucontrol)
  2761. {
  2762. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2763. if (idx < 0)
  2764. return idx;
  2765. ucontrol->value.enumerated.item[0] =
  2766. mi2s_get_sample_rate_val(meta_mi2s_rx_cfg[idx].sample_rate);
  2767. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2768. idx, meta_mi2s_rx_cfg[idx].sample_rate,
  2769. ucontrol->value.enumerated.item[0]);
  2770. return 0;
  2771. }
  2772. static int msm_meta_mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2773. struct snd_ctl_elem_value *ucontrol)
  2774. {
  2775. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2776. if (idx < 0)
  2777. return idx;
  2778. meta_mi2s_rx_cfg[idx].sample_rate =
  2779. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2780. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2781. idx, meta_mi2s_rx_cfg[idx].sample_rate,
  2782. ucontrol->value.enumerated.item[0]);
  2783. return 0;
  2784. }
  2785. static int msm_meta_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2786. struct snd_ctl_elem_value *ucontrol)
  2787. {
  2788. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2789. if (idx < 0)
  2790. return idx;
  2791. ucontrol->value.enumerated.item[0] = meta_mi2s_rx_cfg[idx].channels - 1;
  2792. pr_debug("%s: meta_mi2s_[%d]_rx_ch = %d\n", __func__,
  2793. idx, meta_mi2s_rx_cfg[idx].channels);
  2794. return 0;
  2795. }
  2796. static int msm_meta_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2797. struct snd_ctl_elem_value *ucontrol)
  2798. {
  2799. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2800. if (idx < 0)
  2801. return idx;
  2802. meta_mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2803. pr_debug("%s: meta_mi2s_[%d]_rx_ch = %d\n", __func__,
  2804. idx, meta_mi2s_rx_cfg[idx].channels);
  2805. return 1;
  2806. }
  2807. static int msm_meta_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2808. struct snd_ctl_elem_value *ucontrol)
  2809. {
  2810. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2811. if (idx < 0)
  2812. return idx;
  2813. ucontrol->value.enumerated.item[0] =
  2814. mi2s_auxpcm_get_format_value(meta_mi2s_rx_cfg[idx].bit_format);
  2815. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2816. idx, meta_mi2s_rx_cfg[idx].bit_format,
  2817. ucontrol->value.enumerated.item[0]);
  2818. return 0;
  2819. }
  2820. static int msm_meta_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2821. struct snd_ctl_elem_value *ucontrol)
  2822. {
  2823. struct msm_asoc_mach_data *pdata = NULL;
  2824. struct snd_soc_card *card = NULL;
  2825. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2826. card = kcontrol->private_data;
  2827. pdata = snd_soc_card_get_drvdata(card);
  2828. if (idx < 0)
  2829. return idx;
  2830. /* check for PRIM_META_MI2S and CSRAx to allow 24bit BE config only */
  2831. if ((idx == PRIM_META_MI2S) && pdata->codec_is_csra) {
  2832. meta_mi2s_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2833. pr_debug("%s: Keeping default format idx[%d]_rx_format = %d, item = %d\n",
  2834. __func__, idx, meta_mi2s_rx_cfg[idx].bit_format,
  2835. ucontrol->value.enumerated.item[0]);
  2836. } else {
  2837. meta_mi2s_rx_cfg[idx].bit_format =
  2838. mi2s_auxpcm_get_format(
  2839. ucontrol->value.enumerated.item[0]);
  2840. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2841. idx, meta_mi2s_rx_cfg[idx].bit_format,
  2842. ucontrol->value.enumerated.item[0]);
  2843. }
  2844. return 0;
  2845. }
  2846. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  2847. struct snd_ctl_elem_value *ucontrol)
  2848. {
  2849. int idx = aux_pcm_get_port_idx(kcontrol);
  2850. if (idx < 0)
  2851. return idx;
  2852. ucontrol->value.enumerated.item[0] =
  2853. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  2854. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2855. idx, aux_pcm_rx_cfg[idx].bit_format,
  2856. ucontrol->value.enumerated.item[0]);
  2857. return 0;
  2858. }
  2859. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  2860. struct snd_ctl_elem_value *ucontrol)
  2861. {
  2862. int idx = aux_pcm_get_port_idx(kcontrol);
  2863. if (idx < 0)
  2864. return idx;
  2865. aux_pcm_rx_cfg[idx].bit_format =
  2866. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2867. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2868. idx, aux_pcm_rx_cfg[idx].bit_format,
  2869. ucontrol->value.enumerated.item[0]);
  2870. return 0;
  2871. }
  2872. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  2873. struct snd_ctl_elem_value *ucontrol)
  2874. {
  2875. int idx = aux_pcm_get_port_idx(kcontrol);
  2876. if (idx < 0)
  2877. return idx;
  2878. ucontrol->value.enumerated.item[0] =
  2879. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  2880. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2881. idx, aux_pcm_tx_cfg[idx].bit_format,
  2882. ucontrol->value.enumerated.item[0]);
  2883. return 0;
  2884. }
  2885. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  2886. struct snd_ctl_elem_value *ucontrol)
  2887. {
  2888. int idx = aux_pcm_get_port_idx(kcontrol);
  2889. if (idx < 0)
  2890. return idx;
  2891. aux_pcm_tx_cfg[idx].bit_format =
  2892. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2893. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2894. idx, aux_pcm_tx_cfg[idx].bit_format,
  2895. ucontrol->value.enumerated.item[0]);
  2896. return 0;
  2897. }
  2898. static int spdif_get_port_idx(struct snd_kcontrol *kcontrol)
  2899. {
  2900. int idx;
  2901. if (strnstr(kcontrol->id.name, "PRIM_SPDIF_RX",
  2902. sizeof("PRIM_SPDIF_RX")))
  2903. idx = PRIM_SPDIF_RX;
  2904. else if (strnstr(kcontrol->id.name, "SEC_SPDIF_RX",
  2905. sizeof("SEC_SPDIF_RX")))
  2906. idx = SEC_SPDIF_RX;
  2907. else if (strnstr(kcontrol->id.name, "PRIM_SPDIF_TX",
  2908. sizeof("PRIM_SPDIF_TX")))
  2909. idx = PRIM_SPDIF_TX;
  2910. else if (strnstr(kcontrol->id.name, "SEC_SPDIF_TX",
  2911. sizeof("SEC_SPDIF_TX")))
  2912. idx = SEC_SPDIF_TX;
  2913. else {
  2914. pr_err("%s: unsupported channel: %s",
  2915. __func__, kcontrol->id.name);
  2916. idx = -EINVAL;
  2917. }
  2918. return idx;
  2919. }
  2920. static int spdif_get_sample_rate_val(int sample_rate)
  2921. {
  2922. int sample_rate_val;
  2923. switch (sample_rate) {
  2924. case SAMPLING_RATE_32KHZ:
  2925. sample_rate_val = 0;
  2926. break;
  2927. case SAMPLING_RATE_44P1KHZ:
  2928. sample_rate_val = 1;
  2929. break;
  2930. case SAMPLING_RATE_48KHZ:
  2931. sample_rate_val = 2;
  2932. break;
  2933. case SAMPLING_RATE_88P2KHZ:
  2934. sample_rate_val = 3;
  2935. break;
  2936. case SAMPLING_RATE_96KHZ:
  2937. sample_rate_val = 4;
  2938. break;
  2939. case SAMPLING_RATE_176P4KHZ:
  2940. sample_rate_val = 5;
  2941. break;
  2942. case SAMPLING_RATE_192KHZ:
  2943. sample_rate_val = 6;
  2944. break;
  2945. default:
  2946. sample_rate_val = 2;
  2947. break;
  2948. }
  2949. return sample_rate_val;
  2950. }
  2951. static int spdif_get_sample_rate(int value)
  2952. {
  2953. int sample_rate;
  2954. switch (value) {
  2955. case 0:
  2956. sample_rate = SAMPLING_RATE_32KHZ;
  2957. break;
  2958. case 1:
  2959. sample_rate = SAMPLING_RATE_44P1KHZ;
  2960. break;
  2961. case 2:
  2962. sample_rate = SAMPLING_RATE_48KHZ;
  2963. break;
  2964. case 3:
  2965. sample_rate = SAMPLING_RATE_88P2KHZ;
  2966. break;
  2967. case 4:
  2968. sample_rate = SAMPLING_RATE_96KHZ;
  2969. break;
  2970. case 5:
  2971. sample_rate = SAMPLING_RATE_176P4KHZ;
  2972. break;
  2973. case 6:
  2974. sample_rate = SAMPLING_RATE_192KHZ;
  2975. break;
  2976. default:
  2977. sample_rate = SAMPLING_RATE_48KHZ;
  2978. break;
  2979. }
  2980. return sample_rate;
  2981. }
  2982. static int spdif_get_format(int value)
  2983. {
  2984. int format;
  2985. switch (value) {
  2986. case 0:
  2987. format = SNDRV_PCM_FORMAT_S16_LE;
  2988. break;
  2989. case 1:
  2990. format = SNDRV_PCM_FORMAT_S24_LE;
  2991. break;
  2992. default:
  2993. format = SNDRV_PCM_FORMAT_S16_LE;
  2994. break;
  2995. }
  2996. return format;
  2997. }
  2998. static int spdif_get_format_value(int format)
  2999. {
  3000. int value;
  3001. switch (format) {
  3002. case SNDRV_PCM_FORMAT_S16_LE:
  3003. value = 0;
  3004. break;
  3005. case SNDRV_PCM_FORMAT_S24_LE:
  3006. value = 1;
  3007. break;
  3008. default:
  3009. value = 0;
  3010. break;
  3011. }
  3012. return value;
  3013. }
  3014. static int msm_spdif_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  3015. struct snd_ctl_elem_value *ucontrol)
  3016. {
  3017. int idx = spdif_get_port_idx(kcontrol);
  3018. if (idx < 0)
  3019. return idx;
  3020. spdif_rx_cfg[idx].sample_rate =
  3021. spdif_get_sample_rate(ucontrol->value.enumerated.item[0]);
  3022. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  3023. idx, spdif_rx_cfg[idx].sample_rate,
  3024. ucontrol->value.enumerated.item[0]);
  3025. return 0;
  3026. }
  3027. static int msm_spdif_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  3028. struct snd_ctl_elem_value *ucontrol)
  3029. {
  3030. int idx = spdif_get_port_idx(kcontrol);
  3031. if (idx < 0)
  3032. return idx;
  3033. ucontrol->value.enumerated.item[0] =
  3034. spdif_get_sample_rate_val(spdif_rx_cfg[idx].sample_rate);
  3035. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  3036. idx, spdif_rx_cfg[idx].sample_rate,
  3037. ucontrol->value.enumerated.item[0]);
  3038. return 0;
  3039. }
  3040. static int msm_spdif_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  3041. struct snd_ctl_elem_value *ucontrol)
  3042. {
  3043. int idx = spdif_get_port_idx(kcontrol);
  3044. if (idx < 0)
  3045. return idx;
  3046. spdif_tx_cfg[idx].sample_rate =
  3047. spdif_get_sample_rate(ucontrol->value.enumerated.item[0]);
  3048. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  3049. idx, spdif_tx_cfg[idx].sample_rate,
  3050. ucontrol->value.enumerated.item[0]);
  3051. return 0;
  3052. }
  3053. static int msm_spdif_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  3054. struct snd_ctl_elem_value *ucontrol)
  3055. {
  3056. int idx = spdif_get_port_idx(kcontrol);
  3057. if (idx < 0)
  3058. return idx;
  3059. ucontrol->value.enumerated.item[0] =
  3060. spdif_get_sample_rate_val(spdif_tx_cfg[idx].sample_rate);
  3061. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  3062. idx, spdif_tx_cfg[idx].sample_rate,
  3063. ucontrol->value.enumerated.item[0]);
  3064. return 0;
  3065. }
  3066. static int msm_spdif_rx_ch_get(struct snd_kcontrol *kcontrol,
  3067. struct snd_ctl_elem_value *ucontrol)
  3068. {
  3069. int idx = spdif_get_port_idx(kcontrol);
  3070. if (idx < 0)
  3071. return idx;
  3072. pr_debug("%s: msm_spdif_[%d]_rx_ch = %d\n", __func__,
  3073. idx, spdif_rx_cfg[idx].channels);
  3074. ucontrol->value.enumerated.item[0] = spdif_rx_cfg[idx].channels - 1;
  3075. return 0;
  3076. }
  3077. static int msm_spdif_rx_ch_put(struct snd_kcontrol *kcontrol,
  3078. struct snd_ctl_elem_value *ucontrol)
  3079. {
  3080. int idx = spdif_get_port_idx(kcontrol);
  3081. if (idx < 0)
  3082. return idx;
  3083. spdif_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  3084. pr_debug("%s: msm_spdif_[%d]_rx_ch = %d\n", __func__,
  3085. idx, spdif_rx_cfg[idx].channels);
  3086. return 1;
  3087. }
  3088. static int msm_spdif_tx_ch_get(struct snd_kcontrol *kcontrol,
  3089. struct snd_ctl_elem_value *ucontrol)
  3090. {
  3091. int idx = spdif_get_port_idx(kcontrol);
  3092. if (idx < 0)
  3093. return idx;
  3094. pr_debug("%s: msm_spdif_[%d]_tx_ch = %d\n", __func__,
  3095. idx, spdif_tx_cfg[idx].channels);
  3096. ucontrol->value.enumerated.item[0] = spdif_tx_cfg[idx].channels - 1;
  3097. return 0;
  3098. }
  3099. static int msm_spdif_tx_ch_put(struct snd_kcontrol *kcontrol,
  3100. struct snd_ctl_elem_value *ucontrol)
  3101. {
  3102. int idx = spdif_get_port_idx(kcontrol);
  3103. if (idx < 0)
  3104. return idx;
  3105. spdif_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  3106. pr_debug("%s: msm_spdif_[%d]_tx_ch = %d\n", __func__,
  3107. idx, spdif_tx_cfg[idx].channels);
  3108. return 1;
  3109. }
  3110. static int msm_spdif_rx_format_get(struct snd_kcontrol *kcontrol,
  3111. struct snd_ctl_elem_value *ucontrol)
  3112. {
  3113. int idx = spdif_get_port_idx(kcontrol);
  3114. if (idx < 0)
  3115. return idx;
  3116. ucontrol->value.enumerated.item[0] =
  3117. spdif_get_format_value(spdif_rx_cfg[idx].bit_format);
  3118. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  3119. idx, spdif_rx_cfg[idx].bit_format,
  3120. ucontrol->value.enumerated.item[0]);
  3121. return 0;
  3122. }
  3123. static int msm_spdif_rx_format_put(struct snd_kcontrol *kcontrol,
  3124. struct snd_ctl_elem_value *ucontrol)
  3125. {
  3126. int idx = spdif_get_port_idx(kcontrol);
  3127. if (idx < 0)
  3128. return idx;
  3129. spdif_rx_cfg[idx].bit_format =
  3130. spdif_get_format(ucontrol->value.enumerated.item[0]);
  3131. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  3132. idx, spdif_rx_cfg[idx].bit_format,
  3133. ucontrol->value.enumerated.item[0]);
  3134. return 0;
  3135. }
  3136. static int msm_spdif_tx_format_get(struct snd_kcontrol *kcontrol,
  3137. struct snd_ctl_elem_value *ucontrol)
  3138. {
  3139. int idx = spdif_get_port_idx(kcontrol);
  3140. if (idx < 0)
  3141. return idx;
  3142. ucontrol->value.enumerated.item[0] =
  3143. spdif_get_format_value(spdif_tx_cfg[idx].bit_format);
  3144. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  3145. idx, spdif_tx_cfg[idx].bit_format,
  3146. ucontrol->value.enumerated.item[0]);
  3147. return 0;
  3148. }
  3149. static int msm_spdif_tx_format_put(struct snd_kcontrol *kcontrol,
  3150. struct snd_ctl_elem_value *ucontrol)
  3151. {
  3152. int idx = spdif_get_port_idx(kcontrol);
  3153. if (idx < 0)
  3154. return idx;
  3155. spdif_tx_cfg[idx].bit_format =
  3156. spdif_get_format(ucontrol->value.enumerated.item[0]);
  3157. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  3158. idx, spdif_tx_cfg[idx].bit_format,
  3159. ucontrol->value.enumerated.item[0]);
  3160. return 0;
  3161. }
  3162. static int afe_lb_tx_ch_get(struct snd_kcontrol *kcontrol,
  3163. struct snd_ctl_elem_value *ucontrol)
  3164. {
  3165. pr_debug("%s: afe_lb_tx_ch = %d\n", __func__,
  3166. afe_lb_tx_cfg.channels);
  3167. ucontrol->value.integer.value[0] = afe_lb_tx_cfg.channels - 1;
  3168. return 0;
  3169. }
  3170. static int afe_lb_tx_ch_put(struct snd_kcontrol *kcontrol,
  3171. struct snd_ctl_elem_value *ucontrol)
  3172. {
  3173. afe_lb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  3174. pr_debug("%s: afe_lb_tx_ch = %d\n", __func__, afe_lb_tx_cfg.channels);
  3175. return 0;
  3176. }
  3177. static int afe_lb_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  3178. struct snd_ctl_elem_value *ucontrol)
  3179. {
  3180. int sample_rate_val;
  3181. switch (afe_lb_tx_cfg.sample_rate) {
  3182. case SAMPLING_RATE_384KHZ:
  3183. sample_rate_val = 12;
  3184. break;
  3185. case SAMPLING_RATE_352P8KHZ:
  3186. sample_rate_val = 11;
  3187. break;
  3188. case SAMPLING_RATE_192KHZ:
  3189. sample_rate_val = 10;
  3190. break;
  3191. case SAMPLING_RATE_176P4KHZ:
  3192. sample_rate_val = 9;
  3193. break;
  3194. case SAMPLING_RATE_96KHZ:
  3195. sample_rate_val = 8;
  3196. break;
  3197. case SAMPLING_RATE_88P2KHZ:
  3198. sample_rate_val = 7;
  3199. break;
  3200. case SAMPLING_RATE_48KHZ:
  3201. sample_rate_val = 6;
  3202. break;
  3203. case SAMPLING_RATE_44P1KHZ:
  3204. sample_rate_val = 5;
  3205. break;
  3206. case SAMPLING_RATE_32KHZ:
  3207. sample_rate_val = 4;
  3208. break;
  3209. case SAMPLING_RATE_22P05KHZ:
  3210. sample_rate_val = 3;
  3211. break;
  3212. case SAMPLING_RATE_16KHZ:
  3213. sample_rate_val = 2;
  3214. break;
  3215. case SAMPLING_RATE_11P025KHZ:
  3216. sample_rate_val = 1;
  3217. break;
  3218. case SAMPLING_RATE_8KHZ:
  3219. sample_rate_val = 0;
  3220. break;
  3221. default:
  3222. sample_rate_val = 6;
  3223. break;
  3224. }
  3225. ucontrol->value.integer.value[0] = sample_rate_val;
  3226. pr_debug("%s: afe_lb_tx_sample_rate = %d\n", __func__,
  3227. afe_lb_tx_cfg.sample_rate);
  3228. return 0;
  3229. }
  3230. static int afe_lb_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  3231. struct snd_ctl_elem_value *ucontrol)
  3232. {
  3233. switch (ucontrol->value.integer.value[0]) {
  3234. case 12:
  3235. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  3236. break;
  3237. case 11:
  3238. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  3239. break;
  3240. case 10:
  3241. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  3242. break;
  3243. case 9:
  3244. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  3245. break;
  3246. case 8:
  3247. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  3248. break;
  3249. case 7:
  3250. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  3251. break;
  3252. case 6:
  3253. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  3254. break;
  3255. case 5:
  3256. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  3257. break;
  3258. case 4:
  3259. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  3260. break;
  3261. case 3:
  3262. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  3263. break;
  3264. case 2:
  3265. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  3266. break;
  3267. case 1:
  3268. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  3269. break;
  3270. case 0:
  3271. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  3272. break;
  3273. default:
  3274. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  3275. break;
  3276. }
  3277. pr_debug("%s: control value = %ld, afe_lb_tx_sample_rate = %d\n",
  3278. __func__, ucontrol->value.integer.value[0],
  3279. afe_lb_tx_cfg.sample_rate);
  3280. return 0;
  3281. }
  3282. static int afe_lb_tx_format_get(struct snd_kcontrol *kcontrol,
  3283. struct snd_ctl_elem_value *ucontrol)
  3284. {
  3285. switch (afe_lb_tx_cfg.bit_format) {
  3286. case SNDRV_PCM_FORMAT_S32_LE:
  3287. ucontrol->value.integer.value[0] = 3;
  3288. break;
  3289. case SNDRV_PCM_FORMAT_S24_3LE:
  3290. ucontrol->value.integer.value[0] = 2;
  3291. break;
  3292. case SNDRV_PCM_FORMAT_S24_LE:
  3293. ucontrol->value.integer.value[0] = 1;
  3294. break;
  3295. case SNDRV_PCM_FORMAT_S16_LE:
  3296. default:
  3297. ucontrol->value.integer.value[0] = 0;
  3298. break;
  3299. }
  3300. pr_debug("%s: afe_lb_tx_format = %d, ucontrol value = %ld\n",
  3301. __func__, afe_lb_tx_cfg.bit_format,
  3302. ucontrol->value.integer.value[0]);
  3303. return 0;
  3304. }
  3305. static int afe_lb_tx_format_put(struct snd_kcontrol *kcontrol,
  3306. struct snd_ctl_elem_value *ucontrol)
  3307. {
  3308. switch (ucontrol->value.integer.value[0]) {
  3309. case 3:
  3310. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  3311. break;
  3312. case 2:
  3313. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  3314. break;
  3315. case 1:
  3316. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  3317. break;
  3318. case 0:
  3319. default:
  3320. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  3321. break;
  3322. }
  3323. pr_debug("%s: afe_lb_tx_format = %d, ucontrol value = %ld\n",
  3324. __func__, afe_lb_tx_cfg.bit_format,
  3325. ucontrol->value.integer.value[0]);
  3326. return 0;
  3327. }
  3328. static const struct snd_kcontrol_new msm_snd_sb_controls[] = {
  3329. SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
  3330. slim_rx_ch_get, slim_rx_ch_put),
  3331. SOC_ENUM_EXT("SLIM_2_RX Channels", slim_2_rx_chs,
  3332. slim_rx_ch_get, slim_rx_ch_put),
  3333. SOC_ENUM_EXT("SLIM_0_TX Channels", slim_0_tx_chs,
  3334. slim_tx_ch_get, slim_tx_ch_put),
  3335. SOC_ENUM_EXT("SLIM_1_TX Channels", slim_1_tx_chs,
  3336. slim_tx_ch_get, slim_tx_ch_put),
  3337. SOC_ENUM_EXT("SLIM_5_RX Channels", slim_5_rx_chs,
  3338. slim_rx_ch_get, slim_rx_ch_put),
  3339. SOC_ENUM_EXT("SLIM_6_RX Channels", slim_6_rx_chs,
  3340. slim_rx_ch_get, slim_rx_ch_put),
  3341. SOC_ENUM_EXT("SLIM_0_RX Format", slim_0_rx_format,
  3342. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3343. SOC_ENUM_EXT("SLIM_5_RX Format", slim_5_rx_format,
  3344. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3345. SOC_ENUM_EXT("SLIM_6_RX Format", slim_6_rx_format,
  3346. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3347. SOC_ENUM_EXT("SLIM_0_TX Format", slim_0_tx_format,
  3348. slim_tx_bit_format_get, slim_tx_bit_format_put),
  3349. SOC_ENUM_EXT("SLIM_0_RX SampleRate", slim_0_rx_sample_rate,
  3350. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3351. SOC_ENUM_EXT("SLIM_2_RX SampleRate", slim_2_rx_sample_rate,
  3352. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3353. SOC_ENUM_EXT("SLIM_0_TX SampleRate", slim_0_tx_sample_rate,
  3354. slim_tx_sample_rate_get, slim_tx_sample_rate_put),
  3355. SOC_ENUM_EXT("SLIM_5_RX SampleRate", slim_5_rx_sample_rate,
  3356. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3357. SOC_ENUM_EXT("SLIM_6_RX SampleRate", slim_6_rx_sample_rate,
  3358. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3359. };
  3360. static const struct snd_kcontrol_new msm_snd_va_controls[] = {
  3361. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  3362. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3363. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  3364. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3365. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  3366. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3367. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  3368. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3369. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  3370. va_cdc_dma_tx_0_sample_rate,
  3371. cdc_dma_tx_sample_rate_get,
  3372. cdc_dma_tx_sample_rate_put),
  3373. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  3374. va_cdc_dma_tx_1_sample_rate,
  3375. cdc_dma_tx_sample_rate_get,
  3376. cdc_dma_tx_sample_rate_put),
  3377. };
  3378. static const struct snd_kcontrol_new msm_snd_wsa_controls[] = {
  3379. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3380. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3381. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  3382. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3383. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  3384. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3385. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  3386. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3387. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  3388. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3389. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  3390. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3391. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  3392. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3393. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  3394. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3395. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  3396. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3397. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  3398. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3399. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  3400. wsa_cdc_dma_rx_0_sample_rate,
  3401. cdc_dma_rx_sample_rate_get,
  3402. cdc_dma_rx_sample_rate_put),
  3403. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  3404. wsa_cdc_dma_rx_1_sample_rate,
  3405. cdc_dma_rx_sample_rate_get,
  3406. cdc_dma_rx_sample_rate_put),
  3407. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  3408. wsa_cdc_dma_tx_0_sample_rate,
  3409. cdc_dma_tx_sample_rate_get,
  3410. cdc_dma_tx_sample_rate_put),
  3411. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  3412. wsa_cdc_dma_tx_1_sample_rate,
  3413. cdc_dma_tx_sample_rate_get,
  3414. cdc_dma_tx_sample_rate_put),
  3415. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  3416. wsa_cdc_dma_tx_2_sample_rate,
  3417. cdc_dma_tx_sample_rate_get,
  3418. cdc_dma_tx_sample_rate_put),
  3419. };
  3420. static const struct snd_kcontrol_new msm_snd_controls[] = {
  3421. SOC_ENUM_EXT("BT_TX SampleRate", bt_sample_rate_sink,
  3422. msm_bt_sample_rate_sink_get,
  3423. msm_bt_sample_rate_sink_put),
  3424. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3425. msm_bt_sample_rate_get,
  3426. msm_bt_sample_rate_put),
  3427. SOC_ENUM_EXT("BT_RX SampleRate", bt_sample_rate,
  3428. msm_bt_sample_rate_get,
  3429. msm_bt_sample_rate_put),
  3430. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3431. proxy_rx_ch_get, proxy_rx_ch_put),
  3432. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3433. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3434. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3435. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3436. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3437. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3438. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3439. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3440. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3441. usb_audio_rx_sample_rate_get,
  3442. usb_audio_rx_sample_rate_put),
  3443. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3444. usb_audio_tx_sample_rate_get,
  3445. usb_audio_tx_sample_rate_put),
  3446. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3447. tdm_rx_sample_rate_get,
  3448. tdm_rx_sample_rate_put),
  3449. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3450. tdm_tx_sample_rate_get,
  3451. tdm_tx_sample_rate_put),
  3452. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3453. tdm_rx_format_get,
  3454. tdm_rx_format_put),
  3455. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3456. tdm_tx_format_get,
  3457. tdm_tx_format_put),
  3458. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3459. tdm_rx_ch_get,
  3460. tdm_rx_ch_put),
  3461. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3462. tdm_tx_ch_get,
  3463. tdm_tx_ch_put),
  3464. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3465. tdm_rx_sample_rate_get,
  3466. tdm_rx_sample_rate_put),
  3467. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3468. tdm_tx_sample_rate_get,
  3469. tdm_tx_sample_rate_put),
  3470. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3471. tdm_rx_format_get,
  3472. tdm_rx_format_put),
  3473. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3474. tdm_tx_format_get,
  3475. tdm_tx_format_put),
  3476. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3477. tdm_rx_ch_get,
  3478. tdm_rx_ch_put),
  3479. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3480. tdm_tx_ch_get,
  3481. tdm_tx_ch_put),
  3482. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3483. tdm_rx_sample_rate_get,
  3484. tdm_rx_sample_rate_put),
  3485. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3486. tdm_tx_sample_rate_get,
  3487. tdm_tx_sample_rate_put),
  3488. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3489. tdm_rx_format_get,
  3490. tdm_rx_format_put),
  3491. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3492. tdm_tx_format_get,
  3493. tdm_tx_format_put),
  3494. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3495. tdm_rx_ch_get,
  3496. tdm_rx_ch_put),
  3497. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3498. tdm_tx_ch_get,
  3499. tdm_tx_ch_put),
  3500. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3501. tdm_rx_sample_rate_get,
  3502. tdm_rx_sample_rate_put),
  3503. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3504. tdm_tx_sample_rate_get,
  3505. tdm_tx_sample_rate_put),
  3506. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3507. tdm_rx_format_get,
  3508. tdm_rx_format_put),
  3509. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3510. tdm_tx_format_get,
  3511. tdm_tx_format_put),
  3512. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3513. tdm_rx_ch_get,
  3514. tdm_rx_ch_put),
  3515. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3516. tdm_tx_ch_get,
  3517. tdm_tx_ch_put),
  3518. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3519. tdm_rx_sample_rate_get,
  3520. tdm_rx_sample_rate_put),
  3521. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3522. tdm_tx_sample_rate_get,
  3523. tdm_tx_sample_rate_put),
  3524. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3525. tdm_rx_format_get,
  3526. tdm_rx_format_put),
  3527. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3528. tdm_tx_format_get,
  3529. tdm_tx_format_put),
  3530. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3531. tdm_rx_ch_get,
  3532. tdm_rx_ch_put),
  3533. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3534. tdm_tx_ch_get,
  3535. tdm_tx_ch_put),
  3536. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3537. aux_pcm_rx_sample_rate_get,
  3538. aux_pcm_rx_sample_rate_put),
  3539. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3540. aux_pcm_rx_sample_rate_get,
  3541. aux_pcm_rx_sample_rate_put),
  3542. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3543. aux_pcm_rx_sample_rate_get,
  3544. aux_pcm_rx_sample_rate_put),
  3545. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3546. aux_pcm_rx_sample_rate_get,
  3547. aux_pcm_rx_sample_rate_put),
  3548. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3549. aux_pcm_rx_sample_rate_get,
  3550. aux_pcm_rx_sample_rate_put),
  3551. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3552. aux_pcm_tx_sample_rate_get,
  3553. aux_pcm_tx_sample_rate_put),
  3554. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3555. aux_pcm_tx_sample_rate_get,
  3556. aux_pcm_tx_sample_rate_put),
  3557. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3558. aux_pcm_tx_sample_rate_get,
  3559. aux_pcm_tx_sample_rate_put),
  3560. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3561. aux_pcm_tx_sample_rate_get,
  3562. aux_pcm_tx_sample_rate_put),
  3563. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3564. aux_pcm_tx_sample_rate_get,
  3565. aux_pcm_tx_sample_rate_put),
  3566. SOC_ENUM_EXT("SEN_AUX_PCM_TX SampleRate", sen_aux_pcm_tx_sample_rate,
  3567. aux_pcm_tx_sample_rate_get,
  3568. aux_pcm_tx_sample_rate_put),
  3569. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3570. mi2s_rx_sample_rate_get,
  3571. mi2s_rx_sample_rate_put),
  3572. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3573. mi2s_rx_sample_rate_get,
  3574. mi2s_rx_sample_rate_put),
  3575. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3576. mi2s_rx_sample_rate_get,
  3577. mi2s_rx_sample_rate_put),
  3578. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3579. mi2s_rx_sample_rate_get,
  3580. mi2s_rx_sample_rate_put),
  3581. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3582. mi2s_rx_sample_rate_get,
  3583. mi2s_rx_sample_rate_put),
  3584. SOC_ENUM_EXT("SEN_MI2S_RX SampleRate", sen_mi2s_rx_sample_rate,
  3585. mi2s_rx_sample_rate_get,
  3586. mi2s_rx_sample_rate_put),
  3587. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3588. mi2s_tx_sample_rate_get,
  3589. mi2s_tx_sample_rate_put),
  3590. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3591. mi2s_tx_sample_rate_get,
  3592. mi2s_tx_sample_rate_put),
  3593. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3594. mi2s_tx_sample_rate_get,
  3595. mi2s_tx_sample_rate_put),
  3596. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3597. mi2s_tx_sample_rate_get,
  3598. mi2s_tx_sample_rate_put),
  3599. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3600. mi2s_tx_sample_rate_get,
  3601. mi2s_tx_sample_rate_put),
  3602. SOC_ENUM_EXT("SEN_MI2S_TX SampleRate", sen_mi2s_tx_sample_rate,
  3603. mi2s_tx_sample_rate_get,
  3604. mi2s_tx_sample_rate_put),
  3605. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3606. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3607. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3608. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3609. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3610. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3611. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3612. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3613. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3614. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3615. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3616. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3617. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3618. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3619. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3620. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3621. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3622. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3623. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3624. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3625. SOC_ENUM_EXT("SEN_MI2S_RX Channels", sen_mi2s_rx_chs,
  3626. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3627. SOC_ENUM_EXT("SEN_MI2S_TX Channels", sen_mi2s_tx_chs,
  3628. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3629. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3630. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3631. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3632. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3633. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3634. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3635. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3636. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3637. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3638. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3639. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3640. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3641. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3642. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3643. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3644. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3645. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3646. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3647. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3648. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3649. SOC_ENUM_EXT("SEN_MI2S_RX Format", mi2s_rx_format,
  3650. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3651. SOC_ENUM_EXT("SEN_MI2S_TX Format", mi2s_tx_format,
  3652. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3653. SOC_ENUM_EXT("PRIM_META_MI2S_RX SampleRate",
  3654. prim_meta_mi2s_rx_sample_rate,
  3655. msm_meta_mi2s_rx_sample_rate_get,
  3656. msm_meta_mi2s_rx_sample_rate_put),
  3657. SOC_ENUM_EXT("SEC_META_MI2S_RX SampleRate",
  3658. sec_meta_mi2s_rx_sample_rate,
  3659. msm_meta_mi2s_rx_sample_rate_get,
  3660. msm_meta_mi2s_rx_sample_rate_put),
  3661. SOC_ENUM_EXT("PRIM_META_MI2S_RX Channels", prim_meta_mi2s_rx_chs,
  3662. msm_meta_mi2s_rx_ch_get,
  3663. msm_meta_mi2s_rx_ch_put),
  3664. SOC_ENUM_EXT("SEC_META_MI2S_RX Channels", sec_meta_mi2s_rx_chs,
  3665. msm_meta_mi2s_rx_ch_get,
  3666. msm_meta_mi2s_rx_ch_put),
  3667. SOC_ENUM_EXT("PRIM_META_MI2S_RX Format", mi2s_rx_format,
  3668. msm_meta_mi2s_rx_format_get,
  3669. msm_meta_mi2s_rx_format_put),
  3670. SOC_ENUM_EXT("SEC_META_MI2S_RX Format", mi2s_rx_format,
  3671. msm_meta_mi2s_rx_format_get,
  3672. msm_meta_mi2s_rx_format_put),
  3673. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3674. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3675. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3676. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3677. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3678. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3679. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3680. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3681. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3682. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3683. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3684. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3685. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3686. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3687. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3688. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3689. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3690. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3691. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3692. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3693. SOC_ENUM_EXT("SEN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3694. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3695. SOC_ENUM_EXT("SEN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3696. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3697. SOC_SINGLE_MULTI_EXT("VAD CFG", SND_SOC_NOPM, 0, 1000, 0, 3, NULL,
  3698. msm_snd_vad_cfg_put),
  3699. SOC_ENUM_EXT("PRIM_SPDIF_RX SampleRate", spdif_rx_sample_rate,
  3700. msm_spdif_rx_sample_rate_get,
  3701. msm_spdif_rx_sample_rate_put),
  3702. SOC_ENUM_EXT("PRIM_SPDIF_TX SampleRate", spdif_tx_sample_rate,
  3703. msm_spdif_tx_sample_rate_get,
  3704. msm_spdif_tx_sample_rate_put),
  3705. SOC_ENUM_EXT("SEC_SPDIF_RX SampleRate", spdif_rx_sample_rate,
  3706. msm_spdif_rx_sample_rate_get,
  3707. msm_spdif_rx_sample_rate_put),
  3708. SOC_ENUM_EXT("SEC_SPDIF_TX SampleRate", spdif_tx_sample_rate,
  3709. msm_spdif_tx_sample_rate_get,
  3710. msm_spdif_tx_sample_rate_put),
  3711. SOC_ENUM_EXT("PRIM_SPDIF_RX Channels", spdif_rx_chs,
  3712. msm_spdif_rx_ch_get, msm_spdif_rx_ch_put),
  3713. SOC_ENUM_EXT("PRIM_SPDIF_TX Channels", spdif_tx_chs,
  3714. msm_spdif_tx_ch_get, msm_spdif_tx_ch_put),
  3715. SOC_ENUM_EXT("SEC_SPDIF_RX Channels", spdif_rx_chs,
  3716. msm_spdif_rx_ch_get, msm_spdif_rx_ch_put),
  3717. SOC_ENUM_EXT("SEC_SPDIF_TX Channels", spdif_tx_chs,
  3718. msm_spdif_tx_ch_get, msm_spdif_tx_ch_put),
  3719. SOC_ENUM_EXT("PRIM_SPDIF_RX Format", spdif_rx_format,
  3720. msm_spdif_rx_format_get, msm_spdif_rx_format_put),
  3721. SOC_ENUM_EXT("PRIM_SPDIF_TX Format", spdif_tx_format,
  3722. msm_spdif_tx_format_get, msm_spdif_tx_format_put),
  3723. SOC_ENUM_EXT("SEC_SPDIF_RX Format", spdif_rx_format,
  3724. msm_spdif_rx_format_get, msm_spdif_rx_format_put),
  3725. SOC_ENUM_EXT("SEC_SPDIF_TX Format", spdif_tx_format,
  3726. msm_spdif_tx_format_get, msm_spdif_tx_format_put),
  3727. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_lb_tx_chs,
  3728. afe_lb_tx_ch_get, afe_lb_tx_ch_put),
  3729. SOC_ENUM_EXT("AFE_LOOPBACK_TX Format", afe_lb_tx_format,
  3730. afe_lb_tx_format_get, afe_lb_tx_format_put),
  3731. SOC_ENUM_EXT("AFE_LOOPBACK_TX SampleRate", afe_lb_tx_sample_rate,
  3732. afe_lb_tx_sample_rate_get,
  3733. afe_lb_tx_sample_rate_put),
  3734. };
  3735. static int msm_snd_enable_codec_ext_clk(struct snd_soc_component *component,
  3736. int enable, bool dapm)
  3737. {
  3738. int ret = 0;
  3739. if (!strcmp(component.name, "tasha_codec")) {
  3740. ret = tasha_cdc_mclk_enable(component, enable, dapm);
  3741. } else {
  3742. dev_err(component->dev, "%s: unknown codec to enable ext clk\n",
  3743. __func__);
  3744. ret = -EINVAL;
  3745. }
  3746. return ret;
  3747. }
  3748. static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_component *component,
  3749. int enable, bool dapm)
  3750. {
  3751. int ret = 0;
  3752. if (!strcmp(component.name, "tasha_codec")) {
  3753. ret = tasha_cdc_mclk_tx_enable(component, enable, dapm);
  3754. } else {
  3755. dev_err(component->dev, "%s: unknown codec to enable TX ext clk\n",
  3756. __func__);
  3757. ret = -EINVAL;
  3758. }
  3759. return ret;
  3760. }
  3761. static int msm_mclk_tx_event(struct snd_soc_dapm_widget *w,
  3762. struct snd_kcontrol *kcontrol, int event)
  3763. {
  3764. struct snd_soc_component *component =
  3765. snd_soc_dapm_to_component(w->dapm);
  3766. pr_debug("%s: event = %d\n", __func__, event);
  3767. switch (event) {
  3768. case SND_SOC_DAPM_PRE_PMU:
  3769. return msm_snd_enable_codec_ext_tx_clk(component, 1, true);
  3770. case SND_SOC_DAPM_POST_PMD:
  3771. return msm_snd_enable_codec_ext_tx_clk(component, 0, true);
  3772. }
  3773. return 0;
  3774. }
  3775. static int msm_mclk_event(struct snd_soc_dapm_widget *w,
  3776. struct snd_kcontrol *kcontrol, int event)
  3777. {
  3778. struct snd_soc_component *component =
  3779. snd_soc_dapm_to_component(w->dapm);
  3780. pr_debug("%s: event = %d\n", __func__, event);
  3781. switch (event) {
  3782. case SND_SOC_DAPM_PRE_PMU:
  3783. return msm_snd_enable_codec_ext_clk(component, 1, true);
  3784. case SND_SOC_DAPM_POST_PMD:
  3785. return msm_snd_enable_codec_ext_clk(component, 0, true);
  3786. }
  3787. return 0;
  3788. }
  3789. static int msm_lineout_booster_ctrl_event(struct snd_soc_dapm_widget *w,
  3790. struct snd_kcontrol *k, int event)
  3791. {
  3792. struct snd_soc_component *component =
  3793. snd_soc_dapm_to_component(w->dapm);
  3794. struct snd_soc_card *card = component->card;
  3795. struct msm_asoc_mach_data *pdata =
  3796. snd_soc_card_get_drvdata(card);
  3797. pr_debug("%s: event = %d\n", __func__, event);
  3798. switch (event) {
  3799. case SND_SOC_DAPM_POST_PMU:
  3800. msm_cdc_pinctrl_select_active_state(
  3801. pdata->lineout_booster_gpio_p);
  3802. break;
  3803. case SND_SOC_DAPM_PRE_PMD:
  3804. msm_cdc_pinctrl_select_sleep_state(
  3805. pdata->lineout_booster_gpio_p);
  3806. break;
  3807. }
  3808. return 0;
  3809. }
  3810. static const struct snd_soc_dapm_widget msm_dapm_widgets[] = {
  3811. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  3812. msm_mclk_event,
  3813. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  3814. SND_SOC_DAPM_SUPPLY("MCLK TX", SND_SOC_NOPM, 0, 0,
  3815. msm_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  3816. SND_SOC_DAPM_SPK("lineout booster", msm_lineout_booster_ctrl_event),
  3817. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  3818. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3819. };
  3820. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  3821. struct snd_kcontrol *kcontrol, int event)
  3822. {
  3823. struct msm_asoc_mach_data *pdata = NULL;
  3824. struct snd_soc_component *component =
  3825. snd_soc_dapm_to_component(w->dapm);
  3826. int ret = 0;
  3827. uint32_t dmic_idx;
  3828. int *dmic_gpio_cnt;
  3829. struct device_node *dmic_gpio;
  3830. char *wname;
  3831. wname = strpbrk(w->name, "01234567");
  3832. if (!wname) {
  3833. dev_err(component->dev, "%s: widget not found\n", __func__);
  3834. return -EINVAL;
  3835. }
  3836. ret = kstrtouint(wname, 10, &dmic_idx);
  3837. if (ret < 0) {
  3838. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  3839. __func__);
  3840. return -EINVAL;
  3841. }
  3842. pdata = snd_soc_card_get_drvdata(component->card);
  3843. switch (dmic_idx) {
  3844. case 0:
  3845. case 1:
  3846. dmic_gpio_cnt = &pdata->dmic_01_gpio_cnt;
  3847. dmic_gpio = pdata->dmic_01_gpio_p;
  3848. break;
  3849. case 2:
  3850. case 3:
  3851. dmic_gpio_cnt = &pdata->dmic_23_gpio_cnt;
  3852. dmic_gpio = pdata->dmic_23_gpio_p;
  3853. break;
  3854. case 4:
  3855. case 5:
  3856. dmic_gpio_cnt = &pdata->dmic_45_gpio_cnt;
  3857. dmic_gpio = pdata->dmic_45_gpio_p;
  3858. break;
  3859. case 6:
  3860. case 7:
  3861. dmic_gpio_cnt = &pdata->dmic_67_gpio_cnt;
  3862. dmic_gpio = pdata->dmic_67_gpio_p;
  3863. break;
  3864. default:
  3865. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  3866. __func__);
  3867. return -EINVAL;
  3868. }
  3869. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  3870. __func__, event, dmic_idx, *dmic_gpio_cnt);
  3871. switch (event) {
  3872. case SND_SOC_DAPM_PRE_PMU:
  3873. (*dmic_gpio_cnt)++;
  3874. if (*dmic_gpio_cnt == 1) {
  3875. ret = msm_cdc_pinctrl_select_active_state(
  3876. dmic_gpio);
  3877. if (ret < 0) {
  3878. dev_err(component->dev, "%s: gpio set cannot be activated %sd\n",
  3879. __func__, "dmic_gpio");
  3880. return ret;
  3881. }
  3882. }
  3883. break;
  3884. case SND_SOC_DAPM_POST_PMD:
  3885. (*dmic_gpio_cnt)--;
  3886. if (*dmic_gpio_cnt == 0) {
  3887. ret = msm_cdc_pinctrl_select_sleep_state(
  3888. dmic_gpio);
  3889. if (ret < 0) {
  3890. dev_err(component->dev, "%s: gpio set cannot be de-activated %sd\n",
  3891. __func__, "dmic_gpio");
  3892. return ret;
  3893. }
  3894. }
  3895. break;
  3896. default:
  3897. dev_err(component->dev, "%s: invalid DAPM event %d\n",
  3898. __func__, event);
  3899. return -EINVAL;
  3900. }
  3901. return 0;
  3902. }
  3903. static const struct snd_soc_dapm_widget msm_va_dapm_widgets[] = {
  3904. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  3905. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  3906. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  3907. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  3908. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  3909. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  3910. SND_SOC_DAPM_MIC("Digital Mic6", msm_dmic_event),
  3911. SND_SOC_DAPM_MIC("Digital Mic7", msm_dmic_event),
  3912. };
  3913. static const struct snd_soc_dapm_widget msm_wsa_dapm_widgets[] = {
  3914. };
  3915. static inline int param_is_mask(int p)
  3916. {
  3917. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  3918. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  3919. }
  3920. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  3921. int n)
  3922. {
  3923. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  3924. }
  3925. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  3926. unsigned int bit)
  3927. {
  3928. if (bit >= SNDRV_MASK_MAX)
  3929. return;
  3930. if (param_is_mask(n)) {
  3931. struct snd_mask *m = param_to_mask(p, n);
  3932. m->bits[0] = 0;
  3933. m->bits[1] = 0;
  3934. m->bits[bit >> 5] |= (1 << (bit & 31));
  3935. }
  3936. }
  3937. static int msm_slim_get_ch_from_beid(int32_t be_id)
  3938. {
  3939. int ch_id = 0;
  3940. switch (be_id) {
  3941. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  3942. ch_id = SLIM_RX_0;
  3943. break;
  3944. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  3945. ch_id = SLIM_RX_1;
  3946. break;
  3947. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  3948. ch_id = SLIM_RX_2;
  3949. break;
  3950. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  3951. ch_id = SLIM_RX_3;
  3952. break;
  3953. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  3954. ch_id = SLIM_RX_4;
  3955. break;
  3956. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  3957. ch_id = SLIM_RX_6;
  3958. break;
  3959. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  3960. ch_id = SLIM_TX_0;
  3961. break;
  3962. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  3963. ch_id = SLIM_TX_3;
  3964. break;
  3965. default:
  3966. ch_id = SLIM_RX_0;
  3967. break;
  3968. }
  3969. return ch_id;
  3970. }
  3971. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  3972. {
  3973. int idx = 0;
  3974. switch (be_id) {
  3975. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3976. idx = WSA_CDC_DMA_RX_0;
  3977. break;
  3978. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3979. idx = WSA_CDC_DMA_TX_0;
  3980. break;
  3981. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3982. idx = WSA_CDC_DMA_RX_1;
  3983. break;
  3984. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3985. idx = WSA_CDC_DMA_TX_1;
  3986. break;
  3987. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3988. idx = WSA_CDC_DMA_TX_2;
  3989. break;
  3990. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3991. idx = VA_CDC_DMA_TX_0;
  3992. break;
  3993. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3994. idx = VA_CDC_DMA_TX_1;
  3995. break;
  3996. default:
  3997. idx = VA_CDC_DMA_TX_0;
  3998. break;
  3999. }
  4000. return idx;
  4001. }
  4002. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  4003. struct snd_pcm_hw_params *params)
  4004. {
  4005. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4006. struct snd_interval *rate = hw_param_interval(params,
  4007. SNDRV_PCM_HW_PARAM_RATE);
  4008. struct snd_interval *channels = hw_param_interval(params,
  4009. SNDRV_PCM_HW_PARAM_CHANNELS);
  4010. int rc = 0;
  4011. int idx;
  4012. void *config = NULL;
  4013. struct snd_soc_component *component = NULL;
  4014. pr_debug("%s: format = %d, rate = %d\n",
  4015. __func__, params_format(params), params_rate(params));
  4016. switch (dai_link->id) {
  4017. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  4018. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  4019. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  4020. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  4021. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  4022. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  4023. idx = msm_slim_get_ch_from_beid(dai_link->id);
  4024. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4025. slim_rx_cfg[idx].bit_format);
  4026. rate->min = rate->max = slim_rx_cfg[idx].sample_rate;
  4027. channels->min = channels->max = slim_rx_cfg[idx].channels;
  4028. break;
  4029. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  4030. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  4031. idx = msm_slim_get_ch_from_beid(dai_link->id);
  4032. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4033. slim_tx_cfg[idx].bit_format);
  4034. rate->min = rate->max = slim_tx_cfg[idx].sample_rate;
  4035. channels->min = channels->max = slim_tx_cfg[idx].channels;
  4036. break;
  4037. case MSM_BACKEND_DAI_SLIMBUS_1_TX:
  4038. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4039. slim_tx_cfg[1].bit_format);
  4040. rate->min = rate->max = slim_tx_cfg[1].sample_rate;
  4041. channels->min = channels->max = slim_tx_cfg[1].channels;
  4042. break;
  4043. case MSM_BACKEND_DAI_SLIMBUS_4_TX:
  4044. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4045. SNDRV_PCM_FORMAT_S32_LE);
  4046. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  4047. channels->min = channels->max = msm_vi_feed_tx_ch;
  4048. break;
  4049. case MSM_BACKEND_DAI_SLIMBUS_5_RX:
  4050. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4051. slim_rx_cfg[5].bit_format);
  4052. rate->min = rate->max = slim_rx_cfg[5].sample_rate;
  4053. channels->min = channels->max = slim_rx_cfg[5].channels;
  4054. break;
  4055. case MSM_BACKEND_DAI_SLIMBUS_5_TX:
  4056. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  4057. if (!component) {
  4058. pr_err("%s: component is NULL\n", __func__);
  4059. return -EINVAL;
  4060. }
  4061. rate->min = rate->max = SAMPLING_RATE_16KHZ;
  4062. channels->min = channels->max = 1;
  4063. config = msm_codec_fn.get_afe_config_fn(component,
  4064. AFE_SLIMBUS_SLAVE_PORT_CONFIG);
  4065. if (config) {
  4066. rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG,
  4067. config, SLIMBUS_5_TX);
  4068. if (rc)
  4069. pr_err("%s: Failed to set slimbus slave port config %d\n",
  4070. __func__, rc);
  4071. }
  4072. break;
  4073. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  4074. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4075. slim_rx_cfg[SLIM_RX_7].bit_format);
  4076. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  4077. channels->min = channels->max =
  4078. slim_rx_cfg[SLIM_RX_7].channels;
  4079. break;
  4080. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  4081. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  4082. channels->min = channels->max =
  4083. slim_tx_cfg[SLIM_TX_7].channels;
  4084. break;
  4085. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  4086. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  4087. channels->min = channels->max =
  4088. slim_tx_cfg[SLIM_TX_8].channels;
  4089. break;
  4090. case MSM_BACKEND_DAI_SLIMBUS_9_TX:
  4091. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4092. slim_tx_cfg[SLIM_TX_9].bit_format);
  4093. rate->min = rate->max = slim_tx_cfg[SLIM_TX_9].sample_rate;
  4094. channels->min = channels->max =
  4095. slim_tx_cfg[SLIM_TX_9].channels;
  4096. break;
  4097. case MSM_BACKEND_DAI_USB_RX:
  4098. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4099. usb_rx_cfg.bit_format);
  4100. rate->min = rate->max = usb_rx_cfg.sample_rate;
  4101. channels->min = channels->max = usb_rx_cfg.channels;
  4102. break;
  4103. case MSM_BACKEND_DAI_USB_TX:
  4104. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4105. usb_tx_cfg.bit_format);
  4106. rate->min = rate->max = usb_tx_cfg.sample_rate;
  4107. channels->min = channels->max = usb_tx_cfg.channels;
  4108. break;
  4109. case MSM_BACKEND_DAI_AFE_PCM_RX:
  4110. channels->min = channels->max = proxy_rx_cfg.channels;
  4111. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4112. break;
  4113. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  4114. channels->min = channels->max =
  4115. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  4116. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4117. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  4118. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  4119. break;
  4120. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  4121. channels->min = channels->max =
  4122. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  4123. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4124. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  4125. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  4126. break;
  4127. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  4128. channels->min = channels->max =
  4129. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  4130. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4131. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  4132. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  4133. break;
  4134. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  4135. channels->min = channels->max =
  4136. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  4137. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4138. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  4139. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  4140. break;
  4141. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  4142. channels->min = channels->max =
  4143. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  4144. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4145. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  4146. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  4147. break;
  4148. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  4149. channels->min = channels->max =
  4150. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  4151. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4152. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  4153. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  4154. break;
  4155. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  4156. channels->min = channels->max =
  4157. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  4158. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4159. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  4160. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  4161. break;
  4162. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  4163. channels->min = channels->max =
  4164. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  4165. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4166. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  4167. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  4168. break;
  4169. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  4170. channels->min = channels->max =
  4171. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  4172. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4173. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  4174. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  4175. break;
  4176. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  4177. channels->min = channels->max =
  4178. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  4179. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4180. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  4181. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  4182. break;
  4183. case MSM_BACKEND_DAI_AUXPCM_RX:
  4184. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4185. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  4186. rate->min = rate->max =
  4187. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  4188. channels->min = channels->max =
  4189. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  4190. break;
  4191. case MSM_BACKEND_DAI_AUXPCM_TX:
  4192. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4193. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  4194. rate->min = rate->max =
  4195. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  4196. channels->min = channels->max =
  4197. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  4198. break;
  4199. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  4200. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4201. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  4202. rate->min = rate->max =
  4203. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  4204. channels->min = channels->max =
  4205. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  4206. break;
  4207. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  4208. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4209. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  4210. rate->min = rate->max =
  4211. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  4212. channels->min = channels->max =
  4213. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  4214. break;
  4215. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  4216. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4217. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  4218. rate->min = rate->max =
  4219. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  4220. channels->min = channels->max =
  4221. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  4222. break;
  4223. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  4224. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4225. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  4226. rate->min = rate->max =
  4227. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  4228. channels->min = channels->max =
  4229. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  4230. break;
  4231. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  4232. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4233. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  4234. rate->min = rate->max =
  4235. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  4236. channels->min = channels->max =
  4237. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  4238. break;
  4239. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  4240. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4241. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  4242. rate->min = rate->max =
  4243. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  4244. channels->min = channels->max =
  4245. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  4246. break;
  4247. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  4248. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4249. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  4250. rate->min = rate->max =
  4251. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  4252. channels->min = channels->max =
  4253. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  4254. break;
  4255. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  4256. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4257. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  4258. rate->min = rate->max =
  4259. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  4260. channels->min = channels->max =
  4261. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  4262. break;
  4263. case MSM_BACKEND_DAI_SEN_AUXPCM_RX:
  4264. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4265. aux_pcm_rx_cfg[SEN_AUX_PCM].bit_format);
  4266. rate->min = rate->max =
  4267. aux_pcm_rx_cfg[SEN_AUX_PCM].sample_rate;
  4268. channels->min = channels->max =
  4269. aux_pcm_rx_cfg[SEN_AUX_PCM].channels;
  4270. break;
  4271. case MSM_BACKEND_DAI_SEN_AUXPCM_TX:
  4272. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4273. aux_pcm_tx_cfg[SEN_AUX_PCM].bit_format);
  4274. rate->min = rate->max =
  4275. aux_pcm_tx_cfg[SEN_AUX_PCM].sample_rate;
  4276. channels->min = channels->max =
  4277. aux_pcm_tx_cfg[SEN_AUX_PCM].channels;
  4278. break;
  4279. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  4280. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4281. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  4282. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  4283. channels->min = channels->max =
  4284. mi2s_rx_cfg[PRIM_MI2S].channels;
  4285. break;
  4286. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  4287. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4288. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  4289. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  4290. channels->min = channels->max =
  4291. mi2s_tx_cfg[PRIM_MI2S].channels;
  4292. break;
  4293. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  4294. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4295. mi2s_rx_cfg[SEC_MI2S].bit_format);
  4296. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  4297. channels->min = channels->max =
  4298. mi2s_rx_cfg[SEC_MI2S].channels;
  4299. break;
  4300. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  4301. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4302. mi2s_tx_cfg[SEC_MI2S].bit_format);
  4303. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  4304. channels->min = channels->max =
  4305. mi2s_tx_cfg[SEC_MI2S].channels;
  4306. break;
  4307. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  4308. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4309. mi2s_rx_cfg[TERT_MI2S].bit_format);
  4310. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  4311. channels->min = channels->max =
  4312. mi2s_rx_cfg[TERT_MI2S].channels;
  4313. break;
  4314. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  4315. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4316. mi2s_tx_cfg[TERT_MI2S].bit_format);
  4317. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  4318. channels->min = channels->max =
  4319. mi2s_tx_cfg[TERT_MI2S].channels;
  4320. break;
  4321. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  4322. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4323. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  4324. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  4325. channels->min = channels->max =
  4326. mi2s_rx_cfg[QUAT_MI2S].channels;
  4327. break;
  4328. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  4329. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4330. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  4331. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  4332. channels->min = channels->max =
  4333. mi2s_tx_cfg[QUAT_MI2S].channels;
  4334. break;
  4335. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  4336. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4337. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  4338. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  4339. channels->min = channels->max =
  4340. mi2s_rx_cfg[QUIN_MI2S].channels;
  4341. break;
  4342. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  4343. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4344. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  4345. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  4346. channels->min = channels->max =
  4347. mi2s_tx_cfg[QUIN_MI2S].channels;
  4348. break;
  4349. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  4350. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4351. mi2s_rx_cfg[SEN_MI2S].bit_format);
  4352. rate->min = rate->max = mi2s_rx_cfg[SEN_MI2S].sample_rate;
  4353. channels->min = channels->max =
  4354. mi2s_rx_cfg[SEN_MI2S].channels;
  4355. break;
  4356. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  4357. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4358. mi2s_tx_cfg[SEN_MI2S].bit_format);
  4359. rate->min = rate->max = mi2s_tx_cfg[SEN_MI2S].sample_rate;
  4360. channels->min = channels->max =
  4361. mi2s_tx_cfg[SEN_MI2S].channels;
  4362. break;
  4363. case MSM_BACKEND_DAI_PRI_META_MI2S_RX:
  4364. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4365. meta_mi2s_rx_cfg[PRIM_META_MI2S].bit_format);
  4366. rate->min = rate->max =
  4367. meta_mi2s_rx_cfg[PRIM_META_MI2S].sample_rate;
  4368. channels->min = channels->max =
  4369. meta_mi2s_rx_cfg[PRIM_META_MI2S].channels;
  4370. break;
  4371. case MSM_BACKEND_DAI_SEC_META_MI2S_RX:
  4372. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4373. meta_mi2s_rx_cfg[SEC_META_MI2S].bit_format);
  4374. rate->min = rate->max =
  4375. meta_mi2s_rx_cfg[SEC_META_MI2S].sample_rate;
  4376. channels->min = channels->max =
  4377. meta_mi2s_rx_cfg[SEC_META_MI2S].channels;
  4378. break;
  4379. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4380. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4381. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4382. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4383. cdc_dma_rx_cfg[idx].bit_format);
  4384. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  4385. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  4386. break;
  4387. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4388. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4389. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4390. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4391. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4392. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4393. cdc_dma_tx_cfg[idx].bit_format);
  4394. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4395. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  4396. break;
  4397. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4398. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4399. SNDRV_PCM_FORMAT_S32_LE);
  4400. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  4401. channels->min = channels->max = msm_vi_feed_tx_ch;
  4402. break;
  4403. case MSM_BACKEND_DAI_PRI_SPDIF_RX:
  4404. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4405. spdif_rx_cfg[PRIM_SPDIF_RX].bit_format);
  4406. rate->min = rate->max =
  4407. spdif_rx_cfg[PRIM_SPDIF_RX].sample_rate;
  4408. channels->min = channels->max =
  4409. spdif_rx_cfg[PRIM_SPDIF_RX].channels;
  4410. break;
  4411. case MSM_BACKEND_DAI_PRI_SPDIF_TX:
  4412. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4413. spdif_tx_cfg[PRIM_SPDIF_TX].bit_format);
  4414. rate->min = rate->max =
  4415. spdif_tx_cfg[PRIM_SPDIF_TX].sample_rate;
  4416. channels->min = channels->max =
  4417. spdif_tx_cfg[PRIM_SPDIF_TX].channels;
  4418. break;
  4419. case MSM_BACKEND_DAI_SEC_SPDIF_RX:
  4420. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4421. spdif_rx_cfg[SEC_SPDIF_RX].bit_format);
  4422. rate->min = rate->max =
  4423. spdif_rx_cfg[SEC_SPDIF_RX].sample_rate;
  4424. channels->min = channels->max =
  4425. spdif_rx_cfg[SEC_SPDIF_RX].channels;
  4426. break;
  4427. case MSM_BACKEND_DAI_SEC_SPDIF_TX:
  4428. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4429. spdif_tx_cfg[SEC_SPDIF_TX].bit_format);
  4430. rate->min = rate->max =
  4431. spdif_tx_cfg[SEC_SPDIF_TX].sample_rate;
  4432. channels->min = channels->max =
  4433. spdif_tx_cfg[SEC_SPDIF_TX].channels;
  4434. break;
  4435. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  4436. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4437. afe_lb_tx_cfg.bit_format);
  4438. rate->min = rate->max = afe_lb_tx_cfg.sample_rate;
  4439. channels->min = channels->max = afe_lb_tx_cfg.channels;
  4440. break;
  4441. default:
  4442. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4443. break;
  4444. }
  4445. return rc;
  4446. }
  4447. static int msm_afe_set_config(struct snd_soc_component *component)
  4448. {
  4449. int ret = 0;
  4450. void *config_data = NULL;
  4451. if (!msm_codec_fn.get_afe_config_fn) {
  4452. dev_err(component->dev, "%s: codec get afe config not init'ed\n",
  4453. __func__);
  4454. return -EINVAL;
  4455. }
  4456. config_data = msm_codec_fn.get_afe_config_fn(component,
  4457. AFE_CDC_REGISTERS_CONFIG);
  4458. if (config_data) {
  4459. ret = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
  4460. if (ret) {
  4461. dev_err(component->dev,
  4462. "%s: Failed to set codec registers config %d\n",
  4463. __func__, ret);
  4464. return ret;
  4465. }
  4466. }
  4467. config_data = msm_codec_fn.get_afe_config_fn(component,
  4468. AFE_CDC_REGISTER_PAGE_CONFIG);
  4469. if (config_data) {
  4470. ret = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
  4471. 0);
  4472. if (ret)
  4473. dev_err(component->dev,
  4474. "%s: Failed to set cdc register page config\n",
  4475. __func__);
  4476. }
  4477. config_data = msm_codec_fn.get_afe_config_fn(component,
  4478. AFE_SLIMBUS_SLAVE_CONFIG);
  4479. if (config_data) {
  4480. ret = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
  4481. if (ret) {
  4482. dev_err(component->dev,
  4483. "%s: Failed to set slimbus slave config %d\n",
  4484. __func__, ret);
  4485. return ret;
  4486. }
  4487. }
  4488. return 0;
  4489. }
  4490. static void msm_afe_clear_config(void)
  4491. {
  4492. afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
  4493. afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
  4494. }
  4495. static int msm_adsp_power_up_config(struct snd_soc_component *component,
  4496. struct snd_card *card)
  4497. {
  4498. int ret = 0;
  4499. unsigned long timeout;
  4500. int adsp_ready = 0;
  4501. bool snd_card_online = 0;
  4502. timeout = jiffies +
  4503. msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
  4504. do {
  4505. if (!snd_card_online) {
  4506. snd_card_online = snd_card_is_online_state(card);
  4507. pr_debug("%s: Sound card is %s\n", __func__,
  4508. snd_card_online ? "Online" : "Offline");
  4509. }
  4510. if (!adsp_ready) {
  4511. adsp_ready = q6core_is_adsp_ready();
  4512. pr_debug("%s: ADSP Audio is %s\n", __func__,
  4513. adsp_ready ? "ready" : "not ready");
  4514. }
  4515. if (snd_card_online && adsp_ready)
  4516. break;
  4517. /*
  4518. * Sound card/ADSP will be coming up after subsystem restart and
  4519. * it might not be fully up when the control reaches
  4520. * here. So, wait for 50msec before checking ADSP state
  4521. */
  4522. msleep(50);
  4523. } while (time_after(timeout, jiffies));
  4524. if (!snd_card_online || !adsp_ready) {
  4525. pr_err("%s: Timeout. Sound card is %s, ADSP Audio is %s\n",
  4526. __func__,
  4527. snd_card_online ? "Online" : "Offline",
  4528. adsp_ready ? "ready" : "not ready");
  4529. ret = -ETIMEDOUT;
  4530. goto err;
  4531. }
  4532. ret = msm_afe_set_config(component);
  4533. if (ret)
  4534. pr_err("%s: Failed to set AFE config. err %d\n",
  4535. __func__, ret);
  4536. return 0;
  4537. err:
  4538. return ret;
  4539. }
  4540. static int qcs405_notifier_service_cb(struct notifier_block *this,
  4541. unsigned long opcode, void *ptr)
  4542. {
  4543. int ret;
  4544. struct snd_soc_card *card = NULL;
  4545. const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
  4546. struct snd_soc_pcm_runtime *rtd;
  4547. struct snd_soc_dai *codec_dai;
  4548. struct snd_soc_component *component;
  4549. pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
  4550. switch (opcode) {
  4551. case AUDIO_NOTIFIER_SERVICE_DOWN:
  4552. /*
  4553. * Use flag to ignore initial boot notifications
  4554. * On initial boot msm_adsp_power_up_config is
  4555. * called on init. There is no need to clear
  4556. * and set the config again on initial boot.
  4557. */
  4558. if (is_initial_boot)
  4559. break;
  4560. msm_afe_clear_config();
  4561. break;
  4562. case AUDIO_NOTIFIER_SERVICE_UP:
  4563. if (is_initial_boot) {
  4564. is_initial_boot = false;
  4565. break;
  4566. }
  4567. if (!spdev)
  4568. return -EINVAL;
  4569. card = platform_get_drvdata(spdev);
  4570. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  4571. if (!rtd) {
  4572. dev_err(card->dev,
  4573. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  4574. __func__, be_dl_name);
  4575. ret = -EINVAL;
  4576. goto err;
  4577. }
  4578. codec_dai = rtd->codec_dai;
  4579. if (!strcmp(dev_name(codec_dai->dev), "tasha_codec"))
  4580. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  4581. ret = msm_adsp_power_up_config(component, card->snd_card);
  4582. if (ret < 0) {
  4583. dev_err(card->dev,
  4584. "%s: msm_adsp_power_up_config failed ret = %d!\n",
  4585. __func__, ret);
  4586. goto err;
  4587. }
  4588. break;
  4589. default:
  4590. break;
  4591. }
  4592. err:
  4593. return NOTIFY_OK;
  4594. }
  4595. static struct notifier_block service_nb = {
  4596. .notifier_call = qcs405_notifier_service_cb,
  4597. .priority = -INT_MAX,
  4598. };
  4599. static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
  4600. {
  4601. int ret = 0;
  4602. void *config_data;
  4603. struct snd_soc_component *component;
  4604. struct snd_soc_dapm_context *dapm;
  4605. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4606. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4607. struct snd_card *card;
  4608. struct msm_asoc_mach_data *pdata =
  4609. snd_soc_card_get_drvdata(rtd->card);
  4610. /*
  4611. * Codec SLIMBUS configuration
  4612. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8
  4613. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  4614. * TX14, TX15, TX16
  4615. */
  4616. unsigned int rx_ch[TASHA_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
  4617. 151, 152, 153, 154, 155, 156};
  4618. unsigned int tx_ch[TASHA_TX_MAX] = {128, 129, 130, 131, 132, 133,
  4619. 134, 135, 136, 137, 138, 139,
  4620. 140, 141, 142, 143};
  4621. pr_info("%s: dev_name:%s\n", __func__, dev_name(cpu_dai->dev));
  4622. rtd->pmdown_time = 0;
  4623. if (!strcmp(dev_name(codec_dai->dev), "tasha_codec")) {
  4624. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  4625. dapm = snd_soc_component_get_dapm(component);
  4626. }
  4627. ret = snd_soc_add_component_controls(component, msm_snd_sb_controls,
  4628. ARRAY_SIZE(msm_snd_sb_controls));
  4629. if (ret < 0) {
  4630. pr_err("%s: add_codec_controls failed, err %d\n",
  4631. __func__, ret);
  4632. return ret;
  4633. }
  4634. snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
  4635. ARRAY_SIZE(msm_dapm_widgets));
  4636. snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
  4637. ARRAY_SIZE(wcd_audio_paths));
  4638. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
  4639. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
  4640. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  4641. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  4642. snd_soc_dapm_ignore_suspend(dapm, "lineout booster");
  4643. snd_soc_dapm_sync(dapm);
  4644. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4645. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4646. msm_codec_fn.get_afe_config_fn = tasha_get_afe_config;
  4647. ret = msm_adsp_power_up_config(component, rtd->card->snd_card);
  4648. if (ret) {
  4649. dev_err(component->dev, "%s: Failed to set AFE config %d\n",
  4650. __func__, ret);
  4651. goto err;
  4652. }
  4653. config_data = msm_codec_fn.get_afe_config_fn(component,
  4654. AFE_AANC_VERSION);
  4655. if (config_data) {
  4656. ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  4657. if (ret) {
  4658. dev_err(component->dev, "%s: Failed to set aanc version %d\n",
  4659. __func__, ret);
  4660. goto err;
  4661. }
  4662. }
  4663. card = rtd->card->snd_card;
  4664. if (!pdata->codec_root)
  4665. pdata->codec_root = snd_info_create_subdir(card->module,
  4666. "codecs", card->proc_root);
  4667. if (!pdata->codec_root) {
  4668. dev_dbg(codec->dev, "%s: Cannot create codecs module entry\n",
  4669. __func__);
  4670. ret = 0;
  4671. goto err;
  4672. }
  4673. tasha_codec_info_create_codec_entry(pdata->codec_root, component);
  4674. codec_reg_done = true;
  4675. return 0;
  4676. err:
  4677. return ret;
  4678. }
  4679. static int msm_va_cdc_dma_init(struct snd_soc_pcm_runtime *rtd)
  4680. {
  4681. int ret = 0;
  4682. struct snd_soc_component *component;
  4683. struct snd_soc_dapm_context *dapm;
  4684. struct snd_card *card;
  4685. struct msm_asoc_mach_data *pdata =
  4686. snd_soc_card_get_drvdata(rtd->card);
  4687. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4688. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  4689. if (!component) {
  4690. pr_err("%s: component is NULL\n", __func__);
  4691. return -EINVAL;
  4692. }
  4693. dapm = snd_soc_component_get_dapm(component);
  4694. ret = snd_soc_add_component_controls(component, msm_snd_va_controls,
  4695. ARRAY_SIZE(msm_snd_va_controls));
  4696. if (ret < 0) {
  4697. dev_err(component->dev, "%s: add_component_controls for va failed, err %d\n",
  4698. __func__, ret);
  4699. return ret;
  4700. }
  4701. snd_soc_dapm_new_controls(dapm, msm_va_dapm_widgets,
  4702. ARRAY_SIZE(msm_va_dapm_widgets));
  4703. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  4704. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  4705. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  4706. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  4707. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  4708. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  4709. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  4710. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  4711. snd_soc_dapm_sync(dapm);
  4712. card = rtd->card->snd_card;
  4713. if (!pdata->codec_root)
  4714. pdata->codec_root = snd_info_create_subdir(card->module,
  4715. "codecs", card->proc_root);
  4716. if (!pdata->codec_root) {
  4717. dev_dbg(codec->dev, "%s: Cannot create codecs module entry\n",
  4718. __func__);
  4719. ret = 0;
  4720. goto done;
  4721. }
  4722. bolero_info_create_codec_entry(pdata->codec_root, component);
  4723. done:
  4724. return ret;
  4725. }
  4726. static int msm_wsa_cdc_dma_init(struct snd_soc_pcm_runtime *rtd)
  4727. {
  4728. int ret = 0;
  4729. struct snd_soc_component *component = NULL;
  4730. struct snd_soc_dapm_context *dapm = NULL;
  4731. struct snd_soc_component *aux_comp = NULL;
  4732. struct snd_card *card = NULL;
  4733. struct msm_asoc_mach_data *pdata =
  4734. snd_soc_card_get_drvdata(rtd->card);
  4735. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  4736. if (!component) {
  4737. pr_err("%s: component is NULL\n", __func__);
  4738. return -EINVAL;
  4739. }
  4740. dapm = snd_soc_component_get_dapm(component);
  4741. ret = snd_soc_add_component_controls(component, msm_snd_wsa_controls,
  4742. ARRAY_SIZE(msm_snd_wsa_controls));
  4743. if (ret < 0) {
  4744. dev_err(component->dev, "%s: add_codec_controls for wsa failed, err %d\n",
  4745. __func__, ret);
  4746. return ret;
  4747. }
  4748. snd_soc_dapm_new_controls(dapm, msm_wsa_dapm_widgets,
  4749. ARRAY_SIZE(msm_wsa_dapm_widgets));
  4750. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  4751. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  4752. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  4753. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  4754. snd_soc_dapm_sync(dapm);
  4755. /*
  4756. * Send speaker configuration only for WSA8810.
  4757. * Default configuration is for WSA8815.
  4758. */
  4759. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  4760. __func__, rtd->card->num_aux_devs);
  4761. if (rtd->card->num_aux_devs &&
  4762. !list_empty(&rtd->card->component_dev_list)) {
  4763. aux_comp = list_first_entry(
  4764. &rtd->card->component_dev_list,
  4765. struct snd_soc_component,
  4766. card_aux_list);
  4767. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  4768. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  4769. wsa_macro_set_spkr_mode(component,
  4770. WSA_MACRO_SPKR_MODE_1);
  4771. wsa_macro_set_spkr_gain_offset(component,
  4772. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  4773. }
  4774. }
  4775. card = rtd->card->snd_card;
  4776. if (!pdata->codec_root)
  4777. pdata->codec_root = snd_info_create_subdir(card->module,
  4778. "codecs", card->proc_root);
  4779. if (!pdata->codec_root) {
  4780. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  4781. __func__);
  4782. ret = 0;
  4783. goto done;
  4784. }
  4785. bolero_info_create_codec_entry(pdata->codec_root, component);
  4786. done:
  4787. return ret;
  4788. }
  4789. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  4790. {
  4791. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4792. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161, 162};
  4793. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4794. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4795. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4796. }
  4797. static int msm_snd_hw_params(struct snd_pcm_substream *substream,
  4798. struct snd_pcm_hw_params *params)
  4799. {
  4800. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4801. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4802. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4803. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4804. int ret = 0;
  4805. u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  4806. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4807. u32 user_set_tx_ch = 0;
  4808. u32 rx_ch_count;
  4809. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4810. ret = snd_soc_dai_get_channel_map(codec_dai,
  4811. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4812. if (ret < 0) {
  4813. pr_err("%s: failed to get codec chan map, err:%d\n",
  4814. __func__, ret);
  4815. goto err;
  4816. }
  4817. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
  4818. pr_debug("%s: rx_5_ch=%d\n", __func__,
  4819. slim_rx_cfg[5].channels);
  4820. rx_ch_count = slim_rx_cfg[5].channels;
  4821. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_2_RX) {
  4822. pr_debug("%s: rx_2_ch=%d\n", __func__,
  4823. slim_rx_cfg[2].channels);
  4824. rx_ch_count = slim_rx_cfg[2].channels;
  4825. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
  4826. pr_debug("%s: rx_6_ch=%d\n", __func__,
  4827. slim_rx_cfg[6].channels);
  4828. rx_ch_count = slim_rx_cfg[6].channels;
  4829. } else {
  4830. pr_debug("%s: rx_0_ch=%d\n", __func__,
  4831. slim_rx_cfg[0].channels);
  4832. rx_ch_count = slim_rx_cfg[0].channels;
  4833. }
  4834. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4835. rx_ch_count, rx_ch);
  4836. if (ret < 0) {
  4837. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4838. __func__, ret);
  4839. goto err;
  4840. }
  4841. } else {
  4842. pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
  4843. codec_dai->name, codec_dai->id, user_set_tx_ch);
  4844. ret = snd_soc_dai_get_channel_map(codec_dai,
  4845. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4846. if (ret < 0) {
  4847. pr_err("%s: failed to get tx codec chan map, err:%d\n",
  4848. __func__, ret);
  4849. goto err;
  4850. }
  4851. /* For <codec>_tx1 case */
  4852. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
  4853. user_set_tx_ch = slim_tx_cfg[0].channels;
  4854. /* For <codec>_tx3 case */
  4855. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
  4856. user_set_tx_ch = slim_tx_cfg[1].channels;
  4857. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
  4858. user_set_tx_ch = msm_vi_feed_tx_ch;
  4859. else
  4860. user_set_tx_ch = tx_ch_cnt;
  4861. pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), BE id (%d)\n",
  4862. __func__, slim_tx_cfg[0].channels, user_set_tx_ch,
  4863. tx_ch_cnt, dai_link->id);
  4864. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4865. user_set_tx_ch, tx_ch, 0, 0);
  4866. if (ret < 0)
  4867. pr_err("%s: failed to set tx cpu chan map, err:%d\n",
  4868. __func__, ret);
  4869. }
  4870. err:
  4871. return ret;
  4872. }
  4873. static int msm_snd_auxpcm_startup(struct snd_pcm_substream *substream)
  4874. {
  4875. int ret = 0;
  4876. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4877. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4878. ret = qcs405_send_island_vad_config(dai_link->id);
  4879. if (ret) {
  4880. pr_err("%s: send island/vad cfg failed, err = %d\n",
  4881. __func__, ret);
  4882. }
  4883. return ret;
  4884. }
  4885. static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream)
  4886. {
  4887. int ret = 0;
  4888. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4889. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4890. ret = qcs405_send_island_vad_config(dai_link->id);
  4891. if (ret) {
  4892. pr_err("%s: send island/vad cfg failed, err = %d\n",
  4893. __func__, ret);
  4894. }
  4895. return ret;
  4896. }
  4897. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4898. struct snd_pcm_hw_params *params)
  4899. {
  4900. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4901. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4902. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4903. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4904. int ret = 0;
  4905. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4906. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4907. u32 user_set_tx_ch = 0;
  4908. u32 user_set_rx_ch = 0;
  4909. u32 ch_id;
  4910. ret = snd_soc_dai_get_channel_map(codec_dai,
  4911. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4912. &rx_ch_cdc_dma);
  4913. if (ret < 0) {
  4914. pr_err("%s: failed to get codec chan map, err:%d\n",
  4915. __func__, ret);
  4916. goto err;
  4917. }
  4918. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4919. switch (dai_link->id) {
  4920. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4921. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4922. {
  4923. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4924. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4925. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4926. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4927. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4928. user_set_rx_ch, &rx_ch_cdc_dma);
  4929. if (ret < 0) {
  4930. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4931. __func__, ret);
  4932. goto err;
  4933. }
  4934. }
  4935. break;
  4936. }
  4937. } else {
  4938. switch (dai_link->id) {
  4939. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4940. {
  4941. user_set_tx_ch = msm_vi_feed_tx_ch;
  4942. }
  4943. break;
  4944. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4945. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4946. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4947. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4948. {
  4949. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4950. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4951. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4952. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4953. }
  4954. break;
  4955. }
  4956. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4957. &tx_ch_cdc_dma, 0, 0);
  4958. if (ret < 0) {
  4959. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4960. __func__, ret);
  4961. goto err;
  4962. }
  4963. }
  4964. err:
  4965. return ret;
  4966. }
  4967. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4968. struct snd_pcm_hw_params *params)
  4969. {
  4970. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4971. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4972. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4973. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4974. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4975. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4976. int ret;
  4977. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4978. codec_dai->name, codec_dai->id);
  4979. ret = snd_soc_dai_get_channel_map(codec_dai,
  4980. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4981. if (ret) {
  4982. dev_err(rtd->dev,
  4983. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4984. __func__, ret);
  4985. goto err;
  4986. }
  4987. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4988. __func__, tx_ch_cnt, dai_link->id);
  4989. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4990. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4991. if (ret)
  4992. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4993. __func__, ret);
  4994. err:
  4995. return ret;
  4996. }
  4997. static int msm_get_port_id(int be_id)
  4998. {
  4999. int afe_port_id;
  5000. switch (be_id) {
  5001. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  5002. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  5003. break;
  5004. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  5005. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  5006. break;
  5007. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  5008. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  5009. break;
  5010. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  5011. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  5012. break;
  5013. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  5014. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  5015. break;
  5016. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  5017. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  5018. break;
  5019. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  5020. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  5021. break;
  5022. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  5023. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  5024. break;
  5025. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  5026. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  5027. break;
  5028. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  5029. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  5030. break;
  5031. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  5032. afe_port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  5033. break;
  5034. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  5035. afe_port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  5036. break;
  5037. default:
  5038. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  5039. afe_port_id = -EINVAL;
  5040. }
  5041. return afe_port_id;
  5042. }
  5043. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  5044. {
  5045. u32 bit_per_sample;
  5046. switch (bit_format) {
  5047. case SNDRV_PCM_FORMAT_S32_LE:
  5048. case SNDRV_PCM_FORMAT_S24_3LE:
  5049. case SNDRV_PCM_FORMAT_S24_LE:
  5050. bit_per_sample = 32;
  5051. break;
  5052. case SNDRV_PCM_FORMAT_S16_LE:
  5053. default:
  5054. bit_per_sample = 16;
  5055. break;
  5056. }
  5057. return bit_per_sample;
  5058. }
  5059. static void update_mi2s_clk_val(int dai_id, int stream)
  5060. {
  5061. u32 bit_per_sample;
  5062. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  5063. bit_per_sample =
  5064. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  5065. mi2s_clk[dai_id].clk_freq_in_hz =
  5066. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  5067. } else {
  5068. bit_per_sample =
  5069. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  5070. mi2s_clk[dai_id].clk_freq_in_hz =
  5071. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  5072. }
  5073. }
  5074. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  5075. {
  5076. int ret = 0;
  5077. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5078. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5079. int port_id = 0;
  5080. int index = cpu_dai->id;
  5081. port_id = msm_get_port_id(rtd->dai_link->id);
  5082. if (port_id < 0) {
  5083. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  5084. ret = port_id;
  5085. goto err;
  5086. }
  5087. if (enable) {
  5088. update_mi2s_clk_val(index, substream->stream);
  5089. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  5090. mi2s_clk[index].clk_freq_in_hz);
  5091. }
  5092. mi2s_clk[index].enable = enable;
  5093. ret = afe_set_lpass_clock_v2(port_id,
  5094. &mi2s_clk[index]);
  5095. if (ret < 0) {
  5096. dev_err(rtd->card->dev,
  5097. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  5098. __func__, port_id, ret);
  5099. goto err;
  5100. }
  5101. err:
  5102. return ret;
  5103. }
  5104. static int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  5105. struct snd_pcm_hw_params *params)
  5106. {
  5107. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5108. struct snd_interval *rate = hw_param_interval(params,
  5109. SNDRV_PCM_HW_PARAM_RATE);
  5110. struct snd_interval *channels = hw_param_interval(params,
  5111. SNDRV_PCM_HW_PARAM_CHANNELS);
  5112. if (cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_RX) {
  5113. channels->min = channels->max =
  5114. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  5115. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  5116. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  5117. rate->min = rate->max =
  5118. tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  5119. } else if (cpu_dai->id == AFE_PORT_ID_SECONDARY_TDM_RX) {
  5120. channels->min = channels->max =
  5121. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  5122. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  5123. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  5124. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  5125. } else if (cpu_dai->id == AFE_PORT_ID_QUINARY_TDM_RX) {
  5126. channels->min = channels->max =
  5127. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  5128. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  5129. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  5130. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  5131. } else {
  5132. pr_err("%s: dai id 0x%x not supported\n",
  5133. __func__, cpu_dai->id);
  5134. return -EINVAL;
  5135. }
  5136. pr_debug("%s: dai id = 0x%x channels = %d rate = %d format = 0x%x\n",
  5137. __func__, cpu_dai->id, channels->max, rate->max,
  5138. params_format(params));
  5139. return 0;
  5140. }
  5141. static int qcs405_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  5142. struct snd_pcm_hw_params *params)
  5143. {
  5144. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5145. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5146. int ret = 0;
  5147. int slot_width = 32;
  5148. int channels, slots = 8;
  5149. unsigned int slot_mask, rate, clk_freq;
  5150. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  5151. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  5152. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  5153. switch (cpu_dai->id) {
  5154. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5155. channels = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  5156. break;
  5157. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5158. channels = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  5159. break;
  5160. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5161. channels = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  5162. break;
  5163. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5164. channels = tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  5165. break;
  5166. case AFE_PORT_ID_QUINARY_TDM_RX:
  5167. channels = tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  5168. break;
  5169. case AFE_PORT_ID_PRIMARY_TDM_TX:
  5170. channels = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  5171. break;
  5172. case AFE_PORT_ID_SECONDARY_TDM_TX:
  5173. channels = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  5174. break;
  5175. case AFE_PORT_ID_TERTIARY_TDM_TX:
  5176. channels = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  5177. break;
  5178. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  5179. channels = tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  5180. break;
  5181. case AFE_PORT_ID_QUINARY_TDM_TX:
  5182. channels = tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  5183. break;
  5184. default:
  5185. pr_err("%s: dai id 0x%x not supported\n",
  5186. __func__, cpu_dai->id);
  5187. return -EINVAL;
  5188. }
  5189. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  5190. /*2 slot config - bits 0 and 1 set for the first two slots */
  5191. slot_mask = 0x0000FFFF >> (16-channels);
  5192. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  5193. __func__, slot_width, slots);
  5194. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  5195. slots, slot_width);
  5196. if (ret < 0) {
  5197. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  5198. __func__, ret);
  5199. goto end;
  5200. }
  5201. ret = snd_soc_dai_set_channel_map(cpu_dai,
  5202. 0, NULL, channels, slot_offset);
  5203. if (ret < 0) {
  5204. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  5205. __func__, ret);
  5206. goto end;
  5207. }
  5208. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  5209. /*2 slot config - bits 0 and 1 set for the first two slots */
  5210. slot_mask = 0x0000FFFF >> (16-channels);
  5211. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  5212. __func__, slot_width, slots);
  5213. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  5214. slots, slot_width);
  5215. if (ret < 0) {
  5216. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  5217. __func__, ret);
  5218. goto end;
  5219. }
  5220. ret = snd_soc_dai_set_channel_map(cpu_dai,
  5221. channels, slot_offset, 0, NULL);
  5222. if (ret < 0) {
  5223. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  5224. __func__, ret);
  5225. goto end;
  5226. }
  5227. } else {
  5228. ret = -EINVAL;
  5229. pr_err("%s: invalid use case, err:%d\n",
  5230. __func__, ret);
  5231. goto end;
  5232. }
  5233. rate = params_rate(params);
  5234. clk_freq = rate * slot_width * slots;
  5235. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  5236. if (ret < 0)
  5237. pr_err("%s: failed to set tdm clk, err:%d\n",
  5238. __func__, ret);
  5239. end:
  5240. return ret;
  5241. }
  5242. static int msm_get_tdm_mode(u32 port_id)
  5243. {
  5244. u32 tdm_mode;
  5245. switch (port_id) {
  5246. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5247. case AFE_PORT_ID_PRIMARY_TDM_TX:
  5248. tdm_mode = TDM_PRI;
  5249. break;
  5250. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5251. case AFE_PORT_ID_SECONDARY_TDM_TX:
  5252. tdm_mode = TDM_SEC;
  5253. break;
  5254. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5255. case AFE_PORT_ID_TERTIARY_TDM_TX:
  5256. tdm_mode = TDM_TERT;
  5257. break;
  5258. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5259. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  5260. tdm_mode = TDM_QUAT;
  5261. break;
  5262. case AFE_PORT_ID_QUINARY_TDM_RX:
  5263. case AFE_PORT_ID_QUINARY_TDM_TX:
  5264. tdm_mode = TDM_QUIN;
  5265. break;
  5266. default:
  5267. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  5268. tdm_mode = -EINVAL;
  5269. }
  5270. return tdm_mode;
  5271. }
  5272. static int qcs405_tdm_snd_startup(struct snd_pcm_substream *substream)
  5273. {
  5274. int ret = 0;
  5275. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5276. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5277. struct snd_soc_card *card = rtd->card;
  5278. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5279. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  5280. u32 tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  5281. if (tdm_mode >= TDM_INTERFACE_MAX) {
  5282. ret = -EINVAL;
  5283. pr_err("%s: Invalid TDM interface %d\n",
  5284. __func__, ret);
  5285. return ret;
  5286. }
  5287. if (pdata->mi2s_gpio_p[tdm_mode]) {
  5288. ret = msm_cdc_pinctrl_select_active_state(
  5289. pdata->mi2s_gpio_p[tdm_mode]);
  5290. if (ret)
  5291. pr_err("%s: TDM GPIO pinctrl set active failed with %d\n",
  5292. __func__, ret);
  5293. }
  5294. /* Enable Mic bias for TDM Mics */
  5295. if (cpu_dai->id == AFE_PORT_ID_QUINARY_TDM_TX) {
  5296. if (pdata->tdm_micb_supply) {
  5297. ret = regulator_set_voltage(pdata->tdm_micb_supply,
  5298. pdata->tdm_micb_voltage,
  5299. pdata->tdm_micb_voltage);
  5300. if (ret) {
  5301. pr_err("%s: Setting voltage failed, err = %d\n",
  5302. __func__, ret);
  5303. return ret;
  5304. }
  5305. ret = regulator_set_load(pdata->tdm_micb_supply,
  5306. pdata->tdm_micb_current);
  5307. if (ret) {
  5308. pr_err("%s: Setting current failed, err = %d\n",
  5309. __func__, ret);
  5310. return ret;
  5311. }
  5312. ret = regulator_enable(pdata->tdm_micb_supply);
  5313. if (ret) {
  5314. pr_err("%s: regulator enable failed, err = %d\n",
  5315. __func__, ret);
  5316. return ret;
  5317. }
  5318. }
  5319. }
  5320. ret = qcs405_send_island_vad_config(dai_link->id);
  5321. if (ret) {
  5322. pr_err("%s: send island/vad cfg failed, err = %d\n",
  5323. __func__, ret);
  5324. return ret;
  5325. }
  5326. return ret;
  5327. }
  5328. static void qcs405_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  5329. {
  5330. int ret = 0;
  5331. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5332. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5333. struct snd_soc_card *card = rtd->card;
  5334. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5335. u32 tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  5336. if (cpu_dai->id == AFE_PORT_ID_QUINARY_TDM_TX) {
  5337. if (pdata->tdm_micb_supply) {
  5338. ret = regulator_disable(pdata->tdm_micb_supply);
  5339. if (ret)
  5340. pr_err("%s: regulator disable failed, err = %d\n",
  5341. __func__, ret);
  5342. regulator_set_voltage(pdata->tdm_micb_supply, 0,
  5343. pdata->tdm_micb_voltage);
  5344. regulator_set_load(pdata->tdm_micb_supply, 0);
  5345. }
  5346. }
  5347. if (pdata->mi2s_gpio_p[tdm_mode]) {
  5348. ret = msm_cdc_pinctrl_select_sleep_state(
  5349. pdata->mi2s_gpio_p[tdm_mode]);
  5350. if (ret)
  5351. pr_err("%s: TDM GPIO pinctrl set sleep failed with %d\n",
  5352. __func__, ret);
  5353. }
  5354. }
  5355. static struct snd_soc_ops qcs405_tdm_be_ops = {
  5356. .hw_params = qcs405_tdm_snd_hw_params,
  5357. .startup = qcs405_tdm_snd_startup,
  5358. .shutdown = qcs405_tdm_snd_shutdown
  5359. };
  5360. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  5361. {
  5362. cpumask_t mask;
  5363. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  5364. pm_qos_remove_request(&substream->latency_pm_qos_req);
  5365. cpumask_clear(&mask);
  5366. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  5367. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  5368. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  5369. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  5370. pm_qos_add_request(&substream->latency_pm_qos_req,
  5371. PM_QOS_CPU_DMA_LATENCY,
  5372. MSM_LL_QOS_VALUE);
  5373. return 0;
  5374. }
  5375. static struct snd_soc_ops msm_fe_qos_ops = {
  5376. .prepare = msm_fe_qos_prepare,
  5377. };
  5378. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  5379. {
  5380. int ret = 0;
  5381. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5382. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5383. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  5384. int index = cpu_dai->id;
  5385. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  5386. struct snd_soc_card *card = rtd->card;
  5387. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5388. dev_dbg(rtd->card->dev,
  5389. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  5390. __func__, substream->name, substream->stream,
  5391. cpu_dai->name, cpu_dai->id);
  5392. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5393. ret = -EINVAL;
  5394. dev_err(rtd->card->dev,
  5395. "%s: CPU DAI id (%d) out of range\n",
  5396. __func__, cpu_dai->id);
  5397. goto err;
  5398. }
  5399. /*
  5400. * Mutex protection in case the same MI2S
  5401. * interface using for both TX and RX so
  5402. * that the same clock won't be enable twice.
  5403. */
  5404. mutex_lock(&mi2s_intf_conf[index].lock);
  5405. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  5406. /* Check if msm needs to provide the clock to the interface */
  5407. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  5408. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  5409. fmt = SND_SOC_DAIFMT_CBM_CFM;
  5410. }
  5411. ret = msm_mi2s_set_sclk(substream, true);
  5412. if (ret < 0) {
  5413. dev_err(rtd->card->dev,
  5414. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  5415. __func__, ret);
  5416. goto clean_up;
  5417. }
  5418. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  5419. if (ret < 0) {
  5420. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  5421. __func__, index, ret);
  5422. goto clk_off;
  5423. }
  5424. if (pdata->mi2s_gpio_p[index])
  5425. msm_cdc_pinctrl_select_active_state(
  5426. pdata->mi2s_gpio_p[index]);
  5427. }
  5428. ret = qcs405_send_island_vad_config(dai_link->id);
  5429. if (ret) {
  5430. pr_err("%s: send island/vad cfg failed, err = %d\n",
  5431. __func__, ret);
  5432. return ret;
  5433. }
  5434. clk_off:
  5435. if (ret < 0)
  5436. msm_mi2s_set_sclk(substream, false);
  5437. clean_up:
  5438. if (ret < 0)
  5439. mi2s_intf_conf[index].ref_cnt--;
  5440. mutex_unlock(&mi2s_intf_conf[index].lock);
  5441. err:
  5442. return ret;
  5443. }
  5444. static int msm_mi2s_snd_hw_free(struct snd_pcm_substream *substream)
  5445. {
  5446. int i, data_format = 0;
  5447. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5448. int index = rtd->cpu_dai->id;
  5449. struct snd_soc_card *card = rtd->card;
  5450. struct snd_soc_component *component;
  5451. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  5452. data_format = mi2s_rx_cfg[index].data_format;
  5453. else
  5454. data_format = mi2s_tx_cfg[index].data_format;
  5455. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5456. substream->name, substream->stream);
  5457. /* Call csra mute function if data format is DSD, else return */
  5458. if (data_format != AFE_DSD_DATA)
  5459. return 0;
  5460. for (i = 0; i < card->num_aux_devs; i++) {
  5461. component =
  5462. soc_find_component(card->aux_dev[i].codec_of_node,
  5463. NULL);
  5464. csra66x0_hw_free_mute(component);
  5465. }
  5466. return 0;
  5467. }
  5468. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  5469. {
  5470. int ret;
  5471. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5472. int index = rtd->cpu_dai->id;
  5473. struct snd_soc_card *card = rtd->card;
  5474. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5475. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5476. substream->name, substream->stream);
  5477. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5478. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  5479. return;
  5480. }
  5481. mutex_lock(&mi2s_intf_conf[index].lock);
  5482. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  5483. if (pdata->mi2s_gpio_p[index])
  5484. msm_cdc_pinctrl_select_sleep_state(
  5485. pdata->mi2s_gpio_p[index]);
  5486. ret = msm_mi2s_set_sclk(substream, false);
  5487. if (ret < 0)
  5488. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  5489. __func__, index, ret);
  5490. }
  5491. mutex_unlock(&mi2s_intf_conf[index].lock);
  5492. }
  5493. static int msm_meta_mi2s_set_sclk(struct snd_pcm_substream *substream,
  5494. int member_id, bool enable)
  5495. {
  5496. int ret = 0;
  5497. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5498. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5499. int be_id = 0;
  5500. int port_id = 0;
  5501. int index = cpu_dai->id;
  5502. u32 bit_per_sample = 0;
  5503. switch (member_id) {
  5504. case PRIM_MI2S:
  5505. be_id = MSM_BACKEND_DAI_PRI_MI2S_RX;
  5506. break;
  5507. case SEC_MI2S:
  5508. be_id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX;
  5509. break;
  5510. case TERT_MI2S:
  5511. be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX;
  5512. break;
  5513. case QUAT_MI2S:
  5514. be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX;
  5515. break;
  5516. default:
  5517. dev_err(rtd->card->dev, "%s: Invalid member_id\n", __func__);
  5518. ret = -EINVAL;
  5519. goto err;
  5520. }
  5521. port_id = msm_get_port_id(be_id);
  5522. if (port_id < 0) {
  5523. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  5524. ret = port_id;
  5525. goto err;
  5526. }
  5527. if (enable) {
  5528. bit_per_sample =
  5529. get_mi2s_bits_per_sample(
  5530. meta_mi2s_rx_cfg[index].bit_format);
  5531. mi2s_clk[member_id].clk_freq_in_hz =
  5532. meta_mi2s_rx_cfg[index].sample_rate * 2 *
  5533. bit_per_sample;
  5534. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  5535. mi2s_clk[member_id].clk_freq_in_hz);
  5536. }
  5537. mi2s_clk[member_id].enable = enable;
  5538. ret = afe_set_lpass_clock_v2(port_id, &mi2s_clk[member_id]);
  5539. if (ret < 0) {
  5540. dev_err(rtd->card->dev,
  5541. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  5542. __func__, port_id, ret);
  5543. goto err;
  5544. }
  5545. err:
  5546. return ret;
  5547. }
  5548. static int msm_meta_mi2s_snd_startup(struct snd_pcm_substream *substream)
  5549. {
  5550. int ret = 0;
  5551. int i = 0;
  5552. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5553. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5554. int index = cpu_dai->id;
  5555. int member_port = 0;
  5556. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  5557. struct snd_soc_card *card = rtd->card;
  5558. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5559. u16 port_id = 0;
  5560. dev_dbg(rtd->card->dev,
  5561. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  5562. __func__, substream->name, substream->stream,
  5563. cpu_dai->name, cpu_dai->id);
  5564. if (index < PRIM_META_MI2S || index >= META_MI2S_MAX) {
  5565. ret = -EINVAL;
  5566. dev_err(rtd->card->dev,
  5567. "%s: CPU DAI id (%d) out of range\n",
  5568. __func__, cpu_dai->id);
  5569. goto err;
  5570. }
  5571. for (i = 0; i < meta_mi2s_intf_conf[index].num_member_ports; i++) {
  5572. member_port = meta_mi2s_intf_conf[index].member_port[i];
  5573. if (!mi2s_intf_conf[member_port].msm_is_mi2s_master) {
  5574. mi2s_clk[member_port].clk_id =
  5575. mi2s_ebit_clk[member_port];
  5576. fmt = SND_SOC_DAIFMT_CBM_CFM;
  5577. }
  5578. ret = msm_meta_mi2s_set_sclk(substream, member_port, true);
  5579. if (ret < 0) {
  5580. dev_err(rtd->card->dev,
  5581. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  5582. __func__, ret);
  5583. goto clk_off;
  5584. }
  5585. meta_mi2s_intf_conf[index].clk_enable[i] = true;
  5586. if (i == 0) {
  5587. port_id = msm_get_port_id(rtd->dai_link->id);
  5588. ret = afe_set_clk_id(port_id,
  5589. mi2s_clk[member_port].clk_id);
  5590. if (ret < 0)
  5591. pr_err("%s: afe_set_clk_id fail %d\n",
  5592. __func__, ret);
  5593. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  5594. if (ret < 0) {
  5595. pr_err("%s: set fmt cpu dai failed for META_MI2S (%d), err:%d\n",
  5596. __func__, index, ret);
  5597. goto clk_off;
  5598. }
  5599. }
  5600. if (pdata->mi2s_gpio_p[member_port])
  5601. msm_cdc_pinctrl_select_active_state(
  5602. pdata->mi2s_gpio_p[member_port]);
  5603. }
  5604. return 0;
  5605. clk_off:
  5606. for (i = 0; i < meta_mi2s_intf_conf[index].num_member_ports; i++) {
  5607. member_port = meta_mi2s_intf_conf[index].member_port[i];
  5608. if (pdata->mi2s_gpio_p[member_port])
  5609. msm_cdc_pinctrl_select_sleep_state(
  5610. pdata->mi2s_gpio_p[member_port]);
  5611. if (meta_mi2s_intf_conf[index].clk_enable[i]) {
  5612. msm_meta_mi2s_set_sclk(substream, member_port, false);
  5613. meta_mi2s_intf_conf[index].clk_enable[i] = false;
  5614. }
  5615. }
  5616. err:
  5617. return ret;
  5618. }
  5619. static void msm_meta_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  5620. {
  5621. int ret = 0;
  5622. int i = 0;
  5623. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5624. int index = rtd->cpu_dai->id;
  5625. int member_port = 0;
  5626. struct snd_soc_card *card = rtd->card;
  5627. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5628. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5629. substream->name, substream->stream);
  5630. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5631. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  5632. return;
  5633. }
  5634. for (i = 0; i < meta_mi2s_intf_conf[index].num_member_ports; i++) {
  5635. member_port = meta_mi2s_intf_conf[index].member_port[i];
  5636. if (pdata->mi2s_gpio_p[member_port])
  5637. msm_cdc_pinctrl_select_sleep_state(
  5638. pdata->mi2s_gpio_p[member_port]);
  5639. ret = msm_meta_mi2s_set_sclk(substream, member_port, false);
  5640. if (ret < 0)
  5641. pr_err("%s:clock disable failed for META MI2S (%d); ret=%d\n",
  5642. __func__, index, ret);
  5643. }
  5644. }
  5645. static int msm_spdif_set_clk(struct snd_pcm_substream *substream, bool enable)
  5646. {
  5647. int ret = 0;
  5648. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5649. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5650. int port_id = cpu_dai->id;
  5651. struct afe_clk_set clk_cfg;
  5652. clk_cfg.clk_set_minor_version = Q6AFE_LPASS_CLK_CONFIG_API_VERSION;
  5653. clk_cfg.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO;
  5654. clk_cfg.clk_root = Q6AFE_LPASS_CLK_ROOT_DEFAULT;
  5655. clk_cfg.enable = enable;
  5656. /* Set core clock (based on sample rate for RX, fixed for TX) */
  5657. switch (port_id) {
  5658. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  5659. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_PRI_SPDIF_OUTPUT_CORE;
  5660. /* rate x 2ch x 2_for_biphase_coding x 32_bits_per_sample */
  5661. clk_cfg.clk_freq_in_hz =
  5662. spdif_rx_cfg[PRIM_SPDIF_RX].sample_rate * 2 * 2 * 32;
  5663. break;
  5664. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  5665. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_SEC_SPDIF_OUTPUT_CORE;
  5666. clk_cfg.clk_freq_in_hz =
  5667. spdif_rx_cfg[SEC_SPDIF_RX].sample_rate * 2 * 2 * 32;
  5668. break;
  5669. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  5670. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_PRI_SPDIF_INPUT_CORE;
  5671. clk_cfg.clk_freq_in_hz = SPDIF_TX_CORE_CLK_163_P84_MHZ;
  5672. break;
  5673. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  5674. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_SEC_SPDIF_INPUT_CORE;
  5675. clk_cfg.clk_freq_in_hz = SPDIF_TX_CORE_CLK_163_P84_MHZ;
  5676. break;
  5677. }
  5678. ret = afe_set_lpass_clock_v2(port_id, &clk_cfg);
  5679. if (ret < 0) {
  5680. dev_err(rtd->card->dev,
  5681. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  5682. __func__, port_id, ret);
  5683. goto err;
  5684. }
  5685. /* Set NPL clock for RX in addition */
  5686. switch (port_id) {
  5687. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  5688. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_PRI_SPDIF_OUTPUT_NPL;
  5689. ret = afe_set_lpass_clock_v2(port_id, &clk_cfg);
  5690. if (ret < 0) {
  5691. dev_err(rtd->card->dev,
  5692. "%s: afe NPL failed port 0x%x, err:%d\n",
  5693. __func__, port_id, ret);
  5694. goto err;
  5695. }
  5696. break;
  5697. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  5698. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_SEC_SPDIF_OUTPUT_NPL;
  5699. ret = afe_set_lpass_clock_v2(port_id, &clk_cfg);
  5700. if (ret < 0) {
  5701. dev_err(rtd->card->dev,
  5702. "%s: afe NPL failed for port 0x%x, err:%d\n",
  5703. __func__, port_id, ret);
  5704. goto err;
  5705. }
  5706. break;
  5707. }
  5708. if (enable) {
  5709. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  5710. clk_cfg.clk_freq_in_hz);
  5711. }
  5712. err:
  5713. return ret;
  5714. }
  5715. static int msm_spdif_snd_startup(struct snd_pcm_substream *substream)
  5716. {
  5717. int ret = 0;
  5718. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5719. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5720. int port_id = cpu_dai->id;
  5721. dev_dbg(rtd->card->dev,
  5722. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  5723. __func__, substream->name, substream->stream,
  5724. cpu_dai->name, cpu_dai->id);
  5725. if (port_id < AFE_PORT_ID_PRIMARY_SPDIF_RX ||
  5726. port_id > AFE_PORT_ID_SECONDARY_SPDIF_TX) {
  5727. ret = -EINVAL;
  5728. dev_err(rtd->card->dev,
  5729. "%s: CPU DAI id (%d) out of range\n",
  5730. __func__, cpu_dai->id);
  5731. goto err;
  5732. }
  5733. ret = msm_spdif_set_clk(substream, true);
  5734. if (ret < 0) {
  5735. dev_err(rtd->card->dev,
  5736. "%s: afe lpass clock failed to enable (%d), err:%d\n",
  5737. __func__, port_id, ret);
  5738. }
  5739. err:
  5740. return ret;
  5741. }
  5742. static void msm_spdif_snd_shutdown(struct snd_pcm_substream *substream)
  5743. {
  5744. int ret;
  5745. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5746. int port_id = rtd->cpu_dai->id;
  5747. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5748. substream->name, substream->stream);
  5749. if (port_id < AFE_PORT_ID_PRIMARY_SPDIF_RX ||
  5750. port_id > AFE_PORT_ID_SECONDARY_SPDIF_TX) {
  5751. pr_err("%s:invalid SPDIF DAI(%d)\n", __func__, port_id);
  5752. return;
  5753. }
  5754. ret = msm_spdif_set_clk(substream, false);
  5755. if (ret < 0)
  5756. pr_err("%s:clock disable failed for SPDIF (%d); ret=%d\n",
  5757. __func__, port_id, ret);
  5758. }
  5759. static struct snd_soc_ops msm_mi2s_be_ops = {
  5760. .startup = msm_mi2s_snd_startup,
  5761. .hw_free = msm_mi2s_snd_hw_free,
  5762. .shutdown = msm_mi2s_snd_shutdown,
  5763. };
  5764. static struct snd_soc_ops msm_meta_mi2s_be_ops = {
  5765. .startup = msm_meta_mi2s_snd_startup,
  5766. .shutdown = msm_meta_mi2s_snd_shutdown,
  5767. };
  5768. static struct snd_soc_ops msm_auxpcm_be_ops = {
  5769. .startup = msm_snd_auxpcm_startup,
  5770. };
  5771. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  5772. .startup = msm_snd_cdc_dma_startup,
  5773. .hw_params = msm_snd_cdc_dma_hw_params,
  5774. };
  5775. static struct snd_soc_ops msm_be_ops = {
  5776. .hw_params = msm_snd_hw_params,
  5777. };
  5778. static struct snd_soc_ops msm_wcn_ops = {
  5779. .hw_params = msm_wcn_hw_params,
  5780. };
  5781. static struct snd_soc_ops msm_spdif_be_ops = {
  5782. .startup = msm_spdif_snd_startup,
  5783. .shutdown = msm_spdif_snd_shutdown,
  5784. };
  5785. /* Digital audio interface glue - connects codec <---> CPU */
  5786. static struct snd_soc_dai_link msm_common_dai_links[] = {
  5787. /* FrontEnd DAI Links */
  5788. {
  5789. .name = MSM_DAILINK_NAME(Media1),
  5790. .stream_name = "MultiMedia1",
  5791. .cpu_dai_name = "MultiMedia1",
  5792. .platform_name = "msm-pcm-dsp.0",
  5793. .dynamic = 1,
  5794. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5795. .dpcm_playback = 1,
  5796. .dpcm_capture = 1,
  5797. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5798. SND_SOC_DPCM_TRIGGER_POST},
  5799. .codec_dai_name = "snd-soc-dummy-dai",
  5800. .codec_name = "snd-soc-dummy",
  5801. .ignore_suspend = 1,
  5802. /* this dainlink has playback support */
  5803. .ignore_pmdown_time = 1,
  5804. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  5805. },
  5806. {
  5807. .name = MSM_DAILINK_NAME(Media2),
  5808. .stream_name = "MultiMedia2",
  5809. .cpu_dai_name = "MultiMedia2",
  5810. .platform_name = "msm-pcm-dsp.0",
  5811. .dynamic = 1,
  5812. .dpcm_playback = 1,
  5813. .dpcm_capture = 1,
  5814. .codec_dai_name = "snd-soc-dummy-dai",
  5815. .codec_name = "snd-soc-dummy",
  5816. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5817. SND_SOC_DPCM_TRIGGER_POST},
  5818. .ignore_suspend = 1,
  5819. /* this dainlink has playback support */
  5820. .ignore_pmdown_time = 1,
  5821. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  5822. },
  5823. {
  5824. .name = "VoiceMMode1",
  5825. .stream_name = "VoiceMMode1",
  5826. .cpu_dai_name = "VoiceMMode1",
  5827. .platform_name = "msm-pcm-voice",
  5828. .dynamic = 1,
  5829. .dpcm_playback = 1,
  5830. .dpcm_capture = 1,
  5831. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5832. SND_SOC_DPCM_TRIGGER_POST},
  5833. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5834. .ignore_suspend = 1,
  5835. .ignore_pmdown_time = 1,
  5836. .codec_dai_name = "snd-soc-dummy-dai",
  5837. .codec_name = "snd-soc-dummy",
  5838. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  5839. },
  5840. {
  5841. .name = "MSM VoIP",
  5842. .stream_name = "VoIP",
  5843. .cpu_dai_name = "VoIP",
  5844. .platform_name = "msm-voip-dsp",
  5845. .dynamic = 1,
  5846. .dpcm_playback = 1,
  5847. .dpcm_capture = 1,
  5848. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5849. SND_SOC_DPCM_TRIGGER_POST},
  5850. .codec_dai_name = "snd-soc-dummy-dai",
  5851. .codec_name = "snd-soc-dummy",
  5852. .ignore_suspend = 1,
  5853. /* this dainlink has playback support */
  5854. .ignore_pmdown_time = 1,
  5855. .id = MSM_FRONTEND_DAI_VOIP,
  5856. },
  5857. {
  5858. .name = MSM_DAILINK_NAME(ULL),
  5859. .stream_name = "MultiMedia3",
  5860. .cpu_dai_name = "MultiMedia3",
  5861. .platform_name = "msm-pcm-dsp.2",
  5862. .dynamic = 1,
  5863. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5864. .dpcm_playback = 1,
  5865. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5866. SND_SOC_DPCM_TRIGGER_POST},
  5867. .codec_dai_name = "snd-soc-dummy-dai",
  5868. .codec_name = "snd-soc-dummy",
  5869. .ignore_suspend = 1,
  5870. /* this dainlink has playback support */
  5871. .ignore_pmdown_time = 1,
  5872. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  5873. },
  5874. /* Hostless PCM purpose */
  5875. {
  5876. .name = "SLIMBUS_0 Hostless",
  5877. .stream_name = "SLIMBUS_0 Hostless",
  5878. .cpu_dai_name = "SLIMBUS0_HOSTLESS",
  5879. .platform_name = "msm-pcm-hostless",
  5880. .dynamic = 1,
  5881. .dpcm_playback = 1,
  5882. .dpcm_capture = 1,
  5883. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5884. SND_SOC_DPCM_TRIGGER_POST},
  5885. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5886. .ignore_suspend = 1,
  5887. /* this dailink has playback support */
  5888. .ignore_pmdown_time = 1,
  5889. .codec_dai_name = "snd-soc-dummy-dai",
  5890. .codec_name = "snd-soc-dummy",
  5891. },
  5892. {
  5893. .name = "MSM AFE-PCM RX",
  5894. .stream_name = "AFE-PROXY RX",
  5895. .cpu_dai_name = "msm-dai-q6-dev.241",
  5896. .codec_name = "msm-stub-codec.1",
  5897. .codec_dai_name = "msm-stub-rx",
  5898. .platform_name = "msm-pcm-afe",
  5899. .dpcm_playback = 1,
  5900. .ignore_suspend = 1,
  5901. /* this dainlink has playback support */
  5902. .ignore_pmdown_time = 1,
  5903. },
  5904. {
  5905. .name = "MSM AFE-PCM TX",
  5906. .stream_name = "AFE-PROXY TX",
  5907. .cpu_dai_name = "msm-dai-q6-dev.240",
  5908. .codec_name = "msm-stub-codec.1",
  5909. .codec_dai_name = "msm-stub-tx",
  5910. .platform_name = "msm-pcm-afe",
  5911. .dpcm_capture = 1,
  5912. .ignore_suspend = 1,
  5913. },
  5914. {
  5915. .name = MSM_DAILINK_NAME(Compress1),
  5916. .stream_name = "Compress1",
  5917. .cpu_dai_name = "MultiMedia4",
  5918. .platform_name = "msm-compress-dsp",
  5919. .dynamic = 1,
  5920. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  5921. .dpcm_playback = 1,
  5922. .dpcm_capture = 1,
  5923. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5924. SND_SOC_DPCM_TRIGGER_POST},
  5925. .codec_dai_name = "snd-soc-dummy-dai",
  5926. .codec_name = "snd-soc-dummy",
  5927. .ignore_suspend = 1,
  5928. .ignore_pmdown_time = 1,
  5929. /* this dainlink has playback support */
  5930. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  5931. },
  5932. {
  5933. .name = "AUXPCM Hostless",
  5934. .stream_name = "AUXPCM Hostless",
  5935. .cpu_dai_name = "AUXPCM_HOSTLESS",
  5936. .platform_name = "msm-pcm-hostless",
  5937. .dynamic = 1,
  5938. .dpcm_playback = 1,
  5939. .dpcm_capture = 1,
  5940. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5941. SND_SOC_DPCM_TRIGGER_POST},
  5942. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5943. .ignore_suspend = 1,
  5944. /* this dainlink has playback support */
  5945. .ignore_pmdown_time = 1,
  5946. .codec_dai_name = "snd-soc-dummy-dai",
  5947. .codec_name = "snd-soc-dummy",
  5948. },
  5949. {
  5950. .name = "SLIMBUS_1 Hostless",
  5951. .stream_name = "SLIMBUS_1 Hostless",
  5952. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  5953. .platform_name = "msm-pcm-hostless",
  5954. .dynamic = 1,
  5955. .dpcm_playback = 1,
  5956. .dpcm_capture = 1,
  5957. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5958. SND_SOC_DPCM_TRIGGER_POST},
  5959. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5960. .ignore_suspend = 1,
  5961. /* this dailink has playback support */
  5962. .ignore_pmdown_time = 1,
  5963. .codec_dai_name = "snd-soc-dummy-dai",
  5964. .codec_name = "snd-soc-dummy",
  5965. },
  5966. {
  5967. .name = "SLIMBUS_3 Hostless",
  5968. .stream_name = "SLIMBUS_3 Hostless",
  5969. .cpu_dai_name = "SLIMBUS3_HOSTLESS",
  5970. .platform_name = "msm-pcm-hostless",
  5971. .dynamic = 1,
  5972. .dpcm_playback = 1,
  5973. .dpcm_capture = 1,
  5974. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5975. SND_SOC_DPCM_TRIGGER_POST},
  5976. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5977. .ignore_suspend = 1,
  5978. /* this dailink has playback support */
  5979. .ignore_pmdown_time = 1,
  5980. .codec_dai_name = "snd-soc-dummy-dai",
  5981. .codec_name = "snd-soc-dummy",
  5982. },
  5983. {
  5984. .name = "SLIMBUS_4 Hostless",
  5985. .stream_name = "SLIMBUS_4 Hostless",
  5986. .cpu_dai_name = "SLIMBUS4_HOSTLESS",
  5987. .platform_name = "msm-pcm-hostless",
  5988. .dynamic = 1,
  5989. .dpcm_playback = 1,
  5990. .dpcm_capture = 1,
  5991. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5992. SND_SOC_DPCM_TRIGGER_POST},
  5993. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5994. .ignore_suspend = 1,
  5995. /* this dailink has playback support */
  5996. .ignore_pmdown_time = 1,
  5997. .codec_dai_name = "snd-soc-dummy-dai",
  5998. .codec_name = "snd-soc-dummy",
  5999. },
  6000. {
  6001. .name = MSM_DAILINK_NAME(LowLatency),
  6002. .stream_name = "MultiMedia5",
  6003. .cpu_dai_name = "MultiMedia5",
  6004. .platform_name = "msm-pcm-dsp.1",
  6005. .dynamic = 1,
  6006. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6007. .dpcm_playback = 1,
  6008. .dpcm_capture = 1,
  6009. .codec_dai_name = "snd-soc-dummy-dai",
  6010. .codec_name = "snd-soc-dummy",
  6011. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6012. SND_SOC_DPCM_TRIGGER_POST},
  6013. .ignore_suspend = 1,
  6014. /* this dainlink has playback support */
  6015. .ignore_pmdown_time = 1,
  6016. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  6017. .ops = &msm_fe_qos_ops,
  6018. },
  6019. {
  6020. .name = "Listen 1 Audio Service",
  6021. .stream_name = "Listen 1 Audio Service",
  6022. .cpu_dai_name = "LSM1",
  6023. .platform_name = "msm-lsm-client",
  6024. .dynamic = 1,
  6025. .dpcm_capture = 1,
  6026. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6027. SND_SOC_DPCM_TRIGGER_POST },
  6028. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6029. .ignore_suspend = 1,
  6030. .codec_dai_name = "snd-soc-dummy-dai",
  6031. .codec_name = "snd-soc-dummy",
  6032. .id = MSM_FRONTEND_DAI_LSM1,
  6033. },
  6034. /* Multiple Tunnel instances */
  6035. {
  6036. .name = MSM_DAILINK_NAME(Compress2),
  6037. .stream_name = "Compress2",
  6038. .cpu_dai_name = "MultiMedia7",
  6039. .platform_name = "msm-compress-dsp",
  6040. .dynamic = 1,
  6041. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6042. .dpcm_playback = 1,
  6043. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6044. SND_SOC_DPCM_TRIGGER_POST},
  6045. .codec_dai_name = "snd-soc-dummy-dai",
  6046. .codec_name = "snd-soc-dummy",
  6047. .ignore_suspend = 1,
  6048. .ignore_pmdown_time = 1,
  6049. /* this dainlink has playback support */
  6050. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  6051. },
  6052. {
  6053. .name = MSM_DAILINK_NAME(MultiMedia10),
  6054. .stream_name = "MultiMedia10",
  6055. .cpu_dai_name = "MultiMedia10",
  6056. .platform_name = "msm-pcm-dsp.1",
  6057. .dynamic = 1,
  6058. .dpcm_playback = 1,
  6059. .dpcm_capture = 1,
  6060. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6061. SND_SOC_DPCM_TRIGGER_POST},
  6062. .codec_dai_name = "snd-soc-dummy-dai",
  6063. .codec_name = "snd-soc-dummy",
  6064. .ignore_suspend = 1,
  6065. .ignore_pmdown_time = 1,
  6066. /* this dainlink has playback support */
  6067. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  6068. },
  6069. {
  6070. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  6071. .stream_name = "MM_NOIRQ",
  6072. .cpu_dai_name = "MultiMedia8",
  6073. .platform_name = "msm-pcm-dsp-noirq",
  6074. .dynamic = 1,
  6075. .dpcm_playback = 1,
  6076. .dpcm_capture = 1,
  6077. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6078. SND_SOC_DPCM_TRIGGER_POST},
  6079. .codec_dai_name = "snd-soc-dummy-dai",
  6080. .codec_name = "snd-soc-dummy",
  6081. .ignore_suspend = 1,
  6082. .ignore_pmdown_time = 1,
  6083. /* this dainlink has playback support */
  6084. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  6085. .ops = &msm_fe_qos_ops,
  6086. },
  6087. /* HDMI Hostless */
  6088. {
  6089. .name = "HDMI_RX_HOSTLESS",
  6090. .stream_name = "HDMI_RX_HOSTLESS",
  6091. .cpu_dai_name = "HDMI_HOSTLESS",
  6092. .platform_name = "msm-pcm-hostless",
  6093. .dynamic = 1,
  6094. .dpcm_playback = 1,
  6095. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6096. SND_SOC_DPCM_TRIGGER_POST},
  6097. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6098. .ignore_suspend = 1,
  6099. .ignore_pmdown_time = 1,
  6100. .codec_dai_name = "snd-soc-dummy-dai",
  6101. .codec_name = "snd-soc-dummy",
  6102. },
  6103. {
  6104. .name = "VoiceMMode2",
  6105. .stream_name = "VoiceMMode2",
  6106. .cpu_dai_name = "VoiceMMode2",
  6107. .platform_name = "msm-pcm-voice",
  6108. .dynamic = 1,
  6109. .dpcm_playback = 1,
  6110. .dpcm_capture = 1,
  6111. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6112. SND_SOC_DPCM_TRIGGER_POST},
  6113. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6114. .ignore_suspend = 1,
  6115. .ignore_pmdown_time = 1,
  6116. .codec_dai_name = "snd-soc-dummy-dai",
  6117. .codec_name = "snd-soc-dummy",
  6118. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  6119. },
  6120. /* LSM FE */
  6121. {
  6122. .name = "Listen 2 Audio Service",
  6123. .stream_name = "Listen 2 Audio Service",
  6124. .cpu_dai_name = "LSM2",
  6125. .platform_name = "msm-lsm-client",
  6126. .dynamic = 1,
  6127. .dpcm_capture = 1,
  6128. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6129. SND_SOC_DPCM_TRIGGER_POST },
  6130. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6131. .ignore_suspend = 1,
  6132. .codec_dai_name = "snd-soc-dummy-dai",
  6133. .codec_name = "snd-soc-dummy",
  6134. .id = MSM_FRONTEND_DAI_LSM2,
  6135. },
  6136. {
  6137. .name = "Listen 3 Audio Service",
  6138. .stream_name = "Listen 3 Audio Service",
  6139. .cpu_dai_name = "LSM3",
  6140. .platform_name = "msm-lsm-client",
  6141. .dynamic = 1,
  6142. .dpcm_capture = 1,
  6143. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6144. SND_SOC_DPCM_TRIGGER_POST },
  6145. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6146. .ignore_suspend = 1,
  6147. .codec_dai_name = "snd-soc-dummy-dai",
  6148. .codec_name = "snd-soc-dummy",
  6149. .id = MSM_FRONTEND_DAI_LSM3,
  6150. },
  6151. {
  6152. .name = "Listen 4 Audio Service",
  6153. .stream_name = "Listen 4 Audio Service",
  6154. .cpu_dai_name = "LSM4",
  6155. .platform_name = "msm-lsm-client",
  6156. .dynamic = 1,
  6157. .dpcm_capture = 1,
  6158. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6159. SND_SOC_DPCM_TRIGGER_POST },
  6160. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6161. .ignore_suspend = 1,
  6162. .codec_dai_name = "snd-soc-dummy-dai",
  6163. .codec_name = "snd-soc-dummy",
  6164. .id = MSM_FRONTEND_DAI_LSM4,
  6165. },
  6166. {
  6167. .name = "Listen 5 Audio Service",
  6168. .stream_name = "Listen 5 Audio Service",
  6169. .cpu_dai_name = "LSM5",
  6170. .platform_name = "msm-lsm-client",
  6171. .dynamic = 1,
  6172. .dpcm_capture = 1,
  6173. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6174. SND_SOC_DPCM_TRIGGER_POST },
  6175. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6176. .ignore_suspend = 1,
  6177. .codec_dai_name = "snd-soc-dummy-dai",
  6178. .codec_name = "snd-soc-dummy",
  6179. .id = MSM_FRONTEND_DAI_LSM5,
  6180. },
  6181. {
  6182. .name = "Listen 6 Audio Service",
  6183. .stream_name = "Listen 6 Audio Service",
  6184. .cpu_dai_name = "LSM6",
  6185. .platform_name = "msm-lsm-client",
  6186. .dynamic = 1,
  6187. .dpcm_capture = 1,
  6188. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6189. SND_SOC_DPCM_TRIGGER_POST },
  6190. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6191. .ignore_suspend = 1,
  6192. .codec_dai_name = "snd-soc-dummy-dai",
  6193. .codec_name = "snd-soc-dummy",
  6194. .id = MSM_FRONTEND_DAI_LSM6,
  6195. },
  6196. {
  6197. .name = "Listen 7 Audio Service",
  6198. .stream_name = "Listen 7 Audio Service",
  6199. .cpu_dai_name = "LSM7",
  6200. .platform_name = "msm-lsm-client",
  6201. .dynamic = 1,
  6202. .dpcm_capture = 1,
  6203. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6204. SND_SOC_DPCM_TRIGGER_POST },
  6205. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6206. .ignore_suspend = 1,
  6207. .codec_dai_name = "snd-soc-dummy-dai",
  6208. .codec_name = "snd-soc-dummy",
  6209. .id = MSM_FRONTEND_DAI_LSM7,
  6210. },
  6211. {
  6212. .name = "Listen 8 Audio Service",
  6213. .stream_name = "Listen 8 Audio Service",
  6214. .cpu_dai_name = "LSM8",
  6215. .platform_name = "msm-lsm-client",
  6216. .dynamic = 1,
  6217. .dpcm_capture = 1,
  6218. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6219. SND_SOC_DPCM_TRIGGER_POST },
  6220. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6221. .ignore_suspend = 1,
  6222. .codec_dai_name = "snd-soc-dummy-dai",
  6223. .codec_name = "snd-soc-dummy",
  6224. .id = MSM_FRONTEND_DAI_LSM8,
  6225. },
  6226. {
  6227. .name = MSM_DAILINK_NAME(Media9),
  6228. .stream_name = "MultiMedia9",
  6229. .cpu_dai_name = "MultiMedia9",
  6230. .platform_name = "msm-pcm-dsp.0",
  6231. .dynamic = 1,
  6232. .dpcm_playback = 1,
  6233. .dpcm_capture = 1,
  6234. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6235. SND_SOC_DPCM_TRIGGER_POST},
  6236. .codec_dai_name = "snd-soc-dummy-dai",
  6237. .codec_name = "snd-soc-dummy",
  6238. .ignore_suspend = 1,
  6239. /* this dainlink has playback support */
  6240. .ignore_pmdown_time = 1,
  6241. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  6242. },
  6243. {
  6244. .name = MSM_DAILINK_NAME(Compress4),
  6245. .stream_name = "Compress4",
  6246. .cpu_dai_name = "MultiMedia11",
  6247. .platform_name = "msm-compress-dsp",
  6248. .dynamic = 1,
  6249. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6250. .dpcm_playback = 1,
  6251. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6252. SND_SOC_DPCM_TRIGGER_POST},
  6253. .codec_dai_name = "snd-soc-dummy-dai",
  6254. .codec_name = "snd-soc-dummy",
  6255. .ignore_suspend = 1,
  6256. .ignore_pmdown_time = 1,
  6257. /* this dainlink has playback support */
  6258. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  6259. },
  6260. {
  6261. .name = MSM_DAILINK_NAME(Compress5),
  6262. .stream_name = "Compress5",
  6263. .cpu_dai_name = "MultiMedia12",
  6264. .platform_name = "msm-compress-dsp",
  6265. .dynamic = 1,
  6266. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6267. .dpcm_playback = 1,
  6268. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6269. SND_SOC_DPCM_TRIGGER_POST},
  6270. .codec_dai_name = "snd-soc-dummy-dai",
  6271. .codec_name = "snd-soc-dummy",
  6272. .ignore_suspend = 1,
  6273. .ignore_pmdown_time = 1,
  6274. /* this dainlink has playback support */
  6275. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  6276. },
  6277. {
  6278. .name = MSM_DAILINK_NAME(Compress6),
  6279. .stream_name = "Compress6",
  6280. .cpu_dai_name = "MultiMedia13",
  6281. .platform_name = "msm-compress-dsp",
  6282. .dynamic = 1,
  6283. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6284. .dpcm_playback = 1,
  6285. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6286. SND_SOC_DPCM_TRIGGER_POST},
  6287. .codec_dai_name = "snd-soc-dummy-dai",
  6288. .codec_name = "snd-soc-dummy",
  6289. .ignore_suspend = 1,
  6290. .ignore_pmdown_time = 1,
  6291. /* this dainlink has playback support */
  6292. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  6293. },
  6294. {
  6295. .name = MSM_DAILINK_NAME(Compress7),
  6296. .stream_name = "Compress7",
  6297. .cpu_dai_name = "MultiMedia14",
  6298. .platform_name = "msm-compress-dsp",
  6299. .dynamic = 1,
  6300. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6301. .dpcm_playback = 1,
  6302. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6303. SND_SOC_DPCM_TRIGGER_POST},
  6304. .codec_dai_name = "snd-soc-dummy-dai",
  6305. .codec_name = "snd-soc-dummy",
  6306. .ignore_suspend = 1,
  6307. .ignore_pmdown_time = 1,
  6308. /* this dainlink has playback support */
  6309. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  6310. },
  6311. {
  6312. .name = MSM_DAILINK_NAME(Compress8),
  6313. .stream_name = "Compress8",
  6314. .cpu_dai_name = "MultiMedia15",
  6315. .platform_name = "msm-compress-dsp",
  6316. .dynamic = 1,
  6317. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6318. .dpcm_playback = 1,
  6319. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6320. SND_SOC_DPCM_TRIGGER_POST},
  6321. .codec_dai_name = "snd-soc-dummy-dai",
  6322. .codec_name = "snd-soc-dummy",
  6323. .ignore_suspend = 1,
  6324. .ignore_pmdown_time = 1,
  6325. /* this dainlink has playback support */
  6326. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  6327. },
  6328. {
  6329. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  6330. .stream_name = "MM_NOIRQ_2",
  6331. .cpu_dai_name = "MultiMedia16",
  6332. .platform_name = "msm-pcm-dsp-noirq",
  6333. .dynamic = 1,
  6334. .dpcm_playback = 1,
  6335. .dpcm_capture = 1,
  6336. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6337. SND_SOC_DPCM_TRIGGER_POST},
  6338. .codec_dai_name = "snd-soc-dummy-dai",
  6339. .codec_name = "snd-soc-dummy",
  6340. .ignore_suspend = 1,
  6341. .ignore_pmdown_time = 1,
  6342. /* this dainlink has playback support */
  6343. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  6344. },
  6345. {
  6346. .name = "SLIMBUS_8 Hostless",
  6347. .stream_name = "SLIMBUS8_HOSTLESS Capture",
  6348. .cpu_dai_name = "SLIMBUS8_HOSTLESS",
  6349. .platform_name = "msm-pcm-hostless",
  6350. .dynamic = 1,
  6351. .dpcm_capture = 1,
  6352. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6353. SND_SOC_DPCM_TRIGGER_POST},
  6354. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6355. .ignore_suspend = 1,
  6356. .codec_dai_name = "snd-soc-dummy-dai",
  6357. .codec_name = "snd-soc-dummy",
  6358. },
  6359. /* Hostless PCM purpose */
  6360. {
  6361. .name = "CDC_DMA Hostless",
  6362. .stream_name = "CDC_DMA Hostless",
  6363. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  6364. .platform_name = "msm-pcm-hostless",
  6365. .dynamic = 1,
  6366. .dpcm_playback = 1,
  6367. .dpcm_capture = 1,
  6368. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6369. SND_SOC_DPCM_TRIGGER_POST},
  6370. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6371. .ignore_suspend = 1,
  6372. /* this dailink has playback support */
  6373. .ignore_pmdown_time = 1,
  6374. .codec_dai_name = "snd-soc-dummy-dai",
  6375. .codec_name = "snd-soc-dummy",
  6376. },
  6377. };
  6378. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  6379. {
  6380. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  6381. .stream_name = "WSA CDC DMA0 Capture",
  6382. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  6383. .platform_name = "msm-pcm-hostless",
  6384. .codec_name = "bolero_codec",
  6385. .codec_dai_name = "wsa_macro_vifeedback",
  6386. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  6387. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6388. .ignore_suspend = 1,
  6389. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6390. .ops = &msm_cdc_dma_be_ops,
  6391. },
  6392. };
  6393. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  6394. {
  6395. .name = MSM_DAILINK_NAME(ASM Loopback),
  6396. .stream_name = "MultiMedia6",
  6397. .cpu_dai_name = "MultiMedia6",
  6398. .platform_name = "msm-pcm-loopback",
  6399. .dynamic = 1,
  6400. .dpcm_playback = 1,
  6401. .dpcm_capture = 1,
  6402. .codec_dai_name = "snd-soc-dummy-dai",
  6403. .codec_name = "snd-soc-dummy",
  6404. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6405. SND_SOC_DPCM_TRIGGER_POST},
  6406. .ignore_suspend = 1,
  6407. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6408. .ignore_pmdown_time = 1,
  6409. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  6410. },
  6411. {
  6412. .name = "USB Audio Hostless",
  6413. .stream_name = "USB Audio Hostless",
  6414. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  6415. .platform_name = "msm-pcm-hostless",
  6416. .dynamic = 1,
  6417. .dpcm_playback = 1,
  6418. .dpcm_capture = 1,
  6419. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6420. SND_SOC_DPCM_TRIGGER_POST},
  6421. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6422. .ignore_suspend = 1,
  6423. .ignore_pmdown_time = 1,
  6424. .codec_dai_name = "snd-soc-dummy-dai",
  6425. .codec_name = "snd-soc-dummy",
  6426. },
  6427. {
  6428. .name = "SLIMBUS_7 Hostless",
  6429. .stream_name = "SLIMBUS_7 Hostless",
  6430. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  6431. .platform_name = "msm-pcm-hostless",
  6432. .dynamic = 1,
  6433. .dpcm_capture = 1,
  6434. .dpcm_playback = 1,
  6435. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6436. SND_SOC_DPCM_TRIGGER_POST},
  6437. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6438. .ignore_suspend = 1,
  6439. .ignore_pmdown_time = 1,
  6440. .codec_dai_name = "snd-soc-dummy-dai",
  6441. .codec_name = "snd-soc-dummy",
  6442. },
  6443. {
  6444. .name = MSM_DAILINK_NAME(Compr Capture2),
  6445. .stream_name = "Compr Capture2",
  6446. .cpu_dai_name = "MultiMedia18",
  6447. .platform_name = "msm-compress-dsp",
  6448. .dynamic = 1,
  6449. .dpcm_capture = 1,
  6450. .codec_dai_name = "snd-soc-dummy-dai",
  6451. .codec_name = "snd-soc-dummy",
  6452. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6453. SND_SOC_DPCM_TRIGGER_POST},
  6454. .ignore_pmdown_time = 1,
  6455. .id = MSM_FRONTEND_DAI_MULTIMEDIA18,
  6456. },
  6457. {
  6458. .name = MSM_DAILINK_NAME(Transcode Loopback Playback),
  6459. .stream_name = "Transcode Loopback Playback",
  6460. .cpu_dai_name = "MultiMedia26",
  6461. .platform_name = "msm-transcode-loopback",
  6462. .dynamic = 1,
  6463. .dpcm_playback = 1,
  6464. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6465. SND_SOC_DPCM_TRIGGER_POST},
  6466. .codec_dai_name = "snd-soc-dummy-dai",
  6467. .codec_name = "snd-soc-dummy",
  6468. .ignore_suspend = 1,
  6469. .ignore_pmdown_time = 1,
  6470. /* this dailink has playback support */
  6471. .id = MSM_FRONTEND_DAI_MULTIMEDIA26,
  6472. },
  6473. {
  6474. .name = MSM_DAILINK_NAME(Transcode Loopback Capture),
  6475. .stream_name = "Transcode Loopback Capture",
  6476. .cpu_dai_name = "MultiMedia27",
  6477. .platform_name = "msm-transcode-loopback",
  6478. .dynamic = 1,
  6479. .dpcm_capture = 1,
  6480. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6481. SND_SOC_DPCM_TRIGGER_POST},
  6482. .codec_dai_name = "snd-soc-dummy-dai",
  6483. .codec_name = "snd-soc-dummy",
  6484. .ignore_suspend = 1,
  6485. .ignore_pmdown_time = 1,
  6486. .id = MSM_FRONTEND_DAI_MULTIMEDIA27,
  6487. },
  6488. {
  6489. .name = MSM_DAILINK_NAME(Compr Capture3),
  6490. .stream_name = "Compr Capture3",
  6491. .cpu_dai_name = "MultiMedia19",
  6492. .platform_name = "msm-compress-dsp",
  6493. .dynamic = 1,
  6494. .dpcm_capture = 1,
  6495. .codec_dai_name = "snd-soc-dummy-dai",
  6496. .codec_name = "snd-soc-dummy",
  6497. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6498. SND_SOC_DPCM_TRIGGER_POST},
  6499. .ignore_pmdown_time = 1,
  6500. .id = MSM_FRONTEND_DAI_MULTIMEDIA19,
  6501. },
  6502. {
  6503. .name = MSM_DAILINK_NAME(Compr Capture4),
  6504. .stream_name = "Compr Capture4",
  6505. .cpu_dai_name = "MultiMedia28",
  6506. .platform_name = "msm-compress-dsp",
  6507. .dynamic = 1,
  6508. .dpcm_capture = 1,
  6509. .codec_dai_name = "snd-soc-dummy-dai",
  6510. .codec_name = "snd-soc-dummy",
  6511. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6512. SND_SOC_DPCM_TRIGGER_POST},
  6513. .ignore_pmdown_time = 1,
  6514. .id = MSM_FRONTEND_DAI_MULTIMEDIA28,
  6515. },
  6516. {
  6517. .name = MSM_DAILINK_NAME(Compr Capture5),
  6518. .stream_name = "Compr Capture5",
  6519. .cpu_dai_name = "MultiMedia29",
  6520. .platform_name = "msm-compress-dsp",
  6521. .dynamic = 1,
  6522. .dpcm_capture = 1,
  6523. .codec_dai_name = "snd-soc-dummy-dai",
  6524. .codec_name = "snd-soc-dummy",
  6525. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6526. SND_SOC_DPCM_TRIGGER_POST},
  6527. .ignore_pmdown_time = 1,
  6528. .id = MSM_FRONTEND_DAI_MULTIMEDIA29,
  6529. },
  6530. {
  6531. .name = MSM_DAILINK_NAME(Compr Capture6),
  6532. .stream_name = "Compr Capture6",
  6533. .cpu_dai_name = "MultiMedia30",
  6534. .platform_name = "msm-compress-dsp",
  6535. .dynamic = 1,
  6536. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6537. .dpcm_capture = 1,
  6538. .codec_dai_name = "snd-soc-dummy-dai",
  6539. .codec_name = "snd-soc-dummy",
  6540. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6541. SND_SOC_DPCM_TRIGGER_POST},
  6542. .ignore_pmdown_time = 1,
  6543. .id = MSM_FRONTEND_DAI_MULTIMEDIA30,
  6544. },
  6545. };
  6546. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  6547. /* Backend AFE DAI Links */
  6548. {
  6549. .name = LPASS_BE_AFE_PCM_RX,
  6550. .stream_name = "AFE Playback",
  6551. .cpu_dai_name = "msm-dai-q6-dev.224",
  6552. .platform_name = "msm-pcm-routing",
  6553. .codec_name = "msm-stub-codec.1",
  6554. .codec_dai_name = "msm-stub-rx",
  6555. .no_pcm = 1,
  6556. .dpcm_playback = 1,
  6557. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  6558. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6559. /* this dainlink has playback support */
  6560. .ignore_pmdown_time = 1,
  6561. .ignore_suspend = 1,
  6562. },
  6563. {
  6564. .name = LPASS_BE_AFE_PCM_TX,
  6565. .stream_name = "AFE Capture",
  6566. .cpu_dai_name = "msm-dai-q6-dev.225",
  6567. .platform_name = "msm-pcm-routing",
  6568. .codec_name = "msm-stub-codec.1",
  6569. .codec_dai_name = "msm-stub-tx",
  6570. .no_pcm = 1,
  6571. .dpcm_capture = 1,
  6572. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  6573. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6574. .ignore_suspend = 1,
  6575. },
  6576. /* Incall Record Uplink BACK END DAI Link */
  6577. {
  6578. .name = LPASS_BE_INCALL_RECORD_TX,
  6579. .stream_name = "Voice Uplink Capture",
  6580. .cpu_dai_name = "msm-dai-q6-dev.32772",
  6581. .platform_name = "msm-pcm-routing",
  6582. .codec_name = "msm-stub-codec.1",
  6583. .codec_dai_name = "msm-stub-tx",
  6584. .no_pcm = 1,
  6585. .dpcm_capture = 1,
  6586. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  6587. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6588. .ignore_suspend = 1,
  6589. },
  6590. /* Incall Record Downlink BACK END DAI Link */
  6591. {
  6592. .name = LPASS_BE_INCALL_RECORD_RX,
  6593. .stream_name = "Voice Downlink Capture",
  6594. .cpu_dai_name = "msm-dai-q6-dev.32771",
  6595. .platform_name = "msm-pcm-routing",
  6596. .codec_name = "msm-stub-codec.1",
  6597. .codec_dai_name = "msm-stub-tx",
  6598. .no_pcm = 1,
  6599. .dpcm_capture = 1,
  6600. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  6601. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6602. .ignore_suspend = 1,
  6603. },
  6604. /* Incall Music BACK END DAI Link */
  6605. {
  6606. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  6607. .stream_name = "Voice Farend Playback",
  6608. .cpu_dai_name = "msm-dai-q6-dev.32773",
  6609. .platform_name = "msm-pcm-routing",
  6610. .codec_name = "msm-stub-codec.1",
  6611. .codec_dai_name = "msm-stub-rx",
  6612. .no_pcm = 1,
  6613. .dpcm_playback = 1,
  6614. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  6615. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6616. .ignore_suspend = 1,
  6617. .ignore_pmdown_time = 1,
  6618. },
  6619. /* Incall Music 2 BACK END DAI Link */
  6620. {
  6621. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  6622. .stream_name = "Voice2 Farend Playback",
  6623. .cpu_dai_name = "msm-dai-q6-dev.32770",
  6624. .platform_name = "msm-pcm-routing",
  6625. .codec_name = "msm-stub-codec.1",
  6626. .codec_dai_name = "msm-stub-rx",
  6627. .no_pcm = 1,
  6628. .dpcm_playback = 1,
  6629. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  6630. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6631. .ignore_suspend = 1,
  6632. .ignore_pmdown_time = 1,
  6633. },
  6634. {
  6635. .name = LPASS_BE_USB_AUDIO_RX,
  6636. .stream_name = "USB Audio Playback",
  6637. .cpu_dai_name = "msm-dai-q6-dev.28672",
  6638. .platform_name = "msm-pcm-routing",
  6639. .codec_name = "msm-stub-codec.1",
  6640. .codec_dai_name = "msm-stub-rx",
  6641. .no_pcm = 1,
  6642. .dpcm_playback = 1,
  6643. .id = MSM_BACKEND_DAI_USB_RX,
  6644. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6645. .ignore_pmdown_time = 1,
  6646. .ignore_suspend = 1,
  6647. },
  6648. {
  6649. .name = LPASS_BE_USB_AUDIO_TX,
  6650. .stream_name = "USB Audio Capture",
  6651. .cpu_dai_name = "msm-dai-q6-dev.28673",
  6652. .platform_name = "msm-pcm-routing",
  6653. .codec_name = "msm-stub-codec.1",
  6654. .codec_dai_name = "msm-stub-tx",
  6655. .no_pcm = 1,
  6656. .dpcm_capture = 1,
  6657. .id = MSM_BACKEND_DAI_USB_TX,
  6658. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6659. .ignore_suspend = 1,
  6660. },
  6661. {
  6662. .name = LPASS_BE_PRI_TDM_RX_0,
  6663. .stream_name = "Primary TDM0 Playback",
  6664. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  6665. .platform_name = "msm-pcm-routing",
  6666. .codec_name = "msm-stub-codec.1",
  6667. .codec_dai_name = "msm-stub-rx",
  6668. .no_pcm = 1,
  6669. .dpcm_playback = 1,
  6670. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  6671. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6672. .ops = &qcs405_tdm_be_ops,
  6673. .ignore_suspend = 1,
  6674. .ignore_pmdown_time = 1,
  6675. },
  6676. {
  6677. .name = LPASS_BE_PRI_TDM_TX_0,
  6678. .stream_name = "Primary TDM0 Capture",
  6679. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  6680. .platform_name = "msm-pcm-routing",
  6681. .codec_name = "msm-stub-codec.1",
  6682. .codec_dai_name = "msm-stub-tx",
  6683. .no_pcm = 1,
  6684. .dpcm_capture = 1,
  6685. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  6686. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6687. .ops = &qcs405_tdm_be_ops,
  6688. .ignore_suspend = 1,
  6689. },
  6690. {
  6691. .name = LPASS_BE_SEC_TDM_RX_0,
  6692. .stream_name = "Secondary TDM0 Playback",
  6693. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  6694. .platform_name = "msm-pcm-routing",
  6695. .codec_name = "msm-stub-codec.1",
  6696. .codec_dai_name = "msm-stub-rx",
  6697. .no_pcm = 1,
  6698. .dpcm_playback = 1,
  6699. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  6700. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6701. .ops = &qcs405_tdm_be_ops,
  6702. .ignore_suspend = 1,
  6703. .ignore_pmdown_time = 1,
  6704. },
  6705. {
  6706. .name = LPASS_BE_SEC_TDM_TX_0,
  6707. .stream_name = "Secondary TDM0 Capture",
  6708. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  6709. .platform_name = "msm-pcm-routing",
  6710. .codec_name = "msm-stub-codec.1",
  6711. .codec_dai_name = "msm-stub-tx",
  6712. .no_pcm = 1,
  6713. .dpcm_capture = 1,
  6714. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  6715. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6716. .ops = &qcs405_tdm_be_ops,
  6717. .ignore_suspend = 1,
  6718. },
  6719. {
  6720. .name = LPASS_BE_TERT_TDM_RX_0,
  6721. .stream_name = "Tertiary TDM0 Playback",
  6722. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  6723. .platform_name = "msm-pcm-routing",
  6724. .codec_name = "msm-stub-codec.1",
  6725. .codec_dai_name = "msm-stub-rx",
  6726. .no_pcm = 1,
  6727. .dpcm_playback = 1,
  6728. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  6729. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6730. .ops = &qcs405_tdm_be_ops,
  6731. .ignore_suspend = 1,
  6732. .ignore_pmdown_time = 1,
  6733. },
  6734. {
  6735. .name = LPASS_BE_TERT_TDM_TX_0,
  6736. .stream_name = "Tertiary TDM0 Capture",
  6737. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  6738. .platform_name = "msm-pcm-routing",
  6739. .codec_name = "msm-stub-codec.1",
  6740. .codec_dai_name = "msm-stub-tx",
  6741. .no_pcm = 1,
  6742. .dpcm_capture = 1,
  6743. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  6744. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6745. .ops = &qcs405_tdm_be_ops,
  6746. .ignore_suspend = 1,
  6747. },
  6748. {
  6749. .name = LPASS_BE_QUAT_TDM_RX_0,
  6750. .stream_name = "Quaternary TDM0 Playback",
  6751. .cpu_dai_name = "msm-dai-q6-tdm.36912",
  6752. .platform_name = "msm-pcm-routing",
  6753. .codec_name = "msm-stub-codec.1",
  6754. .codec_dai_name = "msm-stub-rx",
  6755. .no_pcm = 1,
  6756. .dpcm_playback = 1,
  6757. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  6758. .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
  6759. .ops = &qcs405_tdm_be_ops,
  6760. .ignore_suspend = 1,
  6761. .ignore_pmdown_time = 1,
  6762. },
  6763. {
  6764. .name = LPASS_BE_QUAT_TDM_TX_0,
  6765. .stream_name = "Quaternary TDM0 Capture",
  6766. .cpu_dai_name = "msm-dai-q6-tdm.36913",
  6767. .platform_name = "msm-pcm-routing",
  6768. .codec_name = "msm-stub-codec.1",
  6769. .codec_dai_name = "msm-stub-tx",
  6770. .no_pcm = 1,
  6771. .dpcm_capture = 1,
  6772. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  6773. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6774. .ops = &qcs405_tdm_be_ops,
  6775. .ignore_suspend = 1,
  6776. },
  6777. {
  6778. .name = LPASS_BE_QUIN_TDM_RX_0,
  6779. .stream_name = "Quinary TDM0 Playback",
  6780. .cpu_dai_name = "msm-dai-q6-tdm.36928",
  6781. .platform_name = "msm-pcm-routing",
  6782. .codec_name = "msm-stub-codec.1",
  6783. .codec_dai_name = "msm-stub-rx",
  6784. .no_pcm = 1,
  6785. .dpcm_playback = 1,
  6786. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  6787. .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
  6788. .ops = &qcs405_tdm_be_ops,
  6789. .ignore_suspend = 1,
  6790. .ignore_pmdown_time = 1,
  6791. },
  6792. {
  6793. .name = LPASS_BE_QUIN_TDM_TX_0,
  6794. .stream_name = "Quinary TDM0 Capture",
  6795. .cpu_dai_name = "msm-dai-q6-tdm.36929",
  6796. .platform_name = "msm-pcm-routing",
  6797. .codec_name = "msm-stub-codec.1",
  6798. .codec_dai_name = "msm-stub-tx",
  6799. .no_pcm = 1,
  6800. .dpcm_capture = 1,
  6801. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  6802. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6803. .ops = &qcs405_tdm_be_ops,
  6804. .ignore_suspend = 1,
  6805. },
  6806. };
  6807. static struct snd_soc_dai_link msm_tasha_be_dai_links[] = {
  6808. {
  6809. .name = LPASS_BE_SLIMBUS_0_RX,
  6810. .stream_name = "Slimbus Playback",
  6811. .cpu_dai_name = "msm-dai-q6-dev.16384",
  6812. .platform_name = "msm-pcm-routing",
  6813. .codec_name = "tasha_codec",
  6814. .codec_dai_name = "tasha_mix_rx1",
  6815. .no_pcm = 1,
  6816. .dpcm_playback = 1,
  6817. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  6818. .init = &msm_audrx_init,
  6819. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6820. /* this dainlink has playback support */
  6821. .ignore_pmdown_time = 1,
  6822. .ignore_suspend = 1,
  6823. .ops = &msm_be_ops,
  6824. },
  6825. {
  6826. .name = LPASS_BE_SLIMBUS_0_TX,
  6827. .stream_name = "Slimbus Capture",
  6828. .cpu_dai_name = "msm-dai-q6-dev.16385",
  6829. .platform_name = "msm-pcm-routing",
  6830. .codec_name = "tasha_codec",
  6831. .codec_dai_name = "tasha_tx1",
  6832. .no_pcm = 1,
  6833. .dpcm_capture = 1,
  6834. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  6835. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6836. .ignore_suspend = 1,
  6837. .ops = &msm_be_ops,
  6838. },
  6839. {
  6840. .name = LPASS_BE_SLIMBUS_1_RX,
  6841. .stream_name = "Slimbus1 Playback",
  6842. .cpu_dai_name = "msm-dai-q6-dev.16386",
  6843. .platform_name = "msm-pcm-routing",
  6844. .codec_name = "tasha_codec",
  6845. .codec_dai_name = "tasha_mix_rx1",
  6846. .no_pcm = 1,
  6847. .dpcm_playback = 1,
  6848. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  6849. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6850. .ops = &msm_be_ops,
  6851. /* dai link has playback support */
  6852. .ignore_pmdown_time = 1,
  6853. .ignore_suspend = 1,
  6854. },
  6855. {
  6856. .name = LPASS_BE_SLIMBUS_1_TX,
  6857. .stream_name = "Slimbus1 Capture",
  6858. .cpu_dai_name = "msm-dai-q6-dev.16387",
  6859. .platform_name = "msm-pcm-routing",
  6860. .codec_name = "tasha_codec",
  6861. .codec_dai_name = "tasha_tx3",
  6862. .no_pcm = 1,
  6863. .dpcm_capture = 1,
  6864. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  6865. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6866. .ops = &msm_be_ops,
  6867. .ignore_suspend = 1,
  6868. },
  6869. {
  6870. .name = LPASS_BE_SLIMBUS_2_RX,
  6871. .stream_name = "Slimbus2 Playback",
  6872. .cpu_dai_name = "msm-dai-q6-dev.16388",
  6873. .platform_name = "msm-pcm-routing",
  6874. .codec_name = "tasha_codec",
  6875. .codec_dai_name = "tasha_rx2",
  6876. .no_pcm = 1,
  6877. .dpcm_playback = 1,
  6878. .id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
  6879. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6880. .ops = &msm_be_ops,
  6881. .ignore_pmdown_time = 1,
  6882. .ignore_suspend = 1,
  6883. },
  6884. {
  6885. .name = LPASS_BE_SLIMBUS_3_RX,
  6886. .stream_name = "Slimbus3 Playback",
  6887. .cpu_dai_name = "msm-dai-q6-dev.16390",
  6888. .platform_name = "msm-pcm-routing",
  6889. .codec_name = "tasha_codec",
  6890. .codec_dai_name = "tasha_mix_rx1",
  6891. .no_pcm = 1,
  6892. .dpcm_playback = 1,
  6893. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  6894. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6895. .ops = &msm_be_ops,
  6896. /* dai link has playback support */
  6897. .ignore_pmdown_time = 1,
  6898. .ignore_suspend = 1,
  6899. },
  6900. {
  6901. .name = LPASS_BE_SLIMBUS_3_TX,
  6902. .stream_name = "Slimbus3 Capture",
  6903. .cpu_dai_name = "msm-dai-q6-dev.16391",
  6904. .platform_name = "msm-pcm-routing",
  6905. .codec_name = "tasha_codec",
  6906. .codec_dai_name = "tasha_tx1",
  6907. .no_pcm = 1,
  6908. .dpcm_capture = 1,
  6909. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  6910. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6911. .ops = &msm_be_ops,
  6912. .ignore_suspend = 1,
  6913. },
  6914. {
  6915. .name = LPASS_BE_SLIMBUS_4_RX,
  6916. .stream_name = "Slimbus4 Playback",
  6917. .cpu_dai_name = "msm-dai-q6-dev.16392",
  6918. .platform_name = "msm-pcm-routing",
  6919. .codec_name = "tasha_codec",
  6920. .codec_dai_name = "tasha_mix_rx1",
  6921. .no_pcm = 1,
  6922. .dpcm_playback = 1,
  6923. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  6924. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6925. .ops = &msm_be_ops,
  6926. /* dai link has playback support */
  6927. .ignore_pmdown_time = 1,
  6928. .ignore_suspend = 1,
  6929. },
  6930. {
  6931. .name = LPASS_BE_SLIMBUS_5_RX,
  6932. .stream_name = "Slimbus5 Playback",
  6933. .cpu_dai_name = "msm-dai-q6-dev.16394",
  6934. .platform_name = "msm-pcm-routing",
  6935. .codec_name = "tasha_codec",
  6936. .codec_dai_name = "tasha_rx3",
  6937. .no_pcm = 1,
  6938. .dpcm_playback = 1,
  6939. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  6940. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6941. .ops = &msm_be_ops,
  6942. /* dai link has playback support */
  6943. .ignore_pmdown_time = 1,
  6944. .ignore_suspend = 1,
  6945. },
  6946. {
  6947. .name = LPASS_BE_SLIMBUS_6_RX,
  6948. .stream_name = "Slimbus6 Playback",
  6949. .cpu_dai_name = "msm-dai-q6-dev.16396",
  6950. .platform_name = "msm-pcm-routing",
  6951. .codec_name = "tasha_codec",
  6952. .codec_dai_name = "tasha_rx4",
  6953. .no_pcm = 1,
  6954. .dpcm_playback = 1,
  6955. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  6956. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6957. .ops = &msm_be_ops,
  6958. /* dai link has playback support */
  6959. .ignore_pmdown_time = 1,
  6960. .ignore_suspend = 1,
  6961. },
  6962. /* Slimbus VI Recording */
  6963. {
  6964. .name = LPASS_BE_SLIMBUS_TX_VI,
  6965. .stream_name = "Slimbus4 Capture",
  6966. .cpu_dai_name = "msm-dai-q6-dev.16393",
  6967. .platform_name = "msm-pcm-routing",
  6968. .codec_name = "tasha_codec",
  6969. .codec_dai_name = "tasha_vifeedback",
  6970. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  6971. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6972. .ops = &msm_be_ops,
  6973. .ignore_suspend = 1,
  6974. .no_pcm = 1,
  6975. .dpcm_capture = 1,
  6976. .ignore_pmdown_time = 1,
  6977. },
  6978. };
  6979. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  6980. {
  6981. .name = LPASS_BE_SLIMBUS_7_RX,
  6982. .stream_name = "Slimbus7 Playback",
  6983. .cpu_dai_name = "msm-dai-q6-dev.16398",
  6984. .platform_name = "msm-pcm-routing",
  6985. .codec_name = "btfmslim_slave",
  6986. /* BT codec driver determines capabilities based on
  6987. * dai name, bt codecdai name should always contains
  6988. * supported usecase information
  6989. */
  6990. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  6991. .no_pcm = 1,
  6992. .dpcm_playback = 1,
  6993. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  6994. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6995. .ops = &msm_wcn_ops,
  6996. /* dai link has playback support */
  6997. .ignore_pmdown_time = 1,
  6998. .ignore_suspend = 1,
  6999. },
  7000. {
  7001. .name = LPASS_BE_SLIMBUS_7_TX,
  7002. .stream_name = "Slimbus7 Capture",
  7003. .cpu_dai_name = "msm-dai-q6-dev.16399",
  7004. .platform_name = "msm-pcm-routing",
  7005. .codec_name = "btfmslim_slave",
  7006. .codec_dai_name = "btfm_bt_sco_slim_tx",
  7007. .no_pcm = 1,
  7008. .dpcm_capture = 1,
  7009. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  7010. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7011. .ops = &msm_wcn_ops,
  7012. .ignore_suspend = 1,
  7013. },
  7014. {
  7015. .name = LPASS_BE_SLIMBUS_8_TX,
  7016. .stream_name = "Slimbus8 Capture",
  7017. .cpu_dai_name = "msm-dai-q6-dev.16401",
  7018. .platform_name = "msm-pcm-routing",
  7019. .codec_name = "btfmslim_slave",
  7020. .codec_dai_name = "btfm_fm_slim_tx",
  7021. .no_pcm = 1,
  7022. .dpcm_capture = 1,
  7023. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  7024. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7025. .init = &msm_wcn_init,
  7026. .ops = &msm_wcn_ops,
  7027. .ignore_suspend = 1,
  7028. },
  7029. {
  7030. .name = LPASS_BE_SLIMBUS_9_TX,
  7031. .stream_name = "Slimbus9 Capture",
  7032. .cpu_dai_name = "msm-dai-q6-dev.16403",
  7033. .platform_name = "msm-pcm-routing",
  7034. .codec_name = "btfmslim_slave",
  7035. .codec_dai_name = "btfm_bt_split_a2dp_slim_tx",
  7036. .no_pcm = 1,
  7037. .dpcm_capture = 1,
  7038. .id = MSM_BACKEND_DAI_SLIMBUS_9_TX,
  7039. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7040. .ops = &msm_wcn_ops,
  7041. .ignore_suspend = 1,
  7042. },
  7043. };
  7044. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  7045. {
  7046. .name = LPASS_BE_PRI_MI2S_RX,
  7047. .stream_name = "Primary MI2S Playback",
  7048. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  7049. .platform_name = "msm-pcm-routing",
  7050. .codec_name = "msm-stub-codec.1",
  7051. .codec_dai_name = "msm-stub-rx",
  7052. .no_pcm = 1,
  7053. .dpcm_playback = 1,
  7054. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  7055. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7056. .ops = &msm_mi2s_be_ops,
  7057. .ignore_suspend = 1,
  7058. .ignore_pmdown_time = 1,
  7059. },
  7060. {
  7061. .name = LPASS_BE_PRI_MI2S_TX,
  7062. .stream_name = "Primary MI2S Capture",
  7063. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  7064. .platform_name = "msm-pcm-routing",
  7065. .codec_name = "msm-stub-codec.1",
  7066. .codec_dai_name = "msm-stub-tx",
  7067. .no_pcm = 1,
  7068. .dpcm_capture = 1,
  7069. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  7070. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7071. .ops = &msm_mi2s_be_ops,
  7072. .ignore_suspend = 1,
  7073. },
  7074. {
  7075. .name = LPASS_BE_SEC_MI2S_RX,
  7076. .stream_name = "Secondary MI2S Playback",
  7077. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  7078. .platform_name = "msm-pcm-routing",
  7079. .codec_name = "msm-stub-codec.1",
  7080. .codec_dai_name = "msm-stub-rx",
  7081. .no_pcm = 1,
  7082. .dpcm_playback = 1,
  7083. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  7084. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7085. .ops = &msm_mi2s_be_ops,
  7086. .ignore_suspend = 1,
  7087. .ignore_pmdown_time = 1,
  7088. },
  7089. {
  7090. .name = LPASS_BE_SEC_MI2S_TX,
  7091. .stream_name = "Secondary MI2S Capture",
  7092. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  7093. .platform_name = "msm-pcm-routing",
  7094. .codec_name = "msm-stub-codec.1",
  7095. .codec_dai_name = "msm-stub-tx",
  7096. .no_pcm = 1,
  7097. .dpcm_capture = 1,
  7098. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  7099. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7100. .ops = &msm_mi2s_be_ops,
  7101. .ignore_suspend = 1,
  7102. },
  7103. {
  7104. .name = LPASS_BE_TERT_MI2S_RX,
  7105. .stream_name = "Tertiary MI2S Playback",
  7106. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  7107. .platform_name = "msm-pcm-routing",
  7108. .codec_name = "msm-stub-codec.1",
  7109. .codec_dai_name = "msm-stub-rx",
  7110. .no_pcm = 1,
  7111. .dpcm_playback = 1,
  7112. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  7113. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7114. .ops = &msm_mi2s_be_ops,
  7115. .ignore_suspend = 1,
  7116. .ignore_pmdown_time = 1,
  7117. },
  7118. {
  7119. .name = LPASS_BE_TERT_MI2S_TX,
  7120. .stream_name = "Tertiary MI2S Capture",
  7121. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  7122. .platform_name = "msm-pcm-routing",
  7123. .codec_name = "msm-stub-codec.1",
  7124. .codec_dai_name = "msm-stub-tx",
  7125. .no_pcm = 1,
  7126. .dpcm_capture = 1,
  7127. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  7128. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7129. .ops = &msm_mi2s_be_ops,
  7130. .ignore_suspend = 1,
  7131. },
  7132. {
  7133. .name = LPASS_BE_QUAT_MI2S_RX,
  7134. .stream_name = "Quaternary MI2S Playback",
  7135. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  7136. .platform_name = "msm-pcm-routing",
  7137. .codec_name = "msm-stub-codec.1",
  7138. .codec_dai_name = "msm-stub-rx",
  7139. .no_pcm = 1,
  7140. .dpcm_playback = 1,
  7141. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  7142. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7143. .ops = &msm_mi2s_be_ops,
  7144. .ignore_suspend = 1,
  7145. .ignore_pmdown_time = 1,
  7146. },
  7147. {
  7148. .name = LPASS_BE_QUAT_MI2S_TX,
  7149. .stream_name = "Quaternary MI2S Capture",
  7150. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  7151. .platform_name = "msm-pcm-routing",
  7152. .codec_name = "msm-stub-codec.1",
  7153. .codec_dai_name = "msm-stub-tx",
  7154. .no_pcm = 1,
  7155. .dpcm_capture = 1,
  7156. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  7157. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7158. .ops = &msm_mi2s_be_ops,
  7159. .ignore_suspend = 1,
  7160. },
  7161. {
  7162. .name = LPASS_BE_QUIN_MI2S_RX,
  7163. .stream_name = "Quinary MI2S Playback",
  7164. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  7165. .platform_name = "msm-pcm-routing",
  7166. .codec_name = "msm-stub-codec.1",
  7167. .codec_dai_name = "msm-stub-rx",
  7168. .no_pcm = 1,
  7169. .dpcm_playback = 1,
  7170. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  7171. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7172. .ops = &msm_mi2s_be_ops,
  7173. .ignore_suspend = 1,
  7174. .ignore_pmdown_time = 1,
  7175. },
  7176. {
  7177. .name = LPASS_BE_QUIN_MI2S_TX,
  7178. .stream_name = "Quinary MI2S Capture",
  7179. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  7180. .platform_name = "msm-pcm-routing",
  7181. .codec_name = "msm-stub-codec.1",
  7182. .codec_dai_name = "msm-stub-tx",
  7183. .no_pcm = 1,
  7184. .dpcm_capture = 1,
  7185. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  7186. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7187. .ops = &msm_mi2s_be_ops,
  7188. .ignore_suspend = 1,
  7189. },
  7190. };
  7191. static struct snd_soc_dai_link msm_meta_mi2s_be_dai_links[] = {
  7192. {
  7193. .name = LPASS_BE_PRI_META_MI2S_RX,
  7194. .stream_name = "Primary META MI2S Playback",
  7195. .cpu_dai_name = "msm-dai-q6-meta-mi2s.4864",
  7196. .platform_name = "msm-pcm-routing",
  7197. .codec_name = "msm-stub-codec.1",
  7198. .codec_dai_name = "msm-stub-rx",
  7199. .no_pcm = 1,
  7200. .dpcm_playback = 1,
  7201. .id = MSM_BACKEND_DAI_PRI_META_MI2S_RX,
  7202. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7203. .ops = &msm_meta_mi2s_be_ops,
  7204. .ignore_suspend = 1,
  7205. .ignore_pmdown_time = 1,
  7206. },
  7207. {
  7208. .name = LPASS_BE_SEC_META_MI2S_RX,
  7209. .stream_name = "Secondary META MI2S Playback",
  7210. .cpu_dai_name = "msm-dai-q6-meta-mi2s.4866",
  7211. .platform_name = "msm-pcm-routing",
  7212. .codec_name = "msm-stub-codec.1",
  7213. .codec_dai_name = "msm-stub-rx",
  7214. .no_pcm = 1,
  7215. .dpcm_playback = 1,
  7216. .id = MSM_BACKEND_DAI_SEC_META_MI2S_RX,
  7217. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7218. .ops = &msm_meta_mi2s_be_ops,
  7219. .ignore_suspend = 1,
  7220. .ignore_pmdown_time = 1,
  7221. },
  7222. };
  7223. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  7224. /* Primary AUX PCM Backend DAI Links */
  7225. {
  7226. .name = LPASS_BE_AUXPCM_RX,
  7227. .stream_name = "AUX PCM Playback",
  7228. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  7229. .platform_name = "msm-pcm-routing",
  7230. .codec_name = "msm-stub-codec.1",
  7231. .codec_dai_name = "msm-stub-rx",
  7232. .no_pcm = 1,
  7233. .dpcm_playback = 1,
  7234. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  7235. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7236. .ops = &msm_auxpcm_be_ops,
  7237. .ignore_pmdown_time = 1,
  7238. .ignore_suspend = 1,
  7239. },
  7240. {
  7241. .name = LPASS_BE_AUXPCM_TX,
  7242. .stream_name = "AUX PCM Capture",
  7243. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  7244. .platform_name = "msm-pcm-routing",
  7245. .codec_name = "msm-stub-codec.1",
  7246. .codec_dai_name = "msm-stub-tx",
  7247. .no_pcm = 1,
  7248. .dpcm_capture = 1,
  7249. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  7250. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7251. .ops = &msm_auxpcm_be_ops,
  7252. .ignore_suspend = 1,
  7253. },
  7254. /* Secondary AUX PCM Backend DAI Links */
  7255. {
  7256. .name = LPASS_BE_SEC_AUXPCM_RX,
  7257. .stream_name = "Sec AUX PCM Playback",
  7258. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  7259. .platform_name = "msm-pcm-routing",
  7260. .codec_name = "msm-stub-codec.1",
  7261. .codec_dai_name = "msm-stub-rx",
  7262. .no_pcm = 1,
  7263. .dpcm_playback = 1,
  7264. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  7265. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7266. .ops = &msm_auxpcm_be_ops,
  7267. .ignore_pmdown_time = 1,
  7268. .ignore_suspend = 1,
  7269. },
  7270. {
  7271. .name = LPASS_BE_SEC_AUXPCM_TX,
  7272. .stream_name = "Sec AUX PCM Capture",
  7273. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  7274. .platform_name = "msm-pcm-routing",
  7275. .codec_name = "msm-stub-codec.1",
  7276. .codec_dai_name = "msm-stub-tx",
  7277. .no_pcm = 1,
  7278. .dpcm_capture = 1,
  7279. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  7280. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7281. .ops = &msm_auxpcm_be_ops,
  7282. .ignore_suspend = 1,
  7283. },
  7284. /* Tertiary AUX PCM Backend DAI Links */
  7285. {
  7286. .name = LPASS_BE_TERT_AUXPCM_RX,
  7287. .stream_name = "Tert AUX PCM Playback",
  7288. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  7289. .platform_name = "msm-pcm-routing",
  7290. .codec_name = "msm-stub-codec.1",
  7291. .codec_dai_name = "msm-stub-rx",
  7292. .no_pcm = 1,
  7293. .dpcm_playback = 1,
  7294. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  7295. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7296. .ops = &msm_auxpcm_be_ops,
  7297. .ignore_suspend = 1,
  7298. },
  7299. {
  7300. .name = LPASS_BE_TERT_AUXPCM_TX,
  7301. .stream_name = "Tert AUX PCM Capture",
  7302. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  7303. .platform_name = "msm-pcm-routing",
  7304. .codec_name = "msm-stub-codec.1",
  7305. .codec_dai_name = "msm-stub-tx",
  7306. .no_pcm = 1,
  7307. .dpcm_capture = 1,
  7308. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  7309. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7310. .ops = &msm_auxpcm_be_ops,
  7311. .ignore_suspend = 1,
  7312. },
  7313. /* Quaternary AUX PCM Backend DAI Links */
  7314. {
  7315. .name = LPASS_BE_QUAT_AUXPCM_RX,
  7316. .stream_name = "Quat AUX PCM Playback",
  7317. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  7318. .platform_name = "msm-pcm-routing",
  7319. .codec_name = "msm-stub-codec.1",
  7320. .codec_dai_name = "msm-stub-rx",
  7321. .no_pcm = 1,
  7322. .dpcm_playback = 1,
  7323. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  7324. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7325. .ops = &msm_auxpcm_be_ops,
  7326. .ignore_pmdown_time = 1,
  7327. .ignore_suspend = 1,
  7328. },
  7329. {
  7330. .name = LPASS_BE_QUAT_AUXPCM_TX,
  7331. .stream_name = "Quat AUX PCM Capture",
  7332. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  7333. .platform_name = "msm-pcm-routing",
  7334. .codec_name = "msm-stub-codec.1",
  7335. .codec_dai_name = "msm-stub-tx",
  7336. .no_pcm = 1,
  7337. .dpcm_capture = 1,
  7338. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  7339. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7340. .ops = &msm_auxpcm_be_ops,
  7341. .ignore_suspend = 1,
  7342. },
  7343. /* Quinary AUX PCM Backend DAI Links */
  7344. {
  7345. .name = LPASS_BE_QUIN_AUXPCM_RX,
  7346. .stream_name = "Quin AUX PCM Playback",
  7347. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  7348. .platform_name = "msm-pcm-routing",
  7349. .codec_name = "msm-stub-codec.1",
  7350. .codec_dai_name = "msm-stub-rx",
  7351. .no_pcm = 1,
  7352. .dpcm_playback = 1,
  7353. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  7354. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7355. .ops = &msm_auxpcm_be_ops,
  7356. .ignore_pmdown_time = 1,
  7357. .ignore_suspend = 1,
  7358. },
  7359. {
  7360. .name = LPASS_BE_QUIN_AUXPCM_TX,
  7361. .stream_name = "Quin AUX PCM Capture",
  7362. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  7363. .platform_name = "msm-pcm-routing",
  7364. .codec_name = "msm-stub-codec.1",
  7365. .codec_dai_name = "msm-stub-tx",
  7366. .no_pcm = 1,
  7367. .dpcm_capture = 1,
  7368. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  7369. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7370. .ops = &msm_auxpcm_be_ops,
  7371. .ignore_suspend = 1,
  7372. },
  7373. };
  7374. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  7375. /* WSA CDC DMA Backend DAI Links */
  7376. {
  7377. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  7378. .stream_name = "WSA CDC DMA0 Playback",
  7379. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  7380. .platform_name = "msm-pcm-routing",
  7381. .codec_name = "bolero_codec",
  7382. .codec_dai_name = "wsa_macro_rx1",
  7383. .no_pcm = 1,
  7384. .dpcm_playback = 1,
  7385. .init = &msm_wsa_cdc_dma_init,
  7386. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  7387. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7388. .ignore_pmdown_time = 1,
  7389. .ignore_suspend = 1,
  7390. .ops = &msm_cdc_dma_be_ops,
  7391. },
  7392. {
  7393. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  7394. .stream_name = "WSA CDC DMA1 Playback",
  7395. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  7396. .platform_name = "msm-pcm-routing",
  7397. .codec_name = "bolero_codec",
  7398. .codec_dai_name = "wsa_macro_rx_mix",
  7399. .no_pcm = 1,
  7400. .dpcm_playback = 1,
  7401. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  7402. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7403. .ignore_pmdown_time = 1,
  7404. .ignore_suspend = 1,
  7405. .ops = &msm_cdc_dma_be_ops,
  7406. },
  7407. {
  7408. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  7409. .stream_name = "WSA CDC DMA1 Capture",
  7410. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  7411. .platform_name = "msm-pcm-routing",
  7412. .codec_name = "bolero_codec",
  7413. .codec_dai_name = "wsa_macro_echo",
  7414. .no_pcm = 1,
  7415. .dpcm_capture = 1,
  7416. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  7417. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7418. .ignore_suspend = 1,
  7419. .ops = &msm_cdc_dma_be_ops,
  7420. },
  7421. };
  7422. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  7423. {
  7424. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  7425. .stream_name = "VA CDC DMA0 Capture",
  7426. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  7427. .platform_name = "msm-pcm-routing",
  7428. .codec_name = "bolero_codec",
  7429. .codec_dai_name = "va_macro_tx1",
  7430. .no_pcm = 1,
  7431. .dpcm_capture = 1,
  7432. .init = &msm_va_cdc_dma_init,
  7433. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  7434. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7435. .ignore_suspend = 1,
  7436. .ops = &msm_cdc_dma_be_ops,
  7437. },
  7438. {
  7439. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  7440. .stream_name = "VA CDC DMA1 Capture",
  7441. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  7442. .platform_name = "msm-pcm-routing",
  7443. .codec_name = "bolero_codec",
  7444. .codec_dai_name = "va_macro_tx2",
  7445. .no_pcm = 1,
  7446. .dpcm_capture = 1,
  7447. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  7448. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7449. .ignore_suspend = 1,
  7450. .ops = &msm_cdc_dma_be_ops,
  7451. },
  7452. };
  7453. static struct snd_soc_dai_link msm_spdif_be_dai_links[] = {
  7454. {
  7455. .name = LPASS_BE_PRI_SPDIF_RX,
  7456. .stream_name = "Primary SPDIF Playback",
  7457. .cpu_dai_name = "msm-dai-q6-spdif.20480",
  7458. .platform_name = "msm-pcm-routing",
  7459. .codec_name = "msm-stub-codec.1",
  7460. .codec_dai_name = "msm-stub-rx",
  7461. .no_pcm = 1,
  7462. .dpcm_playback = 1,
  7463. .id = MSM_BACKEND_DAI_PRI_SPDIF_RX,
  7464. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7465. .ops = &msm_spdif_be_ops,
  7466. .ignore_suspend = 1,
  7467. .ignore_pmdown_time = 1,
  7468. },
  7469. {
  7470. .name = LPASS_BE_PRI_SPDIF_TX,
  7471. .stream_name = "Primary SPDIF Capture",
  7472. .cpu_dai_name = "msm-dai-q6-spdif.20481",
  7473. .platform_name = "msm-pcm-routing",
  7474. .codec_name = "msm-stub-codec.1",
  7475. .codec_dai_name = "msm-stub-tx",
  7476. .no_pcm = 1,
  7477. .dpcm_capture = 1,
  7478. .id = MSM_BACKEND_DAI_PRI_SPDIF_TX,
  7479. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7480. .ops = &msm_spdif_be_ops,
  7481. .ignore_suspend = 1,
  7482. },
  7483. {
  7484. .name = LPASS_BE_SEC_SPDIF_RX,
  7485. .stream_name = "Secondary SPDIF Playback",
  7486. .cpu_dai_name = "msm-dai-q6-spdif.20482",
  7487. .platform_name = "msm-pcm-routing",
  7488. .codec_name = "msm-stub-codec.1",
  7489. .codec_dai_name = "msm-stub-rx",
  7490. .no_pcm = 1,
  7491. .dpcm_playback = 1,
  7492. .id = MSM_BACKEND_DAI_SEC_SPDIF_RX,
  7493. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7494. .ops = &msm_spdif_be_ops,
  7495. .ignore_suspend = 1,
  7496. .ignore_pmdown_time = 1,
  7497. },
  7498. {
  7499. .name = LPASS_BE_SEC_SPDIF_TX,
  7500. .stream_name = "Secondary SPDIF Capture",
  7501. .cpu_dai_name = "msm-dai-q6-spdif.20483",
  7502. .platform_name = "msm-pcm-routing",
  7503. .codec_name = "msm-stub-codec.1",
  7504. .codec_dai_name = "msm-stub-tx",
  7505. .no_pcm = 1,
  7506. .dpcm_capture = 1,
  7507. .id = MSM_BACKEND_DAI_SEC_SPDIF_TX,
  7508. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7509. .ops = &msm_spdif_be_ops,
  7510. .ignore_suspend = 1,
  7511. },
  7512. };
  7513. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  7514. {
  7515. .name = LPASS_BE_AFE_LOOPBACK_TX,
  7516. .stream_name = "AFE Loopback Capture",
  7517. .cpu_dai_name = "msm-dai-q6-dev.24577",
  7518. .platform_name = "msm-pcm-routing",
  7519. .codec_name = "msm-stub-codec.1",
  7520. .codec_dai_name = "msm-stub-tx",
  7521. .no_pcm = 1,
  7522. .dpcm_capture = 1,
  7523. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  7524. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7525. .ignore_pmdown_time = 1,
  7526. .ignore_suspend = 1,
  7527. },
  7528. };
  7529. static struct snd_soc_dai_link msm_qcs405_dai_links[
  7530. ARRAY_SIZE(msm_common_dai_links) +
  7531. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  7532. ARRAY_SIZE(msm_common_be_dai_links) +
  7533. ARRAY_SIZE(msm_tasha_be_dai_links) +
  7534. ARRAY_SIZE(msm_wcn_be_dai_links) +
  7535. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  7536. ARRAY_SIZE(msm_meta_mi2s_be_dai_links) +
  7537. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  7538. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  7539. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  7540. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  7541. ARRAY_SIZE(msm_spdif_be_dai_links) +
  7542. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link)];
  7543. static int msm_snd_card_tasha_late_probe(struct snd_soc_card *card)
  7544. {
  7545. int ret = 0;
  7546. ret = audio_notifier_register("qcs405", AUDIO_NOTIFIER_ADSP_DOMAIN,
  7547. &service_nb);
  7548. if (ret < 0)
  7549. pr_err("%s: Audio notifier register failed ret = %d\n",
  7550. __func__, ret);
  7551. return ret;
  7552. }
  7553. static int msm_snd_vad_cfg_put(struct snd_kcontrol *kcontrol,
  7554. struct snd_ctl_elem_value *ucontrol)
  7555. {
  7556. int ret = 0;
  7557. int port_id;
  7558. uint32_t vad_enable = ucontrol->value.integer.value[0];
  7559. uint32_t preroll_config = ucontrol->value.integer.value[1];
  7560. uint32_t vad_intf = ucontrol->value.integer.value[2];
  7561. if ((preroll_config < 0) || (preroll_config > 1000) ||
  7562. (vad_enable < 0) || (vad_enable > 1) ||
  7563. (vad_intf > MSM_BACKEND_DAI_MAX)) {
  7564. pr_err("%s: Invalid arguments\n", __func__);
  7565. ret = -EINVAL;
  7566. goto done;
  7567. }
  7568. pr_debug("%s: vad_enable=%d preroll_config=%d vad_intf=%d\n", __func__,
  7569. vad_enable, preroll_config, vad_intf);
  7570. ret = msm_island_vad_get_portid_from_beid(vad_intf, &port_id);
  7571. if (ret) {
  7572. pr_err("%s: Invalid vad interface\n", __func__);
  7573. goto done;
  7574. }
  7575. afe_set_vad_cfg(vad_enable, preroll_config, port_id);
  7576. done:
  7577. return ret;
  7578. }
  7579. static int msm_snd_card_codec_late_probe(struct snd_soc_card *card)
  7580. {
  7581. int ret = 0;
  7582. uint32_t tasha_codec = 0;
  7583. ret = afe_cal_init_hwdep(card);
  7584. if (ret) {
  7585. dev_err(card->dev, "afe cal hwdep init failed (%d)\n", ret);
  7586. ret = 0;
  7587. }
  7588. /* tasha late probe when it is present */
  7589. ret = of_property_read_u32(card->dev->of_node, "qcom,tasha-codec",
  7590. &tasha_codec);
  7591. if (ret) {
  7592. dev_err(card->dev, "%s: No DT match tasha codec\n", __func__);
  7593. ret = 0;
  7594. } else {
  7595. if (tasha_codec) {
  7596. ret = msm_snd_card_tasha_late_probe(card);
  7597. if (ret)
  7598. dev_err(card->dev, "%s: tasha late probe err\n",
  7599. __func__);
  7600. }
  7601. }
  7602. return ret;
  7603. }
  7604. struct snd_soc_card snd_soc_card_qcs405_msm = {
  7605. .name = "qcs405-snd-card",
  7606. .controls = msm_snd_controls,
  7607. .num_controls = ARRAY_SIZE(msm_snd_controls),
  7608. .late_probe = msm_snd_card_codec_late_probe,
  7609. };
  7610. static int msm_populate_dai_link_component_of_node(
  7611. struct snd_soc_card *card)
  7612. {
  7613. int i, index, ret = 0;
  7614. struct device *cdev = card->dev;
  7615. struct snd_soc_dai_link *dai_link = card->dai_link;
  7616. struct device_node *np;
  7617. if (!cdev) {
  7618. pr_err("%s: Sound card device memory NULL\n", __func__);
  7619. return -ENODEV;
  7620. }
  7621. for (i = 0; i < card->num_links; i++) {
  7622. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  7623. continue;
  7624. /* populate platform_of_node for snd card dai links */
  7625. if (dai_link[i].platform_name &&
  7626. !dai_link[i].platform_of_node) {
  7627. index = of_property_match_string(cdev->of_node,
  7628. "asoc-platform-names",
  7629. dai_link[i].platform_name);
  7630. if (index < 0) {
  7631. pr_err("%s: No match found for platform name: %s\n",
  7632. __func__, dai_link[i].platform_name);
  7633. ret = index;
  7634. goto err;
  7635. }
  7636. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  7637. index);
  7638. if (!np) {
  7639. pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
  7640. __func__, dai_link[i].platform_name,
  7641. index);
  7642. ret = -ENODEV;
  7643. goto err;
  7644. }
  7645. dai_link[i].platform_of_node = np;
  7646. dai_link[i].platform_name = NULL;
  7647. }
  7648. /* populate cpu_of_node for snd card dai links */
  7649. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  7650. index = of_property_match_string(cdev->of_node,
  7651. "asoc-cpu-names",
  7652. dai_link[i].cpu_dai_name);
  7653. if (index >= 0) {
  7654. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  7655. index);
  7656. if (!np) {
  7657. pr_err("%s: retrieving phandle for cpu dai %s failed\n",
  7658. __func__,
  7659. dai_link[i].cpu_dai_name);
  7660. ret = -ENODEV;
  7661. goto err;
  7662. }
  7663. dai_link[i].cpu_of_node = np;
  7664. dai_link[i].cpu_dai_name = NULL;
  7665. }
  7666. }
  7667. /* populate codec_of_node for snd card dai links */
  7668. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  7669. index = of_property_match_string(cdev->of_node,
  7670. "asoc-codec-names",
  7671. dai_link[i].codec_name);
  7672. if (index < 0)
  7673. continue;
  7674. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  7675. index);
  7676. if (!np) {
  7677. pr_err("%s: retrieving phandle for codec %s failed\n",
  7678. __func__, dai_link[i].codec_name);
  7679. ret = -ENODEV;
  7680. goto err;
  7681. }
  7682. dai_link[i].codec_of_node = np;
  7683. dai_link[i].codec_name = NULL;
  7684. }
  7685. }
  7686. err:
  7687. return ret;
  7688. }
  7689. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  7690. /* FrontEnd DAI Links */
  7691. {
  7692. .name = "MSMSTUB Media1",
  7693. .stream_name = "MultiMedia1",
  7694. .cpu_dai_name = "MultiMedia1",
  7695. .platform_name = "msm-pcm-dsp.0",
  7696. .dynamic = 1,
  7697. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  7698. .dpcm_playback = 1,
  7699. .dpcm_capture = 1,
  7700. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  7701. SND_SOC_DPCM_TRIGGER_POST},
  7702. .codec_dai_name = "snd-soc-dummy-dai",
  7703. .codec_name = "snd-soc-dummy",
  7704. .ignore_suspend = 1,
  7705. /* this dainlink has playback support */
  7706. .ignore_pmdown_time = 1,
  7707. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  7708. },
  7709. };
  7710. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  7711. /* Backend DAI Links */
  7712. {
  7713. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  7714. .stream_name = "VA CDC DMA0 Capture",
  7715. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  7716. .platform_name = "msm-pcm-routing",
  7717. .codec_name = "bolero_codec",
  7718. .codec_dai_name = "va_macro_tx1",
  7719. .no_pcm = 1,
  7720. .dpcm_capture = 1,
  7721. .init = &msm_va_cdc_dma_init,
  7722. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  7723. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7724. .ignore_suspend = 1,
  7725. .ops = &msm_cdc_dma_be_ops,
  7726. },
  7727. {
  7728. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  7729. .stream_name = "VA CDC DMA1 Capture",
  7730. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  7731. .platform_name = "msm-pcm-routing",
  7732. .codec_name = "bolero_codec",
  7733. .codec_dai_name = "va_macro_tx2",
  7734. .no_pcm = 1,
  7735. .dpcm_capture = 1,
  7736. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  7737. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7738. .ignore_suspend = 1,
  7739. .ops = &msm_cdc_dma_be_ops,
  7740. },
  7741. };
  7742. static struct snd_soc_dai_link msm_stub_dai_links[
  7743. ARRAY_SIZE(msm_stub_fe_dai_links) +
  7744. ARRAY_SIZE(msm_stub_be_dai_links)];
  7745. struct snd_soc_card snd_soc_card_stub_msm = {
  7746. .name = "qcs405-stub-snd-card",
  7747. };
  7748. static const struct of_device_id qcs405_asoc_machine_of_match[] = {
  7749. { .compatible = "qcom,qcs405-asoc-snd",
  7750. .data = "codec"},
  7751. { .compatible = "qcom,qcs405-asoc-snd-stub",
  7752. .data = "stub_codec"},
  7753. {},
  7754. };
  7755. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  7756. {
  7757. struct snd_soc_card *card = NULL;
  7758. struct snd_soc_dai_link *dailink;
  7759. int total_links = 0;
  7760. uint32_t tasha_codec = 0, auxpcm_audio_intf = 0;
  7761. uint32_t va_bolero_codec = 0, wsa_bolero_codec = 0, mi2s_audio_intf = 0;
  7762. uint32_t spdif_audio_intf = 0, wcn_audio_intf = 0;
  7763. uint32_t afe_loopback_intf = 0, meta_mi2s_intf = 0;
  7764. const struct of_device_id *match;
  7765. char __iomem *spdif_cfg, *spdif_pin_ctl;
  7766. int rc = 0;
  7767. match = of_match_node(qcs405_asoc_machine_of_match, dev->of_node);
  7768. if (!match) {
  7769. dev_err(dev, "%s: No DT match found for sound card\n",
  7770. __func__);
  7771. return NULL;
  7772. }
  7773. if (!strcmp(match->data, "codec")) {
  7774. card = &snd_soc_card_qcs405_msm;
  7775. memcpy(msm_qcs405_dai_links + total_links,
  7776. msm_common_dai_links,
  7777. sizeof(msm_common_dai_links));
  7778. total_links += ARRAY_SIZE(msm_common_dai_links);
  7779. rc = of_property_read_u32(dev->of_node, "qcom,wsa-bolero-codec",
  7780. &wsa_bolero_codec);
  7781. if (rc) {
  7782. dev_dbg(dev, "%s: No DT match WSA Macro codec\n",
  7783. __func__);
  7784. } else {
  7785. if (wsa_bolero_codec) {
  7786. dev_dbg(dev, "%s(): WSA macro in bolero codec present\n",
  7787. __func__);
  7788. memcpy(msm_qcs405_dai_links + total_links,
  7789. msm_bolero_fe_dai_links,
  7790. sizeof(msm_bolero_fe_dai_links));
  7791. total_links +=
  7792. ARRAY_SIZE(msm_bolero_fe_dai_links);
  7793. }
  7794. }
  7795. memcpy(msm_qcs405_dai_links + total_links,
  7796. msm_common_misc_fe_dai_links,
  7797. sizeof(msm_common_misc_fe_dai_links));
  7798. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  7799. memcpy(msm_qcs405_dai_links + total_links,
  7800. msm_common_be_dai_links,
  7801. sizeof(msm_common_be_dai_links));
  7802. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  7803. rc = of_property_read_u32(dev->of_node, "qcom,tasha-codec",
  7804. &tasha_codec);
  7805. if (rc) {
  7806. dev_dbg(dev, "%s: No DT match tasha codec\n",
  7807. __func__);
  7808. } else {
  7809. if (tasha_codec) {
  7810. memcpy(msm_qcs405_dai_links + total_links,
  7811. msm_tasha_be_dai_links,
  7812. sizeof(msm_tasha_be_dai_links));
  7813. total_links +=
  7814. ARRAY_SIZE(msm_tasha_be_dai_links);
  7815. }
  7816. }
  7817. rc = of_property_read_u32(dev->of_node, "qcom,va-bolero-codec",
  7818. &va_bolero_codec);
  7819. if (rc) {
  7820. dev_dbg(dev, "%s: No DT match VA Macro codec\n",
  7821. __func__);
  7822. } else {
  7823. if (va_bolero_codec) {
  7824. dev_dbg(dev, "%s(): VA macro in bolero codec present\n",
  7825. __func__);
  7826. memcpy(msm_qcs405_dai_links + total_links,
  7827. msm_va_cdc_dma_be_dai_links,
  7828. sizeof(msm_va_cdc_dma_be_dai_links));
  7829. total_links +=
  7830. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  7831. }
  7832. }
  7833. if (wsa_bolero_codec) {
  7834. dev_dbg(dev, "%s(): WSAmacro in bolero codec present\n",
  7835. __func__);
  7836. memcpy(msm_qcs405_dai_links + total_links,
  7837. msm_wsa_cdc_dma_be_dai_links,
  7838. sizeof(msm_wsa_cdc_dma_be_dai_links));
  7839. total_links +=
  7840. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  7841. }
  7842. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  7843. &mi2s_audio_intf);
  7844. if (rc) {
  7845. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  7846. __func__);
  7847. } else {
  7848. if (mi2s_audio_intf) {
  7849. memcpy(msm_qcs405_dai_links + total_links,
  7850. msm_mi2s_be_dai_links,
  7851. sizeof(msm_mi2s_be_dai_links));
  7852. total_links +=
  7853. ARRAY_SIZE(msm_mi2s_be_dai_links);
  7854. }
  7855. }
  7856. rc = of_property_read_u32(dev->of_node, "qcom,meta-mi2s-intf",
  7857. &meta_mi2s_intf);
  7858. if (rc) {
  7859. dev_dbg(dev, "%s: No DT match META-MI2S interface\n",
  7860. __func__);
  7861. } else {
  7862. if (meta_mi2s_intf) {
  7863. memcpy(msm_qcs405_dai_links + total_links,
  7864. msm_meta_mi2s_be_dai_links,
  7865. sizeof(msm_meta_mi2s_be_dai_links));
  7866. total_links +=
  7867. ARRAY_SIZE(msm_meta_mi2s_be_dai_links);
  7868. }
  7869. }
  7870. rc = of_property_read_u32(dev->of_node,
  7871. "qcom,auxpcm-audio-intf",
  7872. &auxpcm_audio_intf);
  7873. if (rc) {
  7874. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  7875. __func__);
  7876. } else {
  7877. if (auxpcm_audio_intf) {
  7878. memcpy(msm_qcs405_dai_links + total_links,
  7879. msm_auxpcm_be_dai_links,
  7880. sizeof(msm_auxpcm_be_dai_links));
  7881. total_links +=
  7882. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  7883. }
  7884. }
  7885. rc = of_property_read_u32(dev->of_node, "qcom,spdif-audio-intf",
  7886. &spdif_audio_intf);
  7887. if (rc) {
  7888. dev_dbg(dev, "%s: No DT match SPDIF audio interface\n",
  7889. __func__);
  7890. } else {
  7891. if (spdif_audio_intf) {
  7892. memcpy(msm_qcs405_dai_links + total_links,
  7893. msm_spdif_be_dai_links,
  7894. sizeof(msm_spdif_be_dai_links));
  7895. total_links +=
  7896. ARRAY_SIZE(msm_spdif_be_dai_links);
  7897. /* enable spdif coax pins */
  7898. spdif_cfg = ioremap(TLMM_EAST_SPARE, 0x4);
  7899. spdif_pin_ctl =
  7900. ioremap(TLMM_SPDIF_HDMI_ARC_CTL, 0x4);
  7901. iowrite32(0xc0, spdif_cfg);
  7902. iowrite32(0x2220, spdif_pin_ctl);
  7903. }
  7904. }
  7905. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  7906. &wcn_audio_intf);
  7907. if (rc) {
  7908. dev_dbg(dev, "%s: No DT match WCN audio interface\n",
  7909. __func__);
  7910. } else {
  7911. if (wcn_audio_intf) {
  7912. memcpy(msm_qcs405_dai_links + total_links,
  7913. msm_wcn_be_dai_links,
  7914. sizeof(msm_wcn_be_dai_links));
  7915. total_links +=
  7916. ARRAY_SIZE(msm_wcn_be_dai_links);
  7917. }
  7918. }
  7919. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  7920. &afe_loopback_intf);
  7921. if (rc) {
  7922. dev_dbg(dev, "%s: No DT match AFE loopback audio interface\n",
  7923. __func__);
  7924. } else {
  7925. if (afe_loopback_intf) {
  7926. memcpy(msm_qcs405_dai_links + total_links,
  7927. msm_afe_rxtx_lb_be_dai_link,
  7928. sizeof(msm_afe_rxtx_lb_be_dai_link));
  7929. total_links +=
  7930. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  7931. }
  7932. }
  7933. dailink = msm_qcs405_dai_links;
  7934. } else if (!strcmp(match->data, "stub_codec")) {
  7935. card = &snd_soc_card_stub_msm;
  7936. memcpy(msm_stub_dai_links + total_links,
  7937. msm_stub_fe_dai_links,
  7938. sizeof(msm_stub_fe_dai_links));
  7939. total_links += ARRAY_SIZE(msm_stub_fe_dai_links);
  7940. memcpy(msm_stub_dai_links + total_links,
  7941. msm_stub_be_dai_links,
  7942. sizeof(msm_stub_be_dai_links));
  7943. total_links += ARRAY_SIZE(msm_stub_be_dai_links);
  7944. dailink = msm_stub_dai_links;
  7945. }
  7946. if (card) {
  7947. card->dai_link = dailink;
  7948. card->num_links = total_links;
  7949. }
  7950. return card;
  7951. }
  7952. static int msm_wsa881x_init(struct snd_soc_component *component)
  7953. {
  7954. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  7955. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  7956. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  7957. SPKR_L_BOOST, SPKR_L_VI};
  7958. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  7959. SPKR_R_BOOST, SPKR_R_VI};
  7960. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  7961. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  7962. struct msm_asoc_mach_data *pdata;
  7963. struct snd_soc_dapm_context *dapm;
  7964. int ret = 0;
  7965. if (!component) {
  7966. pr_err("%s component is NULL\n", __func__);
  7967. return -EINVAL;
  7968. }
  7969. dapm = snd_soc_component_get_dapm(component);
  7970. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  7971. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  7972. __func__, component->name);
  7973. wsa881x_set_channel_map(component, &spkleft_ports[0],
  7974. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  7975. &ch_rate[0], &spkleft_port_types[0]);
  7976. if (dapm->component) {
  7977. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  7978. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  7979. }
  7980. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  7981. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  7982. __func__, component->name);
  7983. wsa881x_set_channel_map(component, &spkright_ports[0],
  7984. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  7985. &ch_rate[0], &spkright_port_types[0]);
  7986. if (dapm->component) {
  7987. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  7988. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  7989. }
  7990. } else {
  7991. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  7992. component->name);
  7993. ret = -EINVAL;
  7994. goto err;
  7995. }
  7996. pdata = snd_soc_card_get_drvdata(component->card);
  7997. if (pdata && pdata->codec_root)
  7998. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  7999. component);
  8000. err:
  8001. return ret;
  8002. }
  8003. static int msm_init_wsa_dev(struct platform_device *pdev,
  8004. struct snd_soc_card *card)
  8005. {
  8006. struct device_node *wsa_of_node;
  8007. u32 wsa_max_devs;
  8008. u32 wsa_dev_cnt;
  8009. int i;
  8010. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  8011. const char *wsa_auxdev_name_prefix[1];
  8012. char *dev_name_str = NULL;
  8013. int found = 0;
  8014. int ret = 0;
  8015. /* Get maximum WSA device count for this platform */
  8016. ret = of_property_read_u32(pdev->dev.of_node,
  8017. "qcom,wsa-max-devs", &wsa_max_devs);
  8018. if (ret) {
  8019. dev_info(&pdev->dev,
  8020. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  8021. __func__, pdev->dev.of_node->full_name, ret);
  8022. card->num_aux_devs = 0;
  8023. return 0;
  8024. }
  8025. if (wsa_max_devs == 0) {
  8026. dev_warn(&pdev->dev,
  8027. "%s: Max WSA devices is 0 for this target?\n",
  8028. __func__);
  8029. card->num_aux_devs = 0;
  8030. return 0;
  8031. }
  8032. /* Get count of WSA device phandles for this platform */
  8033. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  8034. "qcom,wsa-devs", NULL);
  8035. if (wsa_dev_cnt == -ENOENT) {
  8036. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  8037. __func__);
  8038. goto err;
  8039. } else if (wsa_dev_cnt <= 0) {
  8040. dev_err(&pdev->dev,
  8041. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  8042. __func__, wsa_dev_cnt);
  8043. ret = -EINVAL;
  8044. goto err;
  8045. }
  8046. /*
  8047. * Expect total phandles count to be NOT less than maximum possible
  8048. * WSA count. However, if it is less, then assign same value to
  8049. * max count as well.
  8050. */
  8051. if (wsa_dev_cnt < wsa_max_devs) {
  8052. dev_dbg(&pdev->dev,
  8053. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  8054. __func__, wsa_max_devs, wsa_dev_cnt);
  8055. wsa_max_devs = wsa_dev_cnt;
  8056. }
  8057. /* Make sure prefix string passed for each WSA device */
  8058. ret = of_property_count_strings(pdev->dev.of_node,
  8059. "qcom,wsa-aux-dev-prefix");
  8060. if (ret != wsa_dev_cnt) {
  8061. dev_err(&pdev->dev,
  8062. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  8063. __func__, wsa_dev_cnt, ret);
  8064. ret = -EINVAL;
  8065. goto err;
  8066. }
  8067. /*
  8068. * Alloc mem to store phandle and index info of WSA device, if already
  8069. * registered with ALSA core
  8070. */
  8071. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  8072. sizeof(struct msm_wsa881x_dev_info),
  8073. GFP_KERNEL);
  8074. if (!wsa881x_dev_info) {
  8075. ret = -ENOMEM;
  8076. goto err;
  8077. }
  8078. /*
  8079. * search and check whether all WSA devices are already
  8080. * registered with ALSA core or not. If found a node, store
  8081. * the node and the index in a local array of struct for later
  8082. * use.
  8083. */
  8084. for (i = 0; i < wsa_dev_cnt; i++) {
  8085. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  8086. "qcom,wsa-devs", i);
  8087. if (unlikely(!wsa_of_node)) {
  8088. /* we should not be here */
  8089. dev_err(&pdev->dev,
  8090. "%s: wsa dev node is not present\n",
  8091. __func__);
  8092. ret = -EINVAL;
  8093. goto err_free_dev_info;
  8094. }
  8095. if (soc_find_component(wsa_of_node, NULL)) {
  8096. /* WSA device registered with ALSA core */
  8097. wsa881x_dev_info[found].of_node = wsa_of_node;
  8098. wsa881x_dev_info[found].index = i;
  8099. found++;
  8100. if (found == wsa_max_devs)
  8101. break;
  8102. }
  8103. }
  8104. if (found < wsa_max_devs) {
  8105. dev_err(&pdev->dev,
  8106. "%s: failed to find %d components. Found only %d\n",
  8107. __func__, wsa_max_devs, found);
  8108. return -EPROBE_DEFER;
  8109. }
  8110. dev_info(&pdev->dev,
  8111. "%s: found %d wsa881x devices registered with ALSA core\n",
  8112. __func__, found);
  8113. card->num_aux_devs = wsa_max_devs;
  8114. card->num_configs = wsa_max_devs;
  8115. /* Alloc array of AUX devs struct */
  8116. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8117. sizeof(struct snd_soc_aux_dev),
  8118. GFP_KERNEL);
  8119. if (!msm_aux_dev) {
  8120. ret = -ENOMEM;
  8121. goto err_free_dev_info;
  8122. }
  8123. /* Alloc array of codec conf struct */
  8124. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8125. sizeof(struct snd_soc_codec_conf),
  8126. GFP_KERNEL);
  8127. if (!msm_codec_conf) {
  8128. ret = -ENOMEM;
  8129. goto err_free_aux_dev;
  8130. }
  8131. for (i = 0; i < card->num_aux_devs; i++) {
  8132. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  8133. GFP_KERNEL);
  8134. if (!dev_name_str) {
  8135. ret = -ENOMEM;
  8136. goto err_free_cdc_conf;
  8137. }
  8138. ret = of_property_read_string_index(pdev->dev.of_node,
  8139. "qcom,wsa-aux-dev-prefix",
  8140. wsa881x_dev_info[i].index,
  8141. wsa_auxdev_name_prefix);
  8142. if (ret) {
  8143. dev_err(&pdev->dev,
  8144. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  8145. __func__, ret);
  8146. ret = -EINVAL;
  8147. goto err_free_dev_name_str;
  8148. }
  8149. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  8150. msm_aux_dev[i].name = dev_name_str;
  8151. msm_aux_dev[i].codec_name = NULL;
  8152. msm_aux_dev[i].codec_of_node =
  8153. wsa881x_dev_info[i].of_node;
  8154. msm_aux_dev[i].init = msm_wsa881x_init;
  8155. msm_codec_conf[i].dev_name = NULL;
  8156. msm_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
  8157. msm_codec_conf[i].of_node =
  8158. wsa881x_dev_info[i].of_node;
  8159. }
  8160. card->codec_conf = msm_codec_conf;
  8161. card->aux_dev = msm_aux_dev;
  8162. return 0;
  8163. err_free_dev_name_str:
  8164. devm_kfree(&pdev->dev, dev_name_str);
  8165. err_free_cdc_conf:
  8166. devm_kfree(&pdev->dev, msm_codec_conf);
  8167. err_free_aux_dev:
  8168. devm_kfree(&pdev->dev, msm_aux_dev);
  8169. err_free_dev_info:
  8170. devm_kfree(&pdev->dev, wsa881x_dev_info);
  8171. err:
  8172. return ret;
  8173. }
  8174. static int msm_csra66x0_init(struct snd_soc_component *component)
  8175. {
  8176. if (!component) {
  8177. pr_err("%s component is NULL\n", __func__);
  8178. return -EINVAL;
  8179. }
  8180. return 0;
  8181. }
  8182. static int msm_init_csra_dev(struct platform_device *pdev,
  8183. struct snd_soc_card *card)
  8184. {
  8185. struct device_node *csra_of_node;
  8186. u32 csra_max_devs;
  8187. u32 csra_dev_cnt;
  8188. char *dev_name_str = NULL;
  8189. struct msm_csra66x0_dev_info *csra66x0_dev_info;
  8190. const char *csra_auxdev_name_prefix[1];
  8191. int i;
  8192. int found = 0;
  8193. int ret = 0;
  8194. /* Get maximum CSRA device count for this platform */
  8195. ret = of_property_read_u32(pdev->dev.of_node,
  8196. "qcom,csra-max-devs", &csra_max_devs);
  8197. if (ret) {
  8198. dev_info(&pdev->dev,
  8199. "%s: csra-max-devs property missing in DT %s, ret = %d\n",
  8200. __func__, pdev->dev.of_node->full_name, ret);
  8201. card->num_aux_devs = 0;
  8202. return 0;
  8203. }
  8204. if (csra_max_devs == 0) {
  8205. dev_warn(&pdev->dev,
  8206. "%s: Max CSRA devices is 0 for this target?\n",
  8207. __func__);
  8208. return 0;
  8209. }
  8210. /* Get count of CSRA device phandles for this platform */
  8211. csra_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  8212. "qcom,csra-devs", NULL);
  8213. if (csra_dev_cnt == -ENOENT) {
  8214. dev_warn(&pdev->dev, "%s: No csra device defined in DT.\n",
  8215. __func__);
  8216. goto err;
  8217. } else if (csra_dev_cnt <= 0) {
  8218. dev_err(&pdev->dev,
  8219. "%s: Error reading csra device from DT. csra_dev_cnt = %d\n",
  8220. __func__, csra_dev_cnt);
  8221. ret = -EINVAL;
  8222. goto err;
  8223. }
  8224. /*
  8225. * Expect total phandles count to be NOT less than maximum possible
  8226. * CSRA count. However, if it is less, then assign same value to
  8227. * max count as well.
  8228. */
  8229. if (csra_dev_cnt < csra_max_devs) {
  8230. dev_dbg(&pdev->dev,
  8231. "%s: csra_max_devs = %d cannot exceed csra_dev_cnt = %d\n",
  8232. __func__, csra_max_devs, csra_dev_cnt);
  8233. csra_max_devs = csra_dev_cnt;
  8234. }
  8235. /* Make sure prefix string passed for each CSRA device */
  8236. ret = of_property_count_strings(pdev->dev.of_node,
  8237. "qcom,csra-aux-dev-prefix");
  8238. if (ret != csra_dev_cnt) {
  8239. dev_err(&pdev->dev,
  8240. "%s: expecting %d csra prefix. Defined only %d in DT\n",
  8241. __func__, csra_dev_cnt, ret);
  8242. ret = -EINVAL;
  8243. goto err;
  8244. }
  8245. /*
  8246. * Alloc mem to store phandle and index info of CSRA device, if already
  8247. * registered with ALSA core
  8248. */
  8249. csra66x0_dev_info = devm_kcalloc(&pdev->dev, csra_max_devs,
  8250. sizeof(struct msm_csra66x0_dev_info),
  8251. GFP_KERNEL);
  8252. if (!csra66x0_dev_info) {
  8253. ret = -ENOMEM;
  8254. goto err;
  8255. }
  8256. /*
  8257. * search and check whether all CSRA devices are already
  8258. * registered with ALSA core or not. If found a node, store
  8259. * the node and the index in a local array of struct for later
  8260. * use.
  8261. */
  8262. for (i = 0; i < csra_dev_cnt; i++) {
  8263. csra_of_node = of_parse_phandle(pdev->dev.of_node,
  8264. "qcom,csra-devs", i);
  8265. if (unlikely(!csra_of_node)) {
  8266. /* we should not be here */
  8267. dev_err(&pdev->dev,
  8268. "%s: csra dev node is not present\n",
  8269. __func__);
  8270. ret = -EINVAL;
  8271. goto err_free_dev_info;
  8272. }
  8273. if (soc_find_component(csra_of_node, NULL)) {
  8274. /* CSRA device registered with ALSA core */
  8275. csra66x0_dev_info[found].of_node = csra_of_node;
  8276. csra66x0_dev_info[found].index = i;
  8277. found++;
  8278. if (found == csra_max_devs)
  8279. break;
  8280. }
  8281. }
  8282. if (found < csra_max_devs) {
  8283. dev_dbg(&pdev->dev,
  8284. "%s: failed to find %d components. Found only %d\n",
  8285. __func__, csra_max_devs, found);
  8286. return -EPROBE_DEFER;
  8287. }
  8288. dev_info(&pdev->dev,
  8289. "%s: found %d csra66x0 devices registered with ALSA core\n",
  8290. __func__, found);
  8291. card->num_aux_devs = csra_max_devs;
  8292. card->num_configs = csra_max_devs;
  8293. /* Alloc array of AUX devs struct */
  8294. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8295. sizeof(struct snd_soc_aux_dev), GFP_KERNEL);
  8296. if (!msm_aux_dev) {
  8297. ret = -ENOMEM;
  8298. goto err_free_dev_info;
  8299. }
  8300. /* Alloc array of codec conf struct */
  8301. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8302. sizeof(struct snd_soc_codec_conf), GFP_KERNEL);
  8303. if (!msm_codec_conf) {
  8304. ret = -ENOMEM;
  8305. goto err_free_aux_dev;
  8306. }
  8307. for (i = 0; i < card->num_aux_devs; i++) {
  8308. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  8309. GFP_KERNEL);
  8310. if (!dev_name_str) {
  8311. ret = -ENOMEM;
  8312. goto err_free_cdc_conf;
  8313. }
  8314. ret = of_property_read_string_index(pdev->dev.of_node,
  8315. "qcom,csra-aux-dev-prefix",
  8316. csra66x0_dev_info[i].index,
  8317. csra_auxdev_name_prefix);
  8318. if (ret) {
  8319. dev_err(&pdev->dev,
  8320. "%s: failed to read csra aux dev prefix, ret = %d\n",
  8321. __func__, ret);
  8322. ret = -EINVAL;
  8323. goto err_free_dev_name_str;
  8324. }
  8325. snprintf(dev_name_str, strlen("csra66x0.%d"), "csra66x0.%d", i);
  8326. msm_aux_dev[i].name = dev_name_str;
  8327. msm_aux_dev[i].codec_name = NULL;
  8328. msm_aux_dev[i].codec_of_node =
  8329. csra66x0_dev_info[i].of_node;
  8330. msm_aux_dev[i].init = msm_csra66x0_init; /* codec specific init */
  8331. msm_codec_conf[i].dev_name = NULL;
  8332. msm_codec_conf[i].name_prefix = csra_auxdev_name_prefix[0];
  8333. msm_codec_conf[i].of_node = csra66x0_dev_info[i].of_node;
  8334. }
  8335. card->codec_conf = msm_codec_conf;
  8336. card->aux_dev = msm_aux_dev;
  8337. return 0;
  8338. err_free_dev_name_str:
  8339. devm_kfree(&pdev->dev, dev_name_str);
  8340. err_free_cdc_conf:
  8341. devm_kfree(&pdev->dev, msm_codec_conf);
  8342. err_free_aux_dev:
  8343. devm_kfree(&pdev->dev, msm_aux_dev);
  8344. err_free_dev_info:
  8345. devm_kfree(&pdev->dev, csra66x0_dev_info);
  8346. err:
  8347. return ret;
  8348. }
  8349. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  8350. {
  8351. int count;
  8352. u32 mi2s_master_slave[MI2S_MAX];
  8353. int ret;
  8354. for (count = 0; count < MI2S_MAX; count++) {
  8355. mutex_init(&mi2s_intf_conf[count].lock);
  8356. mi2s_intf_conf[count].ref_cnt = 0;
  8357. }
  8358. ret = of_property_read_u32_array(pdev->dev.of_node,
  8359. "qcom,msm-mi2s-master",
  8360. mi2s_master_slave, MI2S_MAX);
  8361. if (ret) {
  8362. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  8363. __func__);
  8364. } else {
  8365. for (count = 0; count < MI2S_MAX; count++) {
  8366. mi2s_intf_conf[count].msm_is_mi2s_master =
  8367. mi2s_master_slave[count];
  8368. }
  8369. }
  8370. }
  8371. static void msm_i2s_auxpcm_deinit(void)
  8372. {
  8373. int count;
  8374. for (count = 0; count < MI2S_MAX; count++) {
  8375. mutex_destroy(&mi2s_intf_conf[count].lock);
  8376. mi2s_intf_conf[count].ref_cnt = 0;
  8377. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  8378. }
  8379. }
  8380. static void msm_meta_mi2s_init(struct platform_device *pdev)
  8381. {
  8382. int rc = 0;
  8383. int i = 0;
  8384. int index = 0;
  8385. bool parse_of = false;
  8386. struct snd_soc_card *card = platform_get_drvdata(pdev);
  8387. struct snd_soc_dai_link *dai_link = card->dai_link;
  8388. dev_dbg(&pdev->dev, "%s: read from DT\n", __func__);
  8389. for (index = 0; index < META_MI2S_MAX; index++) {
  8390. meta_mi2s_intf_conf[index].num_member_ports = 0;
  8391. meta_mi2s_intf_conf[index].member_port[0] = 0;
  8392. meta_mi2s_intf_conf[index].member_port[1] = 0;
  8393. meta_mi2s_intf_conf[index].member_port[2] = 0;
  8394. meta_mi2s_intf_conf[index].member_port[3] = 0;
  8395. meta_mi2s_intf_conf[index].clk_enable[0] = false;
  8396. meta_mi2s_intf_conf[index].clk_enable[1] = false;
  8397. meta_mi2s_intf_conf[index].clk_enable[2] = false;
  8398. meta_mi2s_intf_conf[index].clk_enable[3] = false;
  8399. }
  8400. /* get member port info to set matching clocks for involved ports */
  8401. for (i = 0; i < card->num_links; i++) {
  8402. if (dai_link[i].id == MSM_BACKEND_DAI_PRI_META_MI2S_RX) {
  8403. parse_of = true;
  8404. index = PRIM_META_MI2S;
  8405. } else if (dai_link[i].id == MSM_BACKEND_DAI_SEC_META_MI2S_RX) {
  8406. parse_of = true;
  8407. index = SEC_META_MI2S;
  8408. } else {
  8409. parse_of = false;
  8410. }
  8411. if (parse_of && dai_link[i].cpu_of_node) {
  8412. rc = of_property_read_u32(dai_link[i].cpu_of_node,
  8413. "qcom,msm-mi2s-num-members",
  8414. &meta_mi2s_intf_conf[index].num_member_ports);
  8415. if (rc) {
  8416. dev_err(&pdev->dev, "%s: invalid num from DT file %s\n",
  8417. __func__, "qcom,msm-mi2s-num-members");
  8418. }
  8419. if (meta_mi2s_intf_conf[index].num_member_ports >
  8420. MAX_NUM_I2S_META_PORT_MEMBER_PORTS) {
  8421. dev_err(&pdev->dev, "%s: num-members %d too large from DT file\n",
  8422. __func__,
  8423. meta_mi2s_intf_conf[index].num_member_ports);
  8424. }
  8425. if (meta_mi2s_intf_conf[index].num_member_ports > 0) {
  8426. rc = of_property_read_u32_array(
  8427. dai_link[i].cpu_of_node,
  8428. "qcom,msm-mi2s-member-id",
  8429. meta_mi2s_intf_conf[index].member_port,
  8430. meta_mi2s_intf_conf[index].num_member_ports);
  8431. if (rc) {
  8432. dev_err(&pdev->dev, "%s: member-id from DT file %s\n",
  8433. __func__,
  8434. "qcom,msm-mi2s-member-id");
  8435. }
  8436. }
  8437. dev_dbg(&pdev->dev, "dev name %s num-members=%d\n",
  8438. dev_name(&pdev->dev),
  8439. meta_mi2s_intf_conf[index].num_member_ports);
  8440. dev_dbg(&pdev->dev, "member array (%d, %d, %d, %d)\n",
  8441. meta_mi2s_intf_conf[index].member_port[0],
  8442. meta_mi2s_intf_conf[index].member_port[1],
  8443. meta_mi2s_intf_conf[index].member_port[2],
  8444. meta_mi2s_intf_conf[index].member_port[3]);
  8445. }
  8446. }
  8447. }
  8448. static int msm_scan_i2c_addr(struct platform_device *pdev,
  8449. uint32_t busnum, uint32_t addr)
  8450. {
  8451. struct i2c_adapter *adap;
  8452. u8 rbuf;
  8453. struct i2c_msg msg;
  8454. int status = 0;
  8455. adap = i2c_get_adapter(busnum);
  8456. if (!adap) {
  8457. dev_err(&pdev->dev, "%s: Cannot get I2C adapter %d\n",
  8458. __func__, busnum);
  8459. return -EBUSY;
  8460. }
  8461. /* to test presence, read one byte from device */
  8462. msg.addr = addr;
  8463. msg.flags = I2C_M_RD;
  8464. msg.len = 1;
  8465. msg.buf = &rbuf;
  8466. status = i2c_transfer(adap, &msg, 1);
  8467. i2c_put_adapter(adap);
  8468. if (status != 1) {
  8469. dev_dbg(&pdev->dev, "%s: I2C read from addr 0x%02x failed\n",
  8470. __func__, addr);
  8471. return -ENODEV;
  8472. }
  8473. dev_dbg(&pdev->dev, "%s: I2C read from addr 0x%02x successful\n",
  8474. __func__, addr);
  8475. return 0;
  8476. }
  8477. static int msm_detect_ep92_dev(struct platform_device *pdev,
  8478. struct snd_soc_card *card)
  8479. {
  8480. int i;
  8481. uint32_t ep92_busnum = 0;
  8482. uint32_t ep92_reg = 0;
  8483. const char *ep92_name = NULL;
  8484. struct snd_soc_dai_link *dai;
  8485. int rc = 0;
  8486. rc = of_property_read_u32(pdev->dev.of_node, "qcom,ep92-busnum",
  8487. &ep92_busnum);
  8488. if (rc) {
  8489. dev_info(&pdev->dev, "%s: No DT match ep92-reg\n", __func__);
  8490. return 0;
  8491. }
  8492. rc = of_property_read_u32(pdev->dev.of_node, "qcom,ep92-reg",
  8493. &ep92_reg);
  8494. if (rc) {
  8495. dev_info(&pdev->dev, "%s: No DT match ep92-busnum\n", __func__);
  8496. return 0;
  8497. }
  8498. rc = of_property_read_string(pdev->dev.of_node, "qcom,ep92-name",
  8499. &ep92_name);
  8500. if (rc) {
  8501. dev_info(&pdev->dev, "%s: No DT match ep92-name\n", __func__);
  8502. return 0;
  8503. }
  8504. /* check I2C bus for connected ep92 chip */
  8505. if (msm_scan_i2c_addr(pdev, ep92_busnum, ep92_reg) < 0) {
  8506. /* check a second time after a short delay */
  8507. msleep(20);
  8508. if (msm_scan_i2c_addr(pdev, ep92_busnum, ep92_reg) < 0) {
  8509. dev_info(&pdev->dev, "%s: No ep92 device found\n",
  8510. __func__);
  8511. /* continue with snd_card registration without ep92 */
  8512. return 0;
  8513. }
  8514. }
  8515. dev_info(&pdev->dev, "%s: ep92 device found\n", __func__);
  8516. /* update codec info in MI2S dai link */
  8517. dai = &msm_mi2s_be_dai_links[0];
  8518. for (i=0; i<ARRAY_SIZE(msm_mi2s_be_dai_links); i++) {
  8519. if (strcmp(dai->name, LPASS_BE_SEC_MI2S_TX) == 0) {
  8520. dev_dbg(&pdev->dev,
  8521. "%s: Set Sec MI2S dai to ep92 codec\n",
  8522. __func__);
  8523. dai->codec_name = ep92_name;
  8524. dai->codec_dai_name = "ep92-hdmi";
  8525. break;
  8526. }
  8527. dai++;
  8528. }
  8529. /* update codec info in SPDIF dai link */
  8530. dai = &msm_spdif_be_dai_links[0];
  8531. for (i=0; i<ARRAY_SIZE(msm_spdif_be_dai_links); i++) {
  8532. if (strcmp(dai->name, LPASS_BE_SEC_SPDIF_TX) == 0) {
  8533. dev_dbg(&pdev->dev,
  8534. "%s: Set Sec SPDIF dai to ep92 codec\n",
  8535. __func__);
  8536. dai->codec_name = ep92_name;
  8537. dai->codec_dai_name = "ep92-arc";
  8538. break;
  8539. }
  8540. dai++;
  8541. }
  8542. return 0;
  8543. }
  8544. static int msm_asoc_machine_probe(struct platform_device *pdev)
  8545. {
  8546. struct snd_soc_card *card;
  8547. struct msm_asoc_mach_data *pdata;
  8548. int ret;
  8549. u32 val;
  8550. const char *micb_supply_str = "tdm-vdd-micb-supply";
  8551. const char *micb_supply_str1 = "tdm-vdd-micb";
  8552. const char *micb_voltage_str = "qcom,tdm-vdd-micb-voltage";
  8553. const char *micb_current_str = "qcom,tdm-vdd-micb-current";
  8554. if (!pdev->dev.of_node) {
  8555. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  8556. return -EINVAL;
  8557. }
  8558. pdata = devm_kzalloc(&pdev->dev,
  8559. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  8560. if (!pdata)
  8561. return -ENOMEM;
  8562. /* test for ep92 HDMI bridge and update dai links accordingly */
  8563. ret = msm_detect_ep92_dev(pdev, card);
  8564. if (ret)
  8565. goto err;
  8566. card = populate_snd_card_dailinks(&pdev->dev);
  8567. if (!card) {
  8568. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  8569. ret = -EINVAL;
  8570. goto err;
  8571. }
  8572. card->dev = &pdev->dev;
  8573. platform_set_drvdata(pdev, card);
  8574. snd_soc_card_set_drvdata(card, pdata);
  8575. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  8576. if (ret) {
  8577. dev_err(&pdev->dev, "parse card name failed, err:%d\n",
  8578. ret);
  8579. goto err;
  8580. }
  8581. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  8582. if (ret) {
  8583. dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
  8584. ret);
  8585. goto err;
  8586. }
  8587. ret = msm_populate_dai_link_component_of_node(card);
  8588. if (ret) {
  8589. ret = -EPROBE_DEFER;
  8590. goto err;
  8591. }
  8592. ret = of_property_read_u32(pdev->dev.of_node, "qcom,csra-codec", &val);
  8593. if (ret) {
  8594. dev_info(&pdev->dev, "no 'qcom,csra-codec' in DT\n");
  8595. val = 0;
  8596. }
  8597. if (val) {
  8598. pdata->codec_is_csra = true;
  8599. mi2s_rx_cfg[PRIM_MI2S].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  8600. meta_mi2s_rx_cfg[PRIM_META_MI2S].bit_format =
  8601. SNDRV_PCM_FORMAT_S24_LE;
  8602. ret = msm_init_csra_dev(pdev, card);
  8603. if (ret)
  8604. goto err;
  8605. } else {
  8606. pdata->codec_is_csra = false;
  8607. ret = msm_init_wsa_dev(pdev, card);
  8608. if (ret)
  8609. goto err;
  8610. }
  8611. pdata->dmic_01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8612. "qcom,cdc-dmic01-gpios", 0);
  8613. pdata->dmic_23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8614. "qcom,cdc-dmic23-gpios", 0);
  8615. pdata->dmic_45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8616. "qcom,cdc-dmic45-gpios", 0);
  8617. pdata->dmic_67_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8618. "qcom,cdc-dmic67-gpios", 0);
  8619. pdata->lineout_booster_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8620. "qcom,lineout-booster-gpio", 0);
  8621. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8622. "qcom,pri-mi2s-gpios", 0);
  8623. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8624. "qcom,sec-mi2s-gpios", 0);
  8625. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8626. "qcom,tert-mi2s-gpios", 0);
  8627. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8628. "qcom,quat-mi2s-gpios", 0);
  8629. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8630. "qcom,quin-mi2s-gpios", 0);
  8631. if (of_parse_phandle(pdev->dev.of_node, micb_supply_str, 0)) {
  8632. pdata->tdm_micb_supply = devm_regulator_get(&pdev->dev,
  8633. micb_supply_str1);
  8634. if (IS_ERR(pdata->tdm_micb_supply)) {
  8635. ret = PTR_ERR(pdata->tdm_micb_supply);
  8636. dev_err(&pdev->dev,
  8637. "%s:Failed to get micbias supply for TDM Mic %d\n",
  8638. __func__, ret);
  8639. }
  8640. ret = of_property_read_u32(pdev->dev.of_node,
  8641. micb_voltage_str,
  8642. &pdata->tdm_micb_voltage);
  8643. if (ret) {
  8644. dev_err(&pdev->dev,
  8645. "%s:Looking up %s property in node %s failed\n",
  8646. __func__, micb_voltage_str,
  8647. pdev->dev.of_node->full_name);
  8648. }
  8649. ret = of_property_read_u32(pdev->dev.of_node,
  8650. micb_current_str,
  8651. &pdata->tdm_micb_current);
  8652. if (ret) {
  8653. dev_err(&pdev->dev,
  8654. "%s:Looking up %s property in node %s failed\n",
  8655. __func__, micb_current_str,
  8656. pdev->dev.of_node->full_name);
  8657. }
  8658. }
  8659. ret = devm_snd_soc_register_card(&pdev->dev, card);
  8660. if (ret == -EPROBE_DEFER) {
  8661. if (codec_reg_done)
  8662. ret = -EINVAL;
  8663. goto err;
  8664. } else if (ret) {
  8665. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  8666. ret);
  8667. goto err;
  8668. }
  8669. dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
  8670. spdev = pdev;
  8671. ret = msm_mdf_mem_init();
  8672. if (ret)
  8673. dev_err(&pdev->dev, "msm_mdf_mem_init failed (%d)\n",
  8674. ret);
  8675. msm_i2s_auxpcm_init(pdev);
  8676. msm_meta_mi2s_init(pdev);
  8677. is_initial_boot = true;
  8678. return 0;
  8679. err:
  8680. return ret;
  8681. }
  8682. static int msm_asoc_machine_remove(struct platform_device *pdev)
  8683. {
  8684. audio_notifier_deregister("qcs405");
  8685. msm_i2s_auxpcm_deinit();
  8686. msm_mdf_mem_deinit();
  8687. return 0;
  8688. }
  8689. static struct platform_driver qcs405_asoc_machine_driver = {
  8690. .driver = {
  8691. .name = DRV_NAME,
  8692. .owner = THIS_MODULE,
  8693. .pm = &snd_soc_pm_ops,
  8694. .of_match_table = qcs405_asoc_machine_of_match,
  8695. .suppress_bind_attrs = true,
  8696. },
  8697. .probe = msm_asoc_machine_probe,
  8698. .remove = msm_asoc_machine_remove,
  8699. };
  8700. module_platform_driver(qcs405_asoc_machine_driver);
  8701. MODULE_DESCRIPTION("ALSA SoC QCS405 Machine driver");
  8702. MODULE_LICENSE("GPL v2");
  8703. MODULE_ALIAS("platform:" DRV_NAME);
  8704. MODULE_DEVICE_TABLE(of, qcs405_asoc_machine_of_match);