qcs405.c 239 KB

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