qcs405.c 266 KB

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