kona.c 187 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/delay.h>
  7. #include <linux/gpio.h>
  8. #include <linux/of_gpio.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. #include <linux/io.h>
  12. #include <linux/module.h>
  13. #include <linux/input.h>
  14. #include <linux/of_device.h>
  15. #include <linux/soc/qcom/fsa4480-i2c.h>
  16. #include <sound/core.h>
  17. #include <sound/soc.h>
  18. #include <sound/soc-dapm.h>
  19. #include <sound/pcm.h>
  20. #include <sound/pcm_params.h>
  21. #include <sound/info.h>
  22. #include <soc/snd_event.h>
  23. #include <dsp/audio_notifier.h>
  24. #include <soc/swr-common.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include <dsp/q6core.h>
  27. #include "device_event.h"
  28. #include "msm-pcm-routing-v2.h"
  29. #include "asoc/msm-cdc-pinctrl.h"
  30. #include "asoc/wcd-mbhc-v2.h"
  31. #include "codecs/wcd938x/wcd938x-mbhc.h"
  32. #include "codecs/wsa881x.h"
  33. #include "codecs/wcd938x/wcd938x.h"
  34. #include "codecs/bolero/bolero-cdc.h"
  35. #include <dt-bindings/sound/audio-codec-port-types.h>
  36. #include "codecs/bolero/wsa-macro.h"
  37. #include "kona-port-config.h"
  38. #define DRV_NAME "kona-asoc-snd"
  39. #define __CHIPSET__ "KONA "
  40. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  41. #define SAMPLING_RATE_8KHZ 8000
  42. #define SAMPLING_RATE_11P025KHZ 11025
  43. #define SAMPLING_RATE_16KHZ 16000
  44. #define SAMPLING_RATE_22P05KHZ 22050
  45. #define SAMPLING_RATE_32KHZ 32000
  46. #define SAMPLING_RATE_44P1KHZ 44100
  47. #define SAMPLING_RATE_48KHZ 48000
  48. #define SAMPLING_RATE_88P2KHZ 88200
  49. #define SAMPLING_RATE_96KHZ 96000
  50. #define SAMPLING_RATE_176P4KHZ 176400
  51. #define SAMPLING_RATE_192KHZ 192000
  52. #define SAMPLING_RATE_352P8KHZ 352800
  53. #define SAMPLING_RATE_384KHZ 384000
  54. #define WCD9XXX_MBHC_DEF_RLOADS 5
  55. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  56. #define CODEC_EXT_CLK_RATE 9600000
  57. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  58. #define DEV_NAME_STR_LEN 32
  59. #define WCD_MBHC_HS_V_MAX 1600
  60. #define TDM_CHANNEL_MAX 8
  61. #define DEV_NAME_STR_LEN 32
  62. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  63. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  64. #define WSA8810_NAME_1 "wsa881x.20170211"
  65. #define WSA8810_NAME_2 "wsa881x.20170212"
  66. #define WCN_CDC_SLIM_RX_CH_MAX 2
  67. #define WCN_CDC_SLIM_TX_CH_MAX 2
  68. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  69. enum {
  70. TDM_0 = 0,
  71. TDM_1,
  72. TDM_2,
  73. TDM_3,
  74. TDM_4,
  75. TDM_5,
  76. TDM_6,
  77. TDM_7,
  78. TDM_PORT_MAX,
  79. };
  80. enum {
  81. TDM_PRI = 0,
  82. TDM_SEC,
  83. TDM_TERT,
  84. TDM_INTERFACE_MAX,
  85. };
  86. enum {
  87. PRIM_AUX_PCM = 0,
  88. SEC_AUX_PCM,
  89. TERT_AUX_PCM,
  90. AUX_PCM_MAX,
  91. };
  92. enum {
  93. PRIM_MI2S = 0,
  94. SEC_MI2S,
  95. TERT_MI2S,
  96. MI2S_MAX,
  97. };
  98. enum {
  99. WSA_CDC_DMA_RX_0 = 0,
  100. WSA_CDC_DMA_RX_1,
  101. RX_CDC_DMA_RX_0,
  102. RX_CDC_DMA_RX_1,
  103. RX_CDC_DMA_RX_2,
  104. RX_CDC_DMA_RX_3,
  105. RX_CDC_DMA_RX_5,
  106. CDC_DMA_RX_MAX,
  107. };
  108. enum {
  109. WSA_CDC_DMA_TX_0 = 0,
  110. WSA_CDC_DMA_TX_1,
  111. WSA_CDC_DMA_TX_2,
  112. TX_CDC_DMA_TX_0,
  113. TX_CDC_DMA_TX_3,
  114. TX_CDC_DMA_TX_4,
  115. VA_CDC_DMA_TX_0,
  116. VA_CDC_DMA_TX_1,
  117. VA_CDC_DMA_TX_2,
  118. CDC_DMA_TX_MAX,
  119. };
  120. enum {
  121. SLIM_RX_7 = 0,
  122. SLIM_RX_MAX,
  123. };
  124. enum {
  125. SLIM_TX_7 = 0,
  126. SLIM_TX_8,
  127. SLIM_TX_MAX,
  128. };
  129. enum {
  130. AFE_LOOPBACK_TX_IDX = 0,
  131. AFE_LOOPBACK_TX_IDX_MAX,
  132. };
  133. struct msm_asoc_mach_data {
  134. struct snd_info_entry *codec_root;
  135. int usbc_en2_gpio; /* used by gpio driver API */
  136. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  137. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  138. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  139. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  140. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  141. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  142. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  143. bool is_afe_config_done;
  144. struct device_node *fsa_handle;
  145. };
  146. struct tdm_port {
  147. u32 mode;
  148. u32 channel;
  149. };
  150. enum {
  151. EXT_DISP_RX_IDX_DP = 0,
  152. EXT_DISP_RX_IDX_MAX,
  153. };
  154. struct msm_wsa881x_dev_info {
  155. struct device_node *of_node;
  156. u32 index;
  157. };
  158. struct aux_codec_dev_info {
  159. struct device_node *of_node;
  160. u32 index;
  161. };
  162. struct dev_config {
  163. u32 sample_rate;
  164. u32 bit_format;
  165. u32 channels;
  166. };
  167. /* Default configuration of slimbus channels */
  168. static struct dev_config slim_rx_cfg[] = {
  169. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  170. };
  171. static struct dev_config slim_tx_cfg[] = {
  172. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  173. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  174. };
  175. /* Default configuration of external display BE */
  176. static struct dev_config ext_disp_rx_cfg[] = {
  177. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  178. };
  179. static struct dev_config usb_rx_cfg = {
  180. .sample_rate = SAMPLING_RATE_48KHZ,
  181. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  182. .channels = 2,
  183. };
  184. static struct dev_config usb_tx_cfg = {
  185. .sample_rate = SAMPLING_RATE_48KHZ,
  186. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  187. .channels = 1,
  188. };
  189. static struct dev_config proxy_rx_cfg = {
  190. .sample_rate = SAMPLING_RATE_48KHZ,
  191. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  192. .channels = 2,
  193. };
  194. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  195. {
  196. AFE_API_VERSION_I2S_CONFIG,
  197. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  198. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  199. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  200. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  201. 0,
  202. },
  203. {
  204. AFE_API_VERSION_I2S_CONFIG,
  205. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  206. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  207. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  208. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  209. 0,
  210. },
  211. {
  212. AFE_API_VERSION_I2S_CONFIG,
  213. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  214. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  215. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  216. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  217. 0,
  218. },
  219. };
  220. struct mi2s_conf {
  221. struct mutex lock;
  222. u32 ref_cnt;
  223. u32 msm_is_mi2s_master;
  224. };
  225. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  226. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  227. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  228. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  229. };
  230. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  231. /* Default configuration of TDM channels */
  232. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  233. { /* PRI 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. { /* SEC 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. { /* TERT 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. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  265. { /* PRI TDM */
  266. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  272. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  273. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  274. },
  275. { /* SEC TDM */
  276. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  277. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  278. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  279. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  280. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  281. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  282. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  283. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  284. },
  285. { /* TERT TDM */
  286. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  287. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  288. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  291. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  292. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  294. },
  295. };
  296. /* Default configuration of AUX PCM channels */
  297. static struct dev_config aux_pcm_rx_cfg[] = {
  298. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  299. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  300. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  301. };
  302. static struct dev_config aux_pcm_tx_cfg[] = {
  303. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  304. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  305. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  306. };
  307. /* Default configuration of MI2S channels */
  308. static struct dev_config mi2s_rx_cfg[] = {
  309. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  310. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  311. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  312. };
  313. static struct dev_config mi2s_tx_cfg[] = {
  314. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  315. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  316. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  317. };
  318. /* Default configuration of Codec DMA Interface RX */
  319. static struct dev_config cdc_dma_rx_cfg[] = {
  320. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  321. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  322. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  323. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  324. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  325. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  326. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  327. };
  328. /* Default configuration of Codec DMA Interface TX */
  329. static struct dev_config cdc_dma_tx_cfg[] = {
  330. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  331. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  332. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  333. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  334. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  335. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  336. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  337. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  338. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  339. };
  340. static struct dev_config afe_loopback_tx_cfg[] = {
  341. [AFE_LOOPBACK_TX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  342. };
  343. static int msm_vi_feed_tx_ch = 2;
  344. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  345. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  346. "S32_LE"};
  347. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  348. "Six", "Seven", "Eight"};
  349. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  350. "KHZ_16", "KHZ_22P05",
  351. "KHZ_32", "KHZ_44P1", "KHZ_48",
  352. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  353. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  354. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  355. "Five", "Six", "Seven",
  356. "Eight"};
  357. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  358. "KHZ_48", "KHZ_176P4",
  359. "KHZ_352P8"};
  360. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  361. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  362. "Five", "Six", "Seven", "Eight"};
  363. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  364. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  365. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  366. "KHZ_48", "KHZ_96", "KHZ_192"};
  367. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  368. "Five", "Six", "Seven",
  369. "Eight"};
  370. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  371. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  372. "Five", "Six", "Seven",
  373. "Eight"};
  374. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  375. "KHZ_16", "KHZ_22P05",
  376. "KHZ_32", "KHZ_44P1", "KHZ_48",
  377. "KHZ_88P2", "KHZ_96",
  378. "KHZ_176P4", "KHZ_192",
  379. "KHZ_352P8", "KHZ_384"};
  380. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  381. "S24_3LE"};
  382. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  383. "KHZ_192", "KHZ_32", "KHZ_44P1",
  384. "KHZ_88P2", "KHZ_176P4"};
  385. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  386. "KHZ_44P1", "KHZ_48",
  387. "KHZ_88P2", "KHZ_96"};
  388. static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
  389. "KHZ_44P1", "KHZ_48",
  390. "KHZ_88P2", "KHZ_96"};
  391. static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
  392. "KHZ_44P1", "KHZ_48",
  393. "KHZ_88P2", "KHZ_96"};
  394. static const char *const afe_loopback_tx_ch_text[] = {"One", "Two"};
  395. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  396. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  397. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  398. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  399. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  400. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  401. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  402. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  403. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  404. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  405. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  406. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  407. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  408. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  409. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  410. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  411. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  412. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  413. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  414. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  415. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  416. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  417. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  418. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  419. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  420. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  421. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  422. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  423. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  424. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  425. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  426. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  427. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  428. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  429. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  430. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  431. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  432. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  433. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  434. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  435. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  436. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  437. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  438. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  439. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  440. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  441. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  442. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  443. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  444. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  445. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  446. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  447. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  448. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  449. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_format, bit_format_text);
  450. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_format, bit_format_text);
  451. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_format, bit_format_text);
  452. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_format, bit_format_text);
  453. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_format, bit_format_text);
  454. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  455. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  456. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  457. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  458. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  459. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  460. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  461. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  462. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  463. cdc_dma_sample_rate_text);
  464. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  465. cdc_dma_sample_rate_text);
  466. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_sample_rate,
  467. cdc_dma_sample_rate_text);
  468. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_sample_rate,
  469. cdc_dma_sample_rate_text);
  470. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_sample_rate,
  471. cdc_dma_sample_rate_text);
  472. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_sample_rate,
  473. cdc_dma_sample_rate_text);
  474. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_sample_rate,
  475. cdc_dma_sample_rate_text);
  476. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  477. cdc_dma_sample_rate_text);
  478. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  479. cdc_dma_sample_rate_text);
  480. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  481. cdc_dma_sample_rate_text);
  482. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  483. cdc_dma_sample_rate_text);
  484. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  485. cdc_dma_sample_rate_text);
  486. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  487. cdc_dma_sample_rate_text);
  488. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  489. cdc_dma_sample_rate_text);
  490. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  491. cdc_dma_sample_rate_text);
  492. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  493. cdc_dma_sample_rate_text);
  494. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  495. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  496. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  497. ext_disp_sample_rate_text);
  498. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  499. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
  500. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
  501. static SOC_ENUM_SINGLE_EXT_DECL(afe_loopback_tx_chs, afe_loopback_tx_ch_text);
  502. static bool is_initial_boot;
  503. static bool codec_reg_done;
  504. static struct snd_soc_aux_dev *msm_aux_dev;
  505. static struct snd_soc_codec_conf *msm_codec_conf;
  506. static struct snd_soc_card snd_soc_card_kona_msm;
  507. static int dmic_0_1_gpio_cnt;
  508. static int dmic_2_3_gpio_cnt;
  509. static int dmic_4_5_gpio_cnt;
  510. static void *def_wcd_mbhc_cal(void);
  511. /*
  512. * Need to report LINEIN
  513. * if R/L channel impedance is larger than 5K ohm
  514. */
  515. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  516. .read_fw_bin = false,
  517. .calibration = NULL,
  518. .detect_extn_cable = true,
  519. .mono_stero_detection = false,
  520. .swap_gnd_mic = NULL,
  521. .hs_ext_micbias = true,
  522. .key_code[0] = KEY_MEDIA,
  523. .key_code[1] = KEY_VOICECOMMAND,
  524. .key_code[2] = KEY_VOLUMEUP,
  525. .key_code[3] = KEY_VOLUMEDOWN,
  526. .key_code[4] = 0,
  527. .key_code[5] = 0,
  528. .key_code[6] = 0,
  529. .key_code[7] = 0,
  530. .linein_th = 5000,
  531. .moisture_en = true,
  532. .mbhc_micbias = MIC_BIAS_2,
  533. .anc_micbias = MIC_BIAS_2,
  534. .enable_anc_mic_detect = false,
  535. };
  536. static inline int param_is_mask(int p)
  537. {
  538. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  539. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  540. }
  541. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  542. int n)
  543. {
  544. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  545. }
  546. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  547. unsigned int bit)
  548. {
  549. if (bit >= SNDRV_MASK_MAX)
  550. return;
  551. if (param_is_mask(n)) {
  552. struct snd_mask *m = param_to_mask(p, n);
  553. m->bits[0] = 0;
  554. m->bits[1] = 0;
  555. m->bits[bit >> 5] |= (1 << (bit & 31));
  556. }
  557. }
  558. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  559. struct snd_ctl_elem_value *ucontrol)
  560. {
  561. int sample_rate_val = 0;
  562. switch (usb_rx_cfg.sample_rate) {
  563. case SAMPLING_RATE_384KHZ:
  564. sample_rate_val = 12;
  565. break;
  566. case SAMPLING_RATE_352P8KHZ:
  567. sample_rate_val = 11;
  568. break;
  569. case SAMPLING_RATE_192KHZ:
  570. sample_rate_val = 10;
  571. break;
  572. case SAMPLING_RATE_176P4KHZ:
  573. sample_rate_val = 9;
  574. break;
  575. case SAMPLING_RATE_96KHZ:
  576. sample_rate_val = 8;
  577. break;
  578. case SAMPLING_RATE_88P2KHZ:
  579. sample_rate_val = 7;
  580. break;
  581. case SAMPLING_RATE_48KHZ:
  582. sample_rate_val = 6;
  583. break;
  584. case SAMPLING_RATE_44P1KHZ:
  585. sample_rate_val = 5;
  586. break;
  587. case SAMPLING_RATE_32KHZ:
  588. sample_rate_val = 4;
  589. break;
  590. case SAMPLING_RATE_22P05KHZ:
  591. sample_rate_val = 3;
  592. break;
  593. case SAMPLING_RATE_16KHZ:
  594. sample_rate_val = 2;
  595. break;
  596. case SAMPLING_RATE_11P025KHZ:
  597. sample_rate_val = 1;
  598. break;
  599. case SAMPLING_RATE_8KHZ:
  600. default:
  601. sample_rate_val = 0;
  602. break;
  603. }
  604. ucontrol->value.integer.value[0] = sample_rate_val;
  605. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  606. usb_rx_cfg.sample_rate);
  607. return 0;
  608. }
  609. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  610. struct snd_ctl_elem_value *ucontrol)
  611. {
  612. switch (ucontrol->value.integer.value[0]) {
  613. case 12:
  614. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  615. break;
  616. case 11:
  617. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  618. break;
  619. case 10:
  620. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  621. break;
  622. case 9:
  623. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  624. break;
  625. case 8:
  626. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  627. break;
  628. case 7:
  629. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  630. break;
  631. case 6:
  632. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  633. break;
  634. case 5:
  635. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  636. break;
  637. case 4:
  638. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  639. break;
  640. case 3:
  641. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  642. break;
  643. case 2:
  644. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  645. break;
  646. case 1:
  647. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  648. break;
  649. case 0:
  650. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  651. break;
  652. default:
  653. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  654. break;
  655. }
  656. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  657. __func__, ucontrol->value.integer.value[0],
  658. usb_rx_cfg.sample_rate);
  659. return 0;
  660. }
  661. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  662. struct snd_ctl_elem_value *ucontrol)
  663. {
  664. int sample_rate_val = 0;
  665. switch (usb_tx_cfg.sample_rate) {
  666. case SAMPLING_RATE_384KHZ:
  667. sample_rate_val = 12;
  668. break;
  669. case SAMPLING_RATE_352P8KHZ:
  670. sample_rate_val = 11;
  671. break;
  672. case SAMPLING_RATE_192KHZ:
  673. sample_rate_val = 10;
  674. break;
  675. case SAMPLING_RATE_176P4KHZ:
  676. sample_rate_val = 9;
  677. break;
  678. case SAMPLING_RATE_96KHZ:
  679. sample_rate_val = 8;
  680. break;
  681. case SAMPLING_RATE_88P2KHZ:
  682. sample_rate_val = 7;
  683. break;
  684. case SAMPLING_RATE_48KHZ:
  685. sample_rate_val = 6;
  686. break;
  687. case SAMPLING_RATE_44P1KHZ:
  688. sample_rate_val = 5;
  689. break;
  690. case SAMPLING_RATE_32KHZ:
  691. sample_rate_val = 4;
  692. break;
  693. case SAMPLING_RATE_22P05KHZ:
  694. sample_rate_val = 3;
  695. break;
  696. case SAMPLING_RATE_16KHZ:
  697. sample_rate_val = 2;
  698. break;
  699. case SAMPLING_RATE_11P025KHZ:
  700. sample_rate_val = 1;
  701. break;
  702. case SAMPLING_RATE_8KHZ:
  703. sample_rate_val = 0;
  704. break;
  705. default:
  706. sample_rate_val = 6;
  707. break;
  708. }
  709. ucontrol->value.integer.value[0] = sample_rate_val;
  710. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  711. usb_tx_cfg.sample_rate);
  712. return 0;
  713. }
  714. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  715. struct snd_ctl_elem_value *ucontrol)
  716. {
  717. switch (ucontrol->value.integer.value[0]) {
  718. case 12:
  719. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  720. break;
  721. case 11:
  722. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  723. break;
  724. case 10:
  725. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  726. break;
  727. case 9:
  728. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  729. break;
  730. case 8:
  731. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  732. break;
  733. case 7:
  734. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  735. break;
  736. case 6:
  737. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  738. break;
  739. case 5:
  740. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  741. break;
  742. case 4:
  743. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  744. break;
  745. case 3:
  746. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  747. break;
  748. case 2:
  749. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  750. break;
  751. case 1:
  752. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  753. break;
  754. case 0:
  755. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  756. break;
  757. default:
  758. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  759. break;
  760. }
  761. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  762. __func__, ucontrol->value.integer.value[0],
  763. usb_tx_cfg.sample_rate);
  764. return 0;
  765. }
  766. static int afe_loopback_tx_ch_get(struct snd_kcontrol *kcontrol,
  767. struct snd_ctl_elem_value *ucontrol)
  768. {
  769. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  770. afe_loopback_tx_cfg[0].channels);
  771. ucontrol->value.enumerated.item[0] =
  772. afe_loopback_tx_cfg[0].channels - 1;
  773. return 0;
  774. }
  775. static int afe_loopback_tx_ch_put(struct snd_kcontrol *kcontrol,
  776. struct snd_ctl_elem_value *ucontrol)
  777. {
  778. afe_loopback_tx_cfg[0].channels =
  779. ucontrol->value.enumerated.item[0] + 1;
  780. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  781. afe_loopback_tx_cfg[0].channels);
  782. return 1;
  783. }
  784. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  785. struct snd_ctl_elem_value *ucontrol)
  786. {
  787. switch (usb_rx_cfg.bit_format) {
  788. case SNDRV_PCM_FORMAT_S32_LE:
  789. ucontrol->value.integer.value[0] = 3;
  790. break;
  791. case SNDRV_PCM_FORMAT_S24_3LE:
  792. ucontrol->value.integer.value[0] = 2;
  793. break;
  794. case SNDRV_PCM_FORMAT_S24_LE:
  795. ucontrol->value.integer.value[0] = 1;
  796. break;
  797. case SNDRV_PCM_FORMAT_S16_LE:
  798. default:
  799. ucontrol->value.integer.value[0] = 0;
  800. break;
  801. }
  802. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  803. __func__, usb_rx_cfg.bit_format,
  804. ucontrol->value.integer.value[0]);
  805. return 0;
  806. }
  807. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  808. struct snd_ctl_elem_value *ucontrol)
  809. {
  810. int rc = 0;
  811. switch (ucontrol->value.integer.value[0]) {
  812. case 3:
  813. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  814. break;
  815. case 2:
  816. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  817. break;
  818. case 1:
  819. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  820. break;
  821. case 0:
  822. default:
  823. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  824. break;
  825. }
  826. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  827. __func__, usb_rx_cfg.bit_format,
  828. ucontrol->value.integer.value[0]);
  829. return rc;
  830. }
  831. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  832. struct snd_ctl_elem_value *ucontrol)
  833. {
  834. switch (usb_tx_cfg.bit_format) {
  835. case SNDRV_PCM_FORMAT_S32_LE:
  836. ucontrol->value.integer.value[0] = 3;
  837. break;
  838. case SNDRV_PCM_FORMAT_S24_3LE:
  839. ucontrol->value.integer.value[0] = 2;
  840. break;
  841. case SNDRV_PCM_FORMAT_S24_LE:
  842. ucontrol->value.integer.value[0] = 1;
  843. break;
  844. case SNDRV_PCM_FORMAT_S16_LE:
  845. default:
  846. ucontrol->value.integer.value[0] = 0;
  847. break;
  848. }
  849. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  850. __func__, usb_tx_cfg.bit_format,
  851. ucontrol->value.integer.value[0]);
  852. return 0;
  853. }
  854. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  855. struct snd_ctl_elem_value *ucontrol)
  856. {
  857. int rc = 0;
  858. switch (ucontrol->value.integer.value[0]) {
  859. case 3:
  860. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  861. break;
  862. case 2:
  863. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  864. break;
  865. case 1:
  866. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  867. break;
  868. case 0:
  869. default:
  870. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  871. break;
  872. }
  873. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  874. __func__, usb_tx_cfg.bit_format,
  875. ucontrol->value.integer.value[0]);
  876. return rc;
  877. }
  878. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  879. struct snd_ctl_elem_value *ucontrol)
  880. {
  881. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  882. usb_rx_cfg.channels);
  883. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  884. return 0;
  885. }
  886. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  887. struct snd_ctl_elem_value *ucontrol)
  888. {
  889. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  890. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  891. return 1;
  892. }
  893. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  894. struct snd_ctl_elem_value *ucontrol)
  895. {
  896. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  897. usb_tx_cfg.channels);
  898. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  899. return 0;
  900. }
  901. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  902. struct snd_ctl_elem_value *ucontrol)
  903. {
  904. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  905. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  906. return 1;
  907. }
  908. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  909. struct snd_ctl_elem_value *ucontrol)
  910. {
  911. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  912. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  913. ucontrol->value.integer.value[0]);
  914. return 0;
  915. }
  916. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  917. struct snd_ctl_elem_value *ucontrol)
  918. {
  919. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  920. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  921. return 1;
  922. }
  923. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  924. {
  925. int idx = 0;
  926. if (strnstr(kcontrol->id.name, "Display Port RX",
  927. sizeof("Display Port RX"))) {
  928. idx = EXT_DISP_RX_IDX_DP;
  929. } else {
  930. pr_err("%s: unsupported BE: %s\n",
  931. __func__, kcontrol->id.name);
  932. idx = -EINVAL;
  933. }
  934. return idx;
  935. }
  936. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  937. struct snd_ctl_elem_value *ucontrol)
  938. {
  939. int idx = ext_disp_get_port_idx(kcontrol);
  940. if (idx < 0)
  941. return idx;
  942. switch (ext_disp_rx_cfg[idx].bit_format) {
  943. case SNDRV_PCM_FORMAT_S24_3LE:
  944. ucontrol->value.integer.value[0] = 2;
  945. break;
  946. case SNDRV_PCM_FORMAT_S24_LE:
  947. ucontrol->value.integer.value[0] = 1;
  948. break;
  949. case SNDRV_PCM_FORMAT_S16_LE:
  950. default:
  951. ucontrol->value.integer.value[0] = 0;
  952. break;
  953. }
  954. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  955. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  956. ucontrol->value.integer.value[0]);
  957. return 0;
  958. }
  959. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  960. struct snd_ctl_elem_value *ucontrol)
  961. {
  962. int idx = ext_disp_get_port_idx(kcontrol);
  963. if (idx < 0)
  964. return idx;
  965. switch (ucontrol->value.integer.value[0]) {
  966. case 2:
  967. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  968. break;
  969. case 1:
  970. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  971. break;
  972. case 0:
  973. default:
  974. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  975. break;
  976. }
  977. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  978. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  979. ucontrol->value.integer.value[0]);
  980. return 0;
  981. }
  982. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  983. struct snd_ctl_elem_value *ucontrol)
  984. {
  985. int idx = ext_disp_get_port_idx(kcontrol);
  986. if (idx < 0)
  987. return idx;
  988. ucontrol->value.integer.value[0] =
  989. ext_disp_rx_cfg[idx].channels - 2;
  990. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  991. idx, ext_disp_rx_cfg[idx].channels);
  992. return 0;
  993. }
  994. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  995. struct snd_ctl_elem_value *ucontrol)
  996. {
  997. int idx = ext_disp_get_port_idx(kcontrol);
  998. if (idx < 0)
  999. return idx;
  1000. ext_disp_rx_cfg[idx].channels =
  1001. ucontrol->value.integer.value[0] + 2;
  1002. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1003. idx, ext_disp_rx_cfg[idx].channels);
  1004. return 1;
  1005. }
  1006. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1007. struct snd_ctl_elem_value *ucontrol)
  1008. {
  1009. int sample_rate_val;
  1010. int idx = ext_disp_get_port_idx(kcontrol);
  1011. if (idx < 0)
  1012. return idx;
  1013. switch (ext_disp_rx_cfg[idx].sample_rate) {
  1014. case SAMPLING_RATE_176P4KHZ:
  1015. sample_rate_val = 6;
  1016. break;
  1017. case SAMPLING_RATE_88P2KHZ:
  1018. sample_rate_val = 5;
  1019. break;
  1020. case SAMPLING_RATE_44P1KHZ:
  1021. sample_rate_val = 4;
  1022. break;
  1023. case SAMPLING_RATE_32KHZ:
  1024. sample_rate_val = 3;
  1025. break;
  1026. case SAMPLING_RATE_192KHZ:
  1027. sample_rate_val = 2;
  1028. break;
  1029. case SAMPLING_RATE_96KHZ:
  1030. sample_rate_val = 1;
  1031. break;
  1032. case SAMPLING_RATE_48KHZ:
  1033. default:
  1034. sample_rate_val = 0;
  1035. break;
  1036. }
  1037. ucontrol->value.integer.value[0] = sample_rate_val;
  1038. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  1039. idx, ext_disp_rx_cfg[idx].sample_rate);
  1040. return 0;
  1041. }
  1042. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1043. struct snd_ctl_elem_value *ucontrol)
  1044. {
  1045. int idx = ext_disp_get_port_idx(kcontrol);
  1046. if (idx < 0)
  1047. return idx;
  1048. switch (ucontrol->value.integer.value[0]) {
  1049. case 6:
  1050. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  1051. break;
  1052. case 5:
  1053. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  1054. break;
  1055. case 4:
  1056. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  1057. break;
  1058. case 3:
  1059. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  1060. break;
  1061. case 2:
  1062. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  1063. break;
  1064. case 1:
  1065. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  1066. break;
  1067. case 0:
  1068. default:
  1069. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  1070. break;
  1071. }
  1072. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  1073. __func__, ucontrol->value.integer.value[0], idx,
  1074. ext_disp_rx_cfg[idx].sample_rate);
  1075. return 0;
  1076. }
  1077. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1078. struct snd_ctl_elem_value *ucontrol)
  1079. {
  1080. pr_debug("%s: proxy_rx channels = %d\n",
  1081. __func__, proxy_rx_cfg.channels);
  1082. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1083. return 0;
  1084. }
  1085. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1086. struct snd_ctl_elem_value *ucontrol)
  1087. {
  1088. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1089. pr_debug("%s: proxy_rx channels = %d\n",
  1090. __func__, proxy_rx_cfg.channels);
  1091. return 1;
  1092. }
  1093. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1094. struct tdm_port *port)
  1095. {
  1096. if (port) {
  1097. if (strnstr(kcontrol->id.name, "PRI",
  1098. sizeof(kcontrol->id.name))) {
  1099. port->mode = TDM_PRI;
  1100. } else if (strnstr(kcontrol->id.name, "SEC",
  1101. sizeof(kcontrol->id.name))) {
  1102. port->mode = TDM_SEC;
  1103. } else if (strnstr(kcontrol->id.name, "TERT",
  1104. sizeof(kcontrol->id.name))) {
  1105. port->mode = TDM_TERT;
  1106. } else {
  1107. pr_err("%s: unsupported mode in: %s\n",
  1108. __func__, kcontrol->id.name);
  1109. return -EINVAL;
  1110. }
  1111. if (strnstr(kcontrol->id.name, "RX_0",
  1112. sizeof(kcontrol->id.name)) ||
  1113. strnstr(kcontrol->id.name, "TX_0",
  1114. sizeof(kcontrol->id.name))) {
  1115. port->channel = TDM_0;
  1116. } else if (strnstr(kcontrol->id.name, "RX_1",
  1117. sizeof(kcontrol->id.name)) ||
  1118. strnstr(kcontrol->id.name, "TX_1",
  1119. sizeof(kcontrol->id.name))) {
  1120. port->channel = TDM_1;
  1121. } else if (strnstr(kcontrol->id.name, "RX_2",
  1122. sizeof(kcontrol->id.name)) ||
  1123. strnstr(kcontrol->id.name, "TX_2",
  1124. sizeof(kcontrol->id.name))) {
  1125. port->channel = TDM_2;
  1126. } else if (strnstr(kcontrol->id.name, "RX_3",
  1127. sizeof(kcontrol->id.name)) ||
  1128. strnstr(kcontrol->id.name, "TX_3",
  1129. sizeof(kcontrol->id.name))) {
  1130. port->channel = TDM_3;
  1131. } else if (strnstr(kcontrol->id.name, "RX_4",
  1132. sizeof(kcontrol->id.name)) ||
  1133. strnstr(kcontrol->id.name, "TX_4",
  1134. sizeof(kcontrol->id.name))) {
  1135. port->channel = TDM_4;
  1136. } else if (strnstr(kcontrol->id.name, "RX_5",
  1137. sizeof(kcontrol->id.name)) ||
  1138. strnstr(kcontrol->id.name, "TX_5",
  1139. sizeof(kcontrol->id.name))) {
  1140. port->channel = TDM_5;
  1141. } else if (strnstr(kcontrol->id.name, "RX_6",
  1142. sizeof(kcontrol->id.name)) ||
  1143. strnstr(kcontrol->id.name, "TX_6",
  1144. sizeof(kcontrol->id.name))) {
  1145. port->channel = TDM_6;
  1146. } else if (strnstr(kcontrol->id.name, "RX_7",
  1147. sizeof(kcontrol->id.name)) ||
  1148. strnstr(kcontrol->id.name, "TX_7",
  1149. sizeof(kcontrol->id.name))) {
  1150. port->channel = TDM_7;
  1151. } else {
  1152. pr_err("%s: unsupported channel in: %s\n",
  1153. __func__, kcontrol->id.name);
  1154. return -EINVAL;
  1155. }
  1156. } else {
  1157. return -EINVAL;
  1158. }
  1159. return 0;
  1160. }
  1161. static int tdm_get_sample_rate(int value)
  1162. {
  1163. int sample_rate = 0;
  1164. switch (value) {
  1165. case 0:
  1166. sample_rate = SAMPLING_RATE_8KHZ;
  1167. break;
  1168. case 1:
  1169. sample_rate = SAMPLING_RATE_16KHZ;
  1170. break;
  1171. case 2:
  1172. sample_rate = SAMPLING_RATE_32KHZ;
  1173. break;
  1174. case 3:
  1175. sample_rate = SAMPLING_RATE_48KHZ;
  1176. break;
  1177. case 4:
  1178. sample_rate = SAMPLING_RATE_176P4KHZ;
  1179. break;
  1180. case 5:
  1181. sample_rate = SAMPLING_RATE_352P8KHZ;
  1182. break;
  1183. default:
  1184. sample_rate = SAMPLING_RATE_48KHZ;
  1185. break;
  1186. }
  1187. return sample_rate;
  1188. }
  1189. static int tdm_get_sample_rate_val(int sample_rate)
  1190. {
  1191. int sample_rate_val = 0;
  1192. switch (sample_rate) {
  1193. case SAMPLING_RATE_8KHZ:
  1194. sample_rate_val = 0;
  1195. break;
  1196. case SAMPLING_RATE_16KHZ:
  1197. sample_rate_val = 1;
  1198. break;
  1199. case SAMPLING_RATE_32KHZ:
  1200. sample_rate_val = 2;
  1201. break;
  1202. case SAMPLING_RATE_48KHZ:
  1203. sample_rate_val = 3;
  1204. break;
  1205. case SAMPLING_RATE_176P4KHZ:
  1206. sample_rate_val = 4;
  1207. break;
  1208. case SAMPLING_RATE_352P8KHZ:
  1209. sample_rate_val = 5;
  1210. break;
  1211. default:
  1212. sample_rate_val = 3;
  1213. break;
  1214. }
  1215. return sample_rate_val;
  1216. }
  1217. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1218. struct snd_ctl_elem_value *ucontrol)
  1219. {
  1220. struct tdm_port port;
  1221. int ret = tdm_get_port_idx(kcontrol, &port);
  1222. if (ret) {
  1223. pr_err("%s: unsupported control: %s\n",
  1224. __func__, kcontrol->id.name);
  1225. } else {
  1226. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1227. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1228. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1229. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1230. ucontrol->value.enumerated.item[0]);
  1231. }
  1232. return ret;
  1233. }
  1234. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1235. struct snd_ctl_elem_value *ucontrol)
  1236. {
  1237. struct tdm_port port;
  1238. int ret = tdm_get_port_idx(kcontrol, &port);
  1239. if (ret) {
  1240. pr_err("%s: unsupported control: %s\n",
  1241. __func__, kcontrol->id.name);
  1242. } else {
  1243. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1244. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1245. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1246. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1247. ucontrol->value.enumerated.item[0]);
  1248. }
  1249. return ret;
  1250. }
  1251. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1252. struct snd_ctl_elem_value *ucontrol)
  1253. {
  1254. struct tdm_port port;
  1255. int ret = tdm_get_port_idx(kcontrol, &port);
  1256. if (ret) {
  1257. pr_err("%s: unsupported control: %s\n",
  1258. __func__, kcontrol->id.name);
  1259. } else {
  1260. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1261. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1262. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1263. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1264. ucontrol->value.enumerated.item[0]);
  1265. }
  1266. return ret;
  1267. }
  1268. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1269. struct snd_ctl_elem_value *ucontrol)
  1270. {
  1271. struct tdm_port port;
  1272. int ret = tdm_get_port_idx(kcontrol, &port);
  1273. if (ret) {
  1274. pr_err("%s: unsupported control: %s\n",
  1275. __func__, kcontrol->id.name);
  1276. } else {
  1277. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1278. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1279. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1280. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1281. ucontrol->value.enumerated.item[0]);
  1282. }
  1283. return ret;
  1284. }
  1285. static int tdm_get_format(int value)
  1286. {
  1287. int format = 0;
  1288. switch (value) {
  1289. case 0:
  1290. format = SNDRV_PCM_FORMAT_S16_LE;
  1291. break;
  1292. case 1:
  1293. format = SNDRV_PCM_FORMAT_S24_LE;
  1294. break;
  1295. case 2:
  1296. format = SNDRV_PCM_FORMAT_S32_LE;
  1297. break;
  1298. default:
  1299. format = SNDRV_PCM_FORMAT_S16_LE;
  1300. break;
  1301. }
  1302. return format;
  1303. }
  1304. static int tdm_get_format_val(int format)
  1305. {
  1306. int value = 0;
  1307. switch (format) {
  1308. case SNDRV_PCM_FORMAT_S16_LE:
  1309. value = 0;
  1310. break;
  1311. case SNDRV_PCM_FORMAT_S24_LE:
  1312. value = 1;
  1313. break;
  1314. case SNDRV_PCM_FORMAT_S32_LE:
  1315. value = 2;
  1316. break;
  1317. default:
  1318. value = 0;
  1319. break;
  1320. }
  1321. return value;
  1322. }
  1323. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1324. struct snd_ctl_elem_value *ucontrol)
  1325. {
  1326. struct tdm_port port;
  1327. int ret = tdm_get_port_idx(kcontrol, &port);
  1328. if (ret) {
  1329. pr_err("%s: unsupported control: %s\n",
  1330. __func__, kcontrol->id.name);
  1331. } else {
  1332. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1333. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1334. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1335. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1336. ucontrol->value.enumerated.item[0]);
  1337. }
  1338. return ret;
  1339. }
  1340. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1341. struct snd_ctl_elem_value *ucontrol)
  1342. {
  1343. struct tdm_port port;
  1344. int ret = tdm_get_port_idx(kcontrol, &port);
  1345. if (ret) {
  1346. pr_err("%s: unsupported control: %s\n",
  1347. __func__, kcontrol->id.name);
  1348. } else {
  1349. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1350. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1351. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1352. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1353. ucontrol->value.enumerated.item[0]);
  1354. }
  1355. return ret;
  1356. }
  1357. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1358. struct snd_ctl_elem_value *ucontrol)
  1359. {
  1360. struct tdm_port port;
  1361. int ret = tdm_get_port_idx(kcontrol, &port);
  1362. if (ret) {
  1363. pr_err("%s: unsupported control: %s\n",
  1364. __func__, kcontrol->id.name);
  1365. } else {
  1366. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1367. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1368. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1369. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1370. ucontrol->value.enumerated.item[0]);
  1371. }
  1372. return ret;
  1373. }
  1374. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1375. struct snd_ctl_elem_value *ucontrol)
  1376. {
  1377. struct tdm_port port;
  1378. int ret = tdm_get_port_idx(kcontrol, &port);
  1379. if (ret) {
  1380. pr_err("%s: unsupported control: %s\n",
  1381. __func__, kcontrol->id.name);
  1382. } else {
  1383. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1384. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1385. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1386. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1387. ucontrol->value.enumerated.item[0]);
  1388. }
  1389. return ret;
  1390. }
  1391. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1392. struct snd_ctl_elem_value *ucontrol)
  1393. {
  1394. struct tdm_port port;
  1395. int ret = tdm_get_port_idx(kcontrol, &port);
  1396. if (ret) {
  1397. pr_err("%s: unsupported control: %s\n",
  1398. __func__, kcontrol->id.name);
  1399. } else {
  1400. ucontrol->value.enumerated.item[0] =
  1401. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1402. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1403. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1404. ucontrol->value.enumerated.item[0]);
  1405. }
  1406. return ret;
  1407. }
  1408. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1409. struct snd_ctl_elem_value *ucontrol)
  1410. {
  1411. struct tdm_port port;
  1412. int ret = tdm_get_port_idx(kcontrol, &port);
  1413. if (ret) {
  1414. pr_err("%s: unsupported control: %s\n",
  1415. __func__, kcontrol->id.name);
  1416. } else {
  1417. tdm_rx_cfg[port.mode][port.channel].channels =
  1418. ucontrol->value.enumerated.item[0] + 1;
  1419. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1420. tdm_rx_cfg[port.mode][port.channel].channels,
  1421. ucontrol->value.enumerated.item[0] + 1);
  1422. }
  1423. return ret;
  1424. }
  1425. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1426. struct snd_ctl_elem_value *ucontrol)
  1427. {
  1428. struct tdm_port port;
  1429. int ret = tdm_get_port_idx(kcontrol, &port);
  1430. if (ret) {
  1431. pr_err("%s: unsupported control: %s\n",
  1432. __func__, kcontrol->id.name);
  1433. } else {
  1434. ucontrol->value.enumerated.item[0] =
  1435. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1436. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1437. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1438. ucontrol->value.enumerated.item[0]);
  1439. }
  1440. return ret;
  1441. }
  1442. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1443. struct snd_ctl_elem_value *ucontrol)
  1444. {
  1445. struct tdm_port port;
  1446. int ret = tdm_get_port_idx(kcontrol, &port);
  1447. if (ret) {
  1448. pr_err("%s: unsupported control: %s\n",
  1449. __func__, kcontrol->id.name);
  1450. } else {
  1451. tdm_tx_cfg[port.mode][port.channel].channels =
  1452. ucontrol->value.enumerated.item[0] + 1;
  1453. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1454. tdm_tx_cfg[port.mode][port.channel].channels,
  1455. ucontrol->value.enumerated.item[0] + 1);
  1456. }
  1457. return ret;
  1458. }
  1459. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1460. {
  1461. int idx = 0;
  1462. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1463. sizeof("PRIM_AUX_PCM"))) {
  1464. idx = PRIM_AUX_PCM;
  1465. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1466. sizeof("SEC_AUX_PCM"))) {
  1467. idx = SEC_AUX_PCM;
  1468. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1469. sizeof("TERT_AUX_PCM"))) {
  1470. idx = TERT_AUX_PCM;
  1471. } else {
  1472. pr_err("%s: unsupported port: %s\n",
  1473. __func__, kcontrol->id.name);
  1474. idx = -EINVAL;
  1475. }
  1476. return idx;
  1477. }
  1478. static int aux_pcm_get_sample_rate(int value)
  1479. {
  1480. int sample_rate = 0;
  1481. switch (value) {
  1482. case 1:
  1483. sample_rate = SAMPLING_RATE_16KHZ;
  1484. break;
  1485. case 0:
  1486. default:
  1487. sample_rate = SAMPLING_RATE_8KHZ;
  1488. break;
  1489. }
  1490. return sample_rate;
  1491. }
  1492. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1493. {
  1494. int sample_rate_val = 0;
  1495. switch (sample_rate) {
  1496. case SAMPLING_RATE_16KHZ:
  1497. sample_rate_val = 1;
  1498. break;
  1499. case SAMPLING_RATE_8KHZ:
  1500. default:
  1501. sample_rate_val = 0;
  1502. break;
  1503. }
  1504. return sample_rate_val;
  1505. }
  1506. static int mi2s_auxpcm_get_format(int value)
  1507. {
  1508. int format = 0;
  1509. switch (value) {
  1510. case 0:
  1511. format = SNDRV_PCM_FORMAT_S16_LE;
  1512. break;
  1513. case 1:
  1514. format = SNDRV_PCM_FORMAT_S24_LE;
  1515. break;
  1516. case 2:
  1517. format = SNDRV_PCM_FORMAT_S24_3LE;
  1518. break;
  1519. case 3:
  1520. format = SNDRV_PCM_FORMAT_S32_LE;
  1521. break;
  1522. default:
  1523. format = SNDRV_PCM_FORMAT_S16_LE;
  1524. break;
  1525. }
  1526. return format;
  1527. }
  1528. static int mi2s_auxpcm_get_format_value(int format)
  1529. {
  1530. int value = 0;
  1531. switch (format) {
  1532. case SNDRV_PCM_FORMAT_S16_LE:
  1533. value = 0;
  1534. break;
  1535. case SNDRV_PCM_FORMAT_S24_LE:
  1536. value = 1;
  1537. break;
  1538. case SNDRV_PCM_FORMAT_S24_3LE:
  1539. value = 2;
  1540. break;
  1541. case SNDRV_PCM_FORMAT_S32_LE:
  1542. value = 3;
  1543. break;
  1544. default:
  1545. value = 0;
  1546. break;
  1547. }
  1548. return value;
  1549. }
  1550. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1551. struct snd_ctl_elem_value *ucontrol)
  1552. {
  1553. int idx = aux_pcm_get_port_idx(kcontrol);
  1554. if (idx < 0)
  1555. return idx;
  1556. ucontrol->value.enumerated.item[0] =
  1557. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1558. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1559. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1560. ucontrol->value.enumerated.item[0]);
  1561. return 0;
  1562. }
  1563. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1564. struct snd_ctl_elem_value *ucontrol)
  1565. {
  1566. int idx = aux_pcm_get_port_idx(kcontrol);
  1567. if (idx < 0)
  1568. return idx;
  1569. aux_pcm_rx_cfg[idx].sample_rate =
  1570. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1571. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1572. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1573. ucontrol->value.enumerated.item[0]);
  1574. return 0;
  1575. }
  1576. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1577. struct snd_ctl_elem_value *ucontrol)
  1578. {
  1579. int idx = aux_pcm_get_port_idx(kcontrol);
  1580. if (idx < 0)
  1581. return idx;
  1582. ucontrol->value.enumerated.item[0] =
  1583. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  1584. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1585. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1586. ucontrol->value.enumerated.item[0]);
  1587. return 0;
  1588. }
  1589. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1590. struct snd_ctl_elem_value *ucontrol)
  1591. {
  1592. int idx = aux_pcm_get_port_idx(kcontrol);
  1593. if (idx < 0)
  1594. return idx;
  1595. aux_pcm_tx_cfg[idx].sample_rate =
  1596. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1597. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1598. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1599. ucontrol->value.enumerated.item[0]);
  1600. return 0;
  1601. }
  1602. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  1603. struct snd_ctl_elem_value *ucontrol)
  1604. {
  1605. int idx = aux_pcm_get_port_idx(kcontrol);
  1606. if (idx < 0)
  1607. return idx;
  1608. ucontrol->value.enumerated.item[0] =
  1609. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  1610. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1611. idx, aux_pcm_rx_cfg[idx].bit_format,
  1612. ucontrol->value.enumerated.item[0]);
  1613. return 0;
  1614. }
  1615. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  1616. struct snd_ctl_elem_value *ucontrol)
  1617. {
  1618. int idx = aux_pcm_get_port_idx(kcontrol);
  1619. if (idx < 0)
  1620. return idx;
  1621. aux_pcm_rx_cfg[idx].bit_format =
  1622. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1623. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1624. idx, aux_pcm_rx_cfg[idx].bit_format,
  1625. ucontrol->value.enumerated.item[0]);
  1626. return 0;
  1627. }
  1628. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  1629. struct snd_ctl_elem_value *ucontrol)
  1630. {
  1631. int idx = aux_pcm_get_port_idx(kcontrol);
  1632. if (idx < 0)
  1633. return idx;
  1634. ucontrol->value.enumerated.item[0] =
  1635. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  1636. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1637. idx, aux_pcm_tx_cfg[idx].bit_format,
  1638. ucontrol->value.enumerated.item[0]);
  1639. return 0;
  1640. }
  1641. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  1642. struct snd_ctl_elem_value *ucontrol)
  1643. {
  1644. int idx = aux_pcm_get_port_idx(kcontrol);
  1645. if (idx < 0)
  1646. return idx;
  1647. aux_pcm_tx_cfg[idx].bit_format =
  1648. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1649. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1650. idx, aux_pcm_tx_cfg[idx].bit_format,
  1651. ucontrol->value.enumerated.item[0]);
  1652. return 0;
  1653. }
  1654. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  1655. {
  1656. int idx = 0;
  1657. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  1658. sizeof("PRIM_MI2S_RX"))) {
  1659. idx = PRIM_MI2S;
  1660. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  1661. sizeof("SEC_MI2S_RX"))) {
  1662. idx = SEC_MI2S;
  1663. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  1664. sizeof("TERT_MI2S_RX"))) {
  1665. idx = TERT_MI2S;
  1666. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  1667. sizeof("PRIM_MI2S_TX"))) {
  1668. idx = PRIM_MI2S;
  1669. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  1670. sizeof("SEC_MI2S_TX"))) {
  1671. idx = SEC_MI2S;
  1672. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  1673. sizeof("TERT_MI2S_TX"))) {
  1674. idx = TERT_MI2S;
  1675. } else {
  1676. pr_err("%s: unsupported channel: %s\n",
  1677. __func__, kcontrol->id.name);
  1678. idx = -EINVAL;
  1679. }
  1680. return idx;
  1681. }
  1682. static int mi2s_get_sample_rate(int value)
  1683. {
  1684. int sample_rate = 0;
  1685. switch (value) {
  1686. case 0:
  1687. sample_rate = SAMPLING_RATE_8KHZ;
  1688. break;
  1689. case 1:
  1690. sample_rate = SAMPLING_RATE_11P025KHZ;
  1691. break;
  1692. case 2:
  1693. sample_rate = SAMPLING_RATE_16KHZ;
  1694. break;
  1695. case 3:
  1696. sample_rate = SAMPLING_RATE_22P05KHZ;
  1697. break;
  1698. case 4:
  1699. sample_rate = SAMPLING_RATE_32KHZ;
  1700. break;
  1701. case 5:
  1702. sample_rate = SAMPLING_RATE_44P1KHZ;
  1703. break;
  1704. case 6:
  1705. sample_rate = SAMPLING_RATE_48KHZ;
  1706. break;
  1707. case 7:
  1708. sample_rate = SAMPLING_RATE_96KHZ;
  1709. break;
  1710. case 8:
  1711. sample_rate = SAMPLING_RATE_192KHZ;
  1712. break;
  1713. default:
  1714. sample_rate = SAMPLING_RATE_48KHZ;
  1715. break;
  1716. }
  1717. return sample_rate;
  1718. }
  1719. static int mi2s_get_sample_rate_val(int sample_rate)
  1720. {
  1721. int sample_rate_val = 0;
  1722. switch (sample_rate) {
  1723. case SAMPLING_RATE_8KHZ:
  1724. sample_rate_val = 0;
  1725. break;
  1726. case SAMPLING_RATE_11P025KHZ:
  1727. sample_rate_val = 1;
  1728. break;
  1729. case SAMPLING_RATE_16KHZ:
  1730. sample_rate_val = 2;
  1731. break;
  1732. case SAMPLING_RATE_22P05KHZ:
  1733. sample_rate_val = 3;
  1734. break;
  1735. case SAMPLING_RATE_32KHZ:
  1736. sample_rate_val = 4;
  1737. break;
  1738. case SAMPLING_RATE_44P1KHZ:
  1739. sample_rate_val = 5;
  1740. break;
  1741. case SAMPLING_RATE_48KHZ:
  1742. sample_rate_val = 6;
  1743. break;
  1744. case SAMPLING_RATE_96KHZ:
  1745. sample_rate_val = 7;
  1746. break;
  1747. case SAMPLING_RATE_192KHZ:
  1748. sample_rate_val = 8;
  1749. break;
  1750. default:
  1751. sample_rate_val = 6;
  1752. break;
  1753. }
  1754. return sample_rate_val;
  1755. }
  1756. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1757. struct snd_ctl_elem_value *ucontrol)
  1758. {
  1759. int idx = mi2s_get_port_idx(kcontrol);
  1760. if (idx < 0)
  1761. return idx;
  1762. ucontrol->value.enumerated.item[0] =
  1763. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  1764. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1765. idx, mi2s_rx_cfg[idx].sample_rate,
  1766. ucontrol->value.enumerated.item[0]);
  1767. return 0;
  1768. }
  1769. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1770. struct snd_ctl_elem_value *ucontrol)
  1771. {
  1772. int idx = mi2s_get_port_idx(kcontrol);
  1773. if (idx < 0)
  1774. return idx;
  1775. mi2s_rx_cfg[idx].sample_rate =
  1776. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1777. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1778. idx, mi2s_rx_cfg[idx].sample_rate,
  1779. ucontrol->value.enumerated.item[0]);
  1780. return 0;
  1781. }
  1782. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1783. struct snd_ctl_elem_value *ucontrol)
  1784. {
  1785. int idx = mi2s_get_port_idx(kcontrol);
  1786. if (idx < 0)
  1787. return idx;
  1788. ucontrol->value.enumerated.item[0] =
  1789. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  1790. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1791. idx, mi2s_tx_cfg[idx].sample_rate,
  1792. ucontrol->value.enumerated.item[0]);
  1793. return 0;
  1794. }
  1795. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1796. struct snd_ctl_elem_value *ucontrol)
  1797. {
  1798. int idx = mi2s_get_port_idx(kcontrol);
  1799. if (idx < 0)
  1800. return idx;
  1801. mi2s_tx_cfg[idx].sample_rate =
  1802. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1803. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1804. idx, mi2s_tx_cfg[idx].sample_rate,
  1805. ucontrol->value.enumerated.item[0]);
  1806. return 0;
  1807. }
  1808. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  1809. struct snd_ctl_elem_value *ucontrol)
  1810. {
  1811. int idx = mi2s_get_port_idx(kcontrol);
  1812. if (idx < 0)
  1813. return idx;
  1814. ucontrol->value.enumerated.item[0] =
  1815. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  1816. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1817. idx, mi2s_rx_cfg[idx].bit_format,
  1818. ucontrol->value.enumerated.item[0]);
  1819. return 0;
  1820. }
  1821. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  1822. struct snd_ctl_elem_value *ucontrol)
  1823. {
  1824. int idx = mi2s_get_port_idx(kcontrol);
  1825. if (idx < 0)
  1826. return idx;
  1827. mi2s_rx_cfg[idx].bit_format =
  1828. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1829. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1830. idx, mi2s_rx_cfg[idx].bit_format,
  1831. ucontrol->value.enumerated.item[0]);
  1832. return 0;
  1833. }
  1834. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  1835. struct snd_ctl_elem_value *ucontrol)
  1836. {
  1837. int idx = mi2s_get_port_idx(kcontrol);
  1838. if (idx < 0)
  1839. return idx;
  1840. ucontrol->value.enumerated.item[0] =
  1841. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  1842. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1843. idx, mi2s_tx_cfg[idx].bit_format,
  1844. ucontrol->value.enumerated.item[0]);
  1845. return 0;
  1846. }
  1847. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  1848. struct snd_ctl_elem_value *ucontrol)
  1849. {
  1850. int idx = mi2s_get_port_idx(kcontrol);
  1851. if (idx < 0)
  1852. return idx;
  1853. mi2s_tx_cfg[idx].bit_format =
  1854. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1855. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1856. idx, mi2s_tx_cfg[idx].bit_format,
  1857. ucontrol->value.enumerated.item[0]);
  1858. return 0;
  1859. }
  1860. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  1861. struct snd_ctl_elem_value *ucontrol)
  1862. {
  1863. int idx = mi2s_get_port_idx(kcontrol);
  1864. if (idx < 0)
  1865. return idx;
  1866. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1867. idx, mi2s_rx_cfg[idx].channels);
  1868. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  1869. return 0;
  1870. }
  1871. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  1872. struct snd_ctl_elem_value *ucontrol)
  1873. {
  1874. int idx = mi2s_get_port_idx(kcontrol);
  1875. if (idx < 0)
  1876. return idx;
  1877. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1878. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1879. idx, mi2s_rx_cfg[idx].channels);
  1880. return 1;
  1881. }
  1882. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  1883. struct snd_ctl_elem_value *ucontrol)
  1884. {
  1885. int idx = mi2s_get_port_idx(kcontrol);
  1886. if (idx < 0)
  1887. return idx;
  1888. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1889. idx, mi2s_tx_cfg[idx].channels);
  1890. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  1891. return 0;
  1892. }
  1893. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  1894. struct snd_ctl_elem_value *ucontrol)
  1895. {
  1896. int idx = mi2s_get_port_idx(kcontrol);
  1897. if (idx < 0)
  1898. return idx;
  1899. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1900. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1901. idx, mi2s_tx_cfg[idx].channels);
  1902. return 1;
  1903. }
  1904. static int msm_get_port_id(int be_id)
  1905. {
  1906. int afe_port_id = 0;
  1907. switch (be_id) {
  1908. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  1909. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  1910. break;
  1911. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  1912. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  1913. break;
  1914. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  1915. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  1916. break;
  1917. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  1918. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  1919. break;
  1920. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  1921. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  1922. break;
  1923. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  1924. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  1925. break;
  1926. default:
  1927. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  1928. afe_port_id = -EINVAL;
  1929. }
  1930. return afe_port_id;
  1931. }
  1932. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  1933. {
  1934. u32 bit_per_sample = 0;
  1935. switch (bit_format) {
  1936. case SNDRV_PCM_FORMAT_S32_LE:
  1937. case SNDRV_PCM_FORMAT_S24_3LE:
  1938. case SNDRV_PCM_FORMAT_S24_LE:
  1939. bit_per_sample = 32;
  1940. break;
  1941. case SNDRV_PCM_FORMAT_S16_LE:
  1942. default:
  1943. bit_per_sample = 16;
  1944. break;
  1945. }
  1946. return bit_per_sample;
  1947. }
  1948. static void update_mi2s_clk_val(int dai_id, int stream)
  1949. {
  1950. u32 bit_per_sample = 0;
  1951. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1952. bit_per_sample =
  1953. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  1954. mi2s_clk[dai_id].clk_freq_in_hz =
  1955. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1956. } else {
  1957. bit_per_sample =
  1958. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  1959. mi2s_clk[dai_id].clk_freq_in_hz =
  1960. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1961. }
  1962. }
  1963. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  1964. {
  1965. int ret = 0;
  1966. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1967. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1968. int port_id = 0;
  1969. int index = cpu_dai->id;
  1970. port_id = msm_get_port_id(rtd->dai_link->id);
  1971. if (port_id < 0) {
  1972. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  1973. ret = port_id;
  1974. goto err;
  1975. }
  1976. if (enable) {
  1977. update_mi2s_clk_val(index, substream->stream);
  1978. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  1979. mi2s_clk[index].clk_freq_in_hz);
  1980. }
  1981. mi2s_clk[index].enable = enable;
  1982. ret = afe_set_lpass_clock_v2(port_id,
  1983. &mi2s_clk[index]);
  1984. if (ret < 0) {
  1985. dev_err(rtd->card->dev,
  1986. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  1987. __func__, port_id, ret);
  1988. goto err;
  1989. }
  1990. err:
  1991. return ret;
  1992. }
  1993. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  1994. {
  1995. int idx = 0;
  1996. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  1997. sizeof("WSA_CDC_DMA_RX_0")))
  1998. idx = WSA_CDC_DMA_RX_0;
  1999. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  2000. sizeof("WSA_CDC_DMA_RX_0")))
  2001. idx = WSA_CDC_DMA_RX_1;
  2002. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  2003. sizeof("RX_CDC_DMA_RX_0")))
  2004. idx = RX_CDC_DMA_RX_0;
  2005. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  2006. sizeof("RX_CDC_DMA_RX_1")))
  2007. idx = RX_CDC_DMA_RX_1;
  2008. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  2009. sizeof("RX_CDC_DMA_RX_2")))
  2010. idx = RX_CDC_DMA_RX_2;
  2011. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  2012. sizeof("RX_CDC_DMA_RX_3")))
  2013. idx = RX_CDC_DMA_RX_3;
  2014. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  2015. sizeof("RX_CDC_DMA_RX_5")))
  2016. idx = RX_CDC_DMA_RX_5;
  2017. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  2018. sizeof("WSA_CDC_DMA_TX_0")))
  2019. idx = WSA_CDC_DMA_TX_0;
  2020. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  2021. sizeof("WSA_CDC_DMA_TX_1")))
  2022. idx = WSA_CDC_DMA_TX_1;
  2023. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  2024. sizeof("WSA_CDC_DMA_TX_2")))
  2025. idx = WSA_CDC_DMA_TX_2;
  2026. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  2027. sizeof("TX_CDC_DMA_TX_0")))
  2028. idx = TX_CDC_DMA_TX_0;
  2029. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  2030. sizeof("TX_CDC_DMA_TX_3")))
  2031. idx = TX_CDC_DMA_TX_3;
  2032. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  2033. sizeof("TX_CDC_DMA_TX_4")))
  2034. idx = TX_CDC_DMA_TX_4;
  2035. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  2036. sizeof("VA_CDC_DMA_TX_0")))
  2037. idx = VA_CDC_DMA_TX_0;
  2038. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  2039. sizeof("VA_CDC_DMA_TX_1")))
  2040. idx = VA_CDC_DMA_TX_1;
  2041. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  2042. sizeof("VA_CDC_DMA_TX_2")))
  2043. idx = VA_CDC_DMA_TX_2;
  2044. else {
  2045. pr_err("%s: unsupported channel: %s\n",
  2046. __func__, kcontrol->id.name);
  2047. return -EINVAL;
  2048. }
  2049. return idx;
  2050. }
  2051. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  2052. struct snd_ctl_elem_value *ucontrol)
  2053. {
  2054. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2055. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2056. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2057. return ch_num;
  2058. }
  2059. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2060. cdc_dma_rx_cfg[ch_num].channels - 1);
  2061. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  2062. return 0;
  2063. }
  2064. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  2065. struct snd_ctl_elem_value *ucontrol)
  2066. {
  2067. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2068. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2069. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2070. return ch_num;
  2071. }
  2072. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2073. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2074. cdc_dma_rx_cfg[ch_num].channels);
  2075. return 1;
  2076. }
  2077. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2078. struct snd_ctl_elem_value *ucontrol)
  2079. {
  2080. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2081. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2082. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2083. return ch_num;
  2084. }
  2085. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2086. case SNDRV_PCM_FORMAT_S32_LE:
  2087. ucontrol->value.integer.value[0] = 3;
  2088. break;
  2089. case SNDRV_PCM_FORMAT_S24_3LE:
  2090. ucontrol->value.integer.value[0] = 2;
  2091. break;
  2092. case SNDRV_PCM_FORMAT_S24_LE:
  2093. ucontrol->value.integer.value[0] = 1;
  2094. break;
  2095. case SNDRV_PCM_FORMAT_S16_LE:
  2096. default:
  2097. ucontrol->value.integer.value[0] = 0;
  2098. break;
  2099. }
  2100. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2101. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2102. ucontrol->value.integer.value[0]);
  2103. return 0;
  2104. }
  2105. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2106. struct snd_ctl_elem_value *ucontrol)
  2107. {
  2108. int rc = 0;
  2109. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2110. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2111. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2112. return ch_num;
  2113. }
  2114. switch (ucontrol->value.integer.value[0]) {
  2115. case 3:
  2116. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2117. break;
  2118. case 2:
  2119. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2120. break;
  2121. case 1:
  2122. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2123. break;
  2124. case 0:
  2125. default:
  2126. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2127. break;
  2128. }
  2129. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2130. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2131. ucontrol->value.integer.value[0]);
  2132. return rc;
  2133. }
  2134. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2135. {
  2136. int sample_rate_val = 0;
  2137. switch (sample_rate) {
  2138. case SAMPLING_RATE_8KHZ:
  2139. sample_rate_val = 0;
  2140. break;
  2141. case SAMPLING_RATE_11P025KHZ:
  2142. sample_rate_val = 1;
  2143. break;
  2144. case SAMPLING_RATE_16KHZ:
  2145. sample_rate_val = 2;
  2146. break;
  2147. case SAMPLING_RATE_22P05KHZ:
  2148. sample_rate_val = 3;
  2149. break;
  2150. case SAMPLING_RATE_32KHZ:
  2151. sample_rate_val = 4;
  2152. break;
  2153. case SAMPLING_RATE_44P1KHZ:
  2154. sample_rate_val = 5;
  2155. break;
  2156. case SAMPLING_RATE_48KHZ:
  2157. sample_rate_val = 6;
  2158. break;
  2159. case SAMPLING_RATE_88P2KHZ:
  2160. sample_rate_val = 7;
  2161. break;
  2162. case SAMPLING_RATE_96KHZ:
  2163. sample_rate_val = 8;
  2164. break;
  2165. case SAMPLING_RATE_176P4KHZ:
  2166. sample_rate_val = 9;
  2167. break;
  2168. case SAMPLING_RATE_192KHZ:
  2169. sample_rate_val = 10;
  2170. break;
  2171. case SAMPLING_RATE_352P8KHZ:
  2172. sample_rate_val = 11;
  2173. break;
  2174. case SAMPLING_RATE_384KHZ:
  2175. sample_rate_val = 12;
  2176. break;
  2177. default:
  2178. sample_rate_val = 6;
  2179. break;
  2180. }
  2181. return sample_rate_val;
  2182. }
  2183. static int cdc_dma_get_sample_rate(int value)
  2184. {
  2185. int sample_rate = 0;
  2186. switch (value) {
  2187. case 0:
  2188. sample_rate = SAMPLING_RATE_8KHZ;
  2189. break;
  2190. case 1:
  2191. sample_rate = SAMPLING_RATE_11P025KHZ;
  2192. break;
  2193. case 2:
  2194. sample_rate = SAMPLING_RATE_16KHZ;
  2195. break;
  2196. case 3:
  2197. sample_rate = SAMPLING_RATE_22P05KHZ;
  2198. break;
  2199. case 4:
  2200. sample_rate = SAMPLING_RATE_32KHZ;
  2201. break;
  2202. case 5:
  2203. sample_rate = SAMPLING_RATE_44P1KHZ;
  2204. break;
  2205. case 6:
  2206. sample_rate = SAMPLING_RATE_48KHZ;
  2207. break;
  2208. case 7:
  2209. sample_rate = SAMPLING_RATE_88P2KHZ;
  2210. break;
  2211. case 8:
  2212. sample_rate = SAMPLING_RATE_96KHZ;
  2213. break;
  2214. case 9:
  2215. sample_rate = SAMPLING_RATE_176P4KHZ;
  2216. break;
  2217. case 10:
  2218. sample_rate = SAMPLING_RATE_192KHZ;
  2219. break;
  2220. case 11:
  2221. sample_rate = SAMPLING_RATE_352P8KHZ;
  2222. break;
  2223. case 12:
  2224. sample_rate = SAMPLING_RATE_384KHZ;
  2225. break;
  2226. default:
  2227. sample_rate = SAMPLING_RATE_48KHZ;
  2228. break;
  2229. }
  2230. return sample_rate;
  2231. }
  2232. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2233. struct snd_ctl_elem_value *ucontrol)
  2234. {
  2235. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2236. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2237. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2238. return ch_num;
  2239. }
  2240. ucontrol->value.enumerated.item[0] =
  2241. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2242. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2243. cdc_dma_rx_cfg[ch_num].sample_rate);
  2244. return 0;
  2245. }
  2246. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2247. struct snd_ctl_elem_value *ucontrol)
  2248. {
  2249. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2250. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2251. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2252. return ch_num;
  2253. }
  2254. cdc_dma_rx_cfg[ch_num].sample_rate =
  2255. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2256. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2257. __func__, ucontrol->value.enumerated.item[0],
  2258. cdc_dma_rx_cfg[ch_num].sample_rate);
  2259. return 0;
  2260. }
  2261. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2262. struct snd_ctl_elem_value *ucontrol)
  2263. {
  2264. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2265. if (ch_num < 0) {
  2266. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2267. return ch_num;
  2268. }
  2269. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2270. cdc_dma_tx_cfg[ch_num].channels);
  2271. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2272. return 0;
  2273. }
  2274. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2275. struct snd_ctl_elem_value *ucontrol)
  2276. {
  2277. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2278. if (ch_num < 0) {
  2279. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2280. return ch_num;
  2281. }
  2282. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2283. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2284. cdc_dma_tx_cfg[ch_num].channels);
  2285. return 1;
  2286. }
  2287. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2288. struct snd_ctl_elem_value *ucontrol)
  2289. {
  2290. int sample_rate_val;
  2291. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2292. if (ch_num < 0) {
  2293. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2294. return ch_num;
  2295. }
  2296. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2297. case SAMPLING_RATE_384KHZ:
  2298. sample_rate_val = 12;
  2299. break;
  2300. case SAMPLING_RATE_352P8KHZ:
  2301. sample_rate_val = 11;
  2302. break;
  2303. case SAMPLING_RATE_192KHZ:
  2304. sample_rate_val = 10;
  2305. break;
  2306. case SAMPLING_RATE_176P4KHZ:
  2307. sample_rate_val = 9;
  2308. break;
  2309. case SAMPLING_RATE_96KHZ:
  2310. sample_rate_val = 8;
  2311. break;
  2312. case SAMPLING_RATE_88P2KHZ:
  2313. sample_rate_val = 7;
  2314. break;
  2315. case SAMPLING_RATE_48KHZ:
  2316. sample_rate_val = 6;
  2317. break;
  2318. case SAMPLING_RATE_44P1KHZ:
  2319. sample_rate_val = 5;
  2320. break;
  2321. case SAMPLING_RATE_32KHZ:
  2322. sample_rate_val = 4;
  2323. break;
  2324. case SAMPLING_RATE_22P05KHZ:
  2325. sample_rate_val = 3;
  2326. break;
  2327. case SAMPLING_RATE_16KHZ:
  2328. sample_rate_val = 2;
  2329. break;
  2330. case SAMPLING_RATE_11P025KHZ:
  2331. sample_rate_val = 1;
  2332. break;
  2333. case SAMPLING_RATE_8KHZ:
  2334. sample_rate_val = 0;
  2335. break;
  2336. default:
  2337. sample_rate_val = 6;
  2338. break;
  2339. }
  2340. ucontrol->value.integer.value[0] = sample_rate_val;
  2341. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2342. cdc_dma_tx_cfg[ch_num].sample_rate);
  2343. return 0;
  2344. }
  2345. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2346. struct snd_ctl_elem_value *ucontrol)
  2347. {
  2348. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2349. if (ch_num < 0) {
  2350. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2351. return ch_num;
  2352. }
  2353. switch (ucontrol->value.integer.value[0]) {
  2354. case 12:
  2355. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2356. break;
  2357. case 11:
  2358. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2359. break;
  2360. case 10:
  2361. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2362. break;
  2363. case 9:
  2364. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2365. break;
  2366. case 8:
  2367. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2368. break;
  2369. case 7:
  2370. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2371. break;
  2372. case 6:
  2373. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2374. break;
  2375. case 5:
  2376. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2377. break;
  2378. case 4:
  2379. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2380. break;
  2381. case 3:
  2382. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2383. break;
  2384. case 2:
  2385. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2386. break;
  2387. case 1:
  2388. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2389. break;
  2390. case 0:
  2391. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2392. break;
  2393. default:
  2394. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2395. break;
  2396. }
  2397. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2398. __func__, ucontrol->value.integer.value[0],
  2399. cdc_dma_tx_cfg[ch_num].sample_rate);
  2400. return 0;
  2401. }
  2402. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2403. struct snd_ctl_elem_value *ucontrol)
  2404. {
  2405. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2406. if (ch_num < 0) {
  2407. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2408. return ch_num;
  2409. }
  2410. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2411. case SNDRV_PCM_FORMAT_S32_LE:
  2412. ucontrol->value.integer.value[0] = 3;
  2413. break;
  2414. case SNDRV_PCM_FORMAT_S24_3LE:
  2415. ucontrol->value.integer.value[0] = 2;
  2416. break;
  2417. case SNDRV_PCM_FORMAT_S24_LE:
  2418. ucontrol->value.integer.value[0] = 1;
  2419. break;
  2420. case SNDRV_PCM_FORMAT_S16_LE:
  2421. default:
  2422. ucontrol->value.integer.value[0] = 0;
  2423. break;
  2424. }
  2425. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2426. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2427. ucontrol->value.integer.value[0]);
  2428. return 0;
  2429. }
  2430. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2431. struct snd_ctl_elem_value *ucontrol)
  2432. {
  2433. int rc = 0;
  2434. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2435. if (ch_num < 0) {
  2436. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2437. return ch_num;
  2438. }
  2439. switch (ucontrol->value.integer.value[0]) {
  2440. case 3:
  2441. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2442. break;
  2443. case 2:
  2444. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2445. break;
  2446. case 1:
  2447. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2448. break;
  2449. case 0:
  2450. default:
  2451. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2452. break;
  2453. }
  2454. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2455. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2456. ucontrol->value.integer.value[0]);
  2457. return rc;
  2458. }
  2459. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  2460. {
  2461. int idx = 0;
  2462. switch (be_id) {
  2463. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2464. idx = WSA_CDC_DMA_RX_0;
  2465. break;
  2466. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2467. idx = WSA_CDC_DMA_TX_0;
  2468. break;
  2469. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2470. idx = WSA_CDC_DMA_RX_1;
  2471. break;
  2472. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2473. idx = WSA_CDC_DMA_TX_1;
  2474. break;
  2475. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2476. idx = WSA_CDC_DMA_TX_2;
  2477. break;
  2478. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2479. idx = RX_CDC_DMA_RX_0;
  2480. break;
  2481. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2482. idx = RX_CDC_DMA_RX_1;
  2483. break;
  2484. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2485. idx = RX_CDC_DMA_RX_2;
  2486. break;
  2487. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2488. idx = RX_CDC_DMA_RX_3;
  2489. break;
  2490. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2491. idx = RX_CDC_DMA_RX_5;
  2492. break;
  2493. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2494. idx = TX_CDC_DMA_TX_0;
  2495. break;
  2496. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2497. idx = TX_CDC_DMA_TX_3;
  2498. break;
  2499. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2500. idx = TX_CDC_DMA_TX_4;
  2501. break;
  2502. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2503. idx = VA_CDC_DMA_TX_0;
  2504. break;
  2505. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2506. idx = VA_CDC_DMA_TX_1;
  2507. break;
  2508. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2509. idx = VA_CDC_DMA_TX_2;
  2510. break;
  2511. default:
  2512. idx = RX_CDC_DMA_RX_0;
  2513. break;
  2514. }
  2515. return idx;
  2516. }
  2517. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  2518. struct snd_ctl_elem_value *ucontrol)
  2519. {
  2520. /*
  2521. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  2522. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  2523. * value.
  2524. */
  2525. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  2526. case SAMPLING_RATE_96KHZ:
  2527. ucontrol->value.integer.value[0] = 5;
  2528. break;
  2529. case SAMPLING_RATE_88P2KHZ:
  2530. ucontrol->value.integer.value[0] = 4;
  2531. break;
  2532. case SAMPLING_RATE_48KHZ:
  2533. ucontrol->value.integer.value[0] = 3;
  2534. break;
  2535. case SAMPLING_RATE_44P1KHZ:
  2536. ucontrol->value.integer.value[0] = 2;
  2537. break;
  2538. case SAMPLING_RATE_16KHZ:
  2539. ucontrol->value.integer.value[0] = 1;
  2540. break;
  2541. case SAMPLING_RATE_8KHZ:
  2542. default:
  2543. ucontrol->value.integer.value[0] = 0;
  2544. break;
  2545. }
  2546. pr_debug("%s: sample rate = %d\n", __func__,
  2547. slim_rx_cfg[SLIM_RX_7].sample_rate);
  2548. return 0;
  2549. }
  2550. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  2551. struct snd_ctl_elem_value *ucontrol)
  2552. {
  2553. switch (ucontrol->value.integer.value[0]) {
  2554. case 1:
  2555. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2556. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2557. break;
  2558. case 2:
  2559. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2560. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2561. break;
  2562. case 3:
  2563. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2564. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2565. break;
  2566. case 4:
  2567. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2568. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2569. break;
  2570. case 5:
  2571. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2572. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2573. break;
  2574. case 0:
  2575. default:
  2576. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2577. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2578. break;
  2579. }
  2580. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  2581. __func__,
  2582. slim_rx_cfg[SLIM_RX_7].sample_rate,
  2583. slim_tx_cfg[SLIM_TX_7].sample_rate,
  2584. ucontrol->value.enumerated.item[0]);
  2585. return 0;
  2586. }
  2587. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  2588. struct snd_ctl_elem_value *ucontrol)
  2589. {
  2590. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  2591. case SAMPLING_RATE_96KHZ:
  2592. ucontrol->value.integer.value[0] = 5;
  2593. break;
  2594. case SAMPLING_RATE_88P2KHZ:
  2595. ucontrol->value.integer.value[0] = 4;
  2596. break;
  2597. case SAMPLING_RATE_48KHZ:
  2598. ucontrol->value.integer.value[0] = 3;
  2599. break;
  2600. case SAMPLING_RATE_44P1KHZ:
  2601. ucontrol->value.integer.value[0] = 2;
  2602. break;
  2603. case SAMPLING_RATE_16KHZ:
  2604. ucontrol->value.integer.value[0] = 1;
  2605. break;
  2606. case SAMPLING_RATE_8KHZ:
  2607. default:
  2608. ucontrol->value.integer.value[0] = 0;
  2609. break;
  2610. }
  2611. pr_debug("%s: sample rate rx = %d\n", __func__,
  2612. slim_rx_cfg[SLIM_RX_7].sample_rate);
  2613. return 0;
  2614. }
  2615. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  2616. struct snd_ctl_elem_value *ucontrol)
  2617. {
  2618. switch (ucontrol->value.integer.value[0]) {
  2619. case 1:
  2620. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2621. break;
  2622. case 2:
  2623. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2624. break;
  2625. case 3:
  2626. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2627. break;
  2628. case 4:
  2629. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2630. break;
  2631. case 5:
  2632. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2633. break;
  2634. case 0:
  2635. default:
  2636. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2637. break;
  2638. }
  2639. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  2640. __func__,
  2641. slim_rx_cfg[SLIM_RX_7].sample_rate,
  2642. ucontrol->value.enumerated.item[0]);
  2643. return 0;
  2644. }
  2645. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  2646. struct snd_ctl_elem_value *ucontrol)
  2647. {
  2648. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  2649. case SAMPLING_RATE_96KHZ:
  2650. ucontrol->value.integer.value[0] = 5;
  2651. break;
  2652. case SAMPLING_RATE_88P2KHZ:
  2653. ucontrol->value.integer.value[0] = 4;
  2654. break;
  2655. case SAMPLING_RATE_48KHZ:
  2656. ucontrol->value.integer.value[0] = 3;
  2657. break;
  2658. case SAMPLING_RATE_44P1KHZ:
  2659. ucontrol->value.integer.value[0] = 2;
  2660. break;
  2661. case SAMPLING_RATE_16KHZ:
  2662. ucontrol->value.integer.value[0] = 1;
  2663. break;
  2664. case SAMPLING_RATE_8KHZ:
  2665. default:
  2666. ucontrol->value.integer.value[0] = 0;
  2667. break;
  2668. }
  2669. pr_debug("%s: sample rate tx = %d\n", __func__,
  2670. slim_tx_cfg[SLIM_TX_7].sample_rate);
  2671. return 0;
  2672. }
  2673. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  2674. struct snd_ctl_elem_value *ucontrol)
  2675. {
  2676. switch (ucontrol->value.integer.value[0]) {
  2677. case 1:
  2678. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2679. break;
  2680. case 2:
  2681. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2682. break;
  2683. case 3:
  2684. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2685. break;
  2686. case 4:
  2687. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2688. break;
  2689. case 5:
  2690. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  2691. break;
  2692. case 0:
  2693. default:
  2694. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  2695. break;
  2696. }
  2697. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  2698. __func__,
  2699. slim_tx_cfg[SLIM_TX_7].sample_rate,
  2700. ucontrol->value.enumerated.item[0]);
  2701. return 0;
  2702. }
  2703. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  2704. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  2705. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2706. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  2707. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2708. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  2709. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2710. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  2711. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2712. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  2713. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2714. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  2715. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2716. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  2717. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2718. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  2719. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2720. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  2721. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2722. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  2723. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2724. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  2725. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2726. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  2727. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2728. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  2729. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2730. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  2731. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2732. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  2733. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2734. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  2735. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2736. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  2737. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2738. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  2739. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2740. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc_dma_rx_0_format,
  2741. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2742. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc_dma_rx_1_format,
  2743. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2744. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc_dma_rx_2_format,
  2745. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2746. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc_dma_rx_3_format,
  2747. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2748. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc_dma_rx_5_format,
  2749. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2750. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  2751. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2752. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  2753. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2754. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  2755. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2756. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  2757. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2758. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  2759. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2760. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  2761. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2762. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  2763. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2764. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  2765. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2766. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  2767. wsa_cdc_dma_rx_0_sample_rate,
  2768. cdc_dma_rx_sample_rate_get,
  2769. cdc_dma_rx_sample_rate_put),
  2770. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  2771. wsa_cdc_dma_rx_1_sample_rate,
  2772. cdc_dma_rx_sample_rate_get,
  2773. cdc_dma_rx_sample_rate_put),
  2774. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  2775. rx_cdc_dma_rx_0_sample_rate,
  2776. cdc_dma_rx_sample_rate_get,
  2777. cdc_dma_rx_sample_rate_put),
  2778. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  2779. rx_cdc_dma_rx_1_sample_rate,
  2780. cdc_dma_rx_sample_rate_get,
  2781. cdc_dma_rx_sample_rate_put),
  2782. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  2783. rx_cdc_dma_rx_2_sample_rate,
  2784. cdc_dma_rx_sample_rate_get,
  2785. cdc_dma_rx_sample_rate_put),
  2786. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  2787. rx_cdc_dma_rx_3_sample_rate,
  2788. cdc_dma_rx_sample_rate_get,
  2789. cdc_dma_rx_sample_rate_put),
  2790. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  2791. rx_cdc_dma_rx_5_sample_rate,
  2792. cdc_dma_rx_sample_rate_get,
  2793. cdc_dma_rx_sample_rate_put),
  2794. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  2795. wsa_cdc_dma_tx_0_sample_rate,
  2796. cdc_dma_tx_sample_rate_get,
  2797. cdc_dma_tx_sample_rate_put),
  2798. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  2799. wsa_cdc_dma_tx_1_sample_rate,
  2800. cdc_dma_tx_sample_rate_get,
  2801. cdc_dma_tx_sample_rate_put),
  2802. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  2803. wsa_cdc_dma_tx_2_sample_rate,
  2804. cdc_dma_tx_sample_rate_get,
  2805. cdc_dma_tx_sample_rate_put),
  2806. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  2807. tx_cdc_dma_tx_0_sample_rate,
  2808. cdc_dma_tx_sample_rate_get,
  2809. cdc_dma_tx_sample_rate_put),
  2810. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  2811. tx_cdc_dma_tx_3_sample_rate,
  2812. cdc_dma_tx_sample_rate_get,
  2813. cdc_dma_tx_sample_rate_put),
  2814. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  2815. tx_cdc_dma_tx_4_sample_rate,
  2816. cdc_dma_tx_sample_rate_get,
  2817. cdc_dma_tx_sample_rate_put),
  2818. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  2819. va_cdc_dma_tx_0_sample_rate,
  2820. cdc_dma_tx_sample_rate_get,
  2821. cdc_dma_tx_sample_rate_put),
  2822. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  2823. va_cdc_dma_tx_1_sample_rate,
  2824. cdc_dma_tx_sample_rate_get,
  2825. cdc_dma_tx_sample_rate_put),
  2826. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  2827. va_cdc_dma_tx_2_sample_rate,
  2828. cdc_dma_tx_sample_rate_get,
  2829. cdc_dma_tx_sample_rate_put),
  2830. };
  2831. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  2832. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  2833. usb_audio_rx_sample_rate_get,
  2834. usb_audio_rx_sample_rate_put),
  2835. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  2836. usb_audio_tx_sample_rate_get,
  2837. usb_audio_tx_sample_rate_put),
  2838. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2839. tdm_rx_sample_rate_get,
  2840. tdm_rx_sample_rate_put),
  2841. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2842. tdm_rx_sample_rate_get,
  2843. tdm_rx_sample_rate_put),
  2844. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2845. tdm_rx_sample_rate_get,
  2846. tdm_rx_sample_rate_put),
  2847. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2848. tdm_tx_sample_rate_get,
  2849. tdm_tx_sample_rate_put),
  2850. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2851. tdm_tx_sample_rate_get,
  2852. tdm_tx_sample_rate_put),
  2853. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2854. tdm_tx_sample_rate_get,
  2855. tdm_tx_sample_rate_put),
  2856. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2857. aux_pcm_rx_sample_rate_get,
  2858. aux_pcm_rx_sample_rate_put),
  2859. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  2860. aux_pcm_rx_sample_rate_get,
  2861. aux_pcm_rx_sample_rate_put),
  2862. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  2863. aux_pcm_rx_sample_rate_get,
  2864. aux_pcm_rx_sample_rate_put),
  2865. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2866. aux_pcm_tx_sample_rate_get,
  2867. aux_pcm_tx_sample_rate_put),
  2868. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  2869. aux_pcm_tx_sample_rate_get,
  2870. aux_pcm_tx_sample_rate_put),
  2871. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  2872. aux_pcm_tx_sample_rate_get,
  2873. aux_pcm_tx_sample_rate_put),
  2874. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  2875. mi2s_rx_sample_rate_get,
  2876. mi2s_rx_sample_rate_put),
  2877. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  2878. mi2s_rx_sample_rate_get,
  2879. mi2s_rx_sample_rate_put),
  2880. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  2881. mi2s_rx_sample_rate_get,
  2882. mi2s_rx_sample_rate_put),
  2883. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  2884. mi2s_tx_sample_rate_get,
  2885. mi2s_tx_sample_rate_put),
  2886. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  2887. mi2s_tx_sample_rate_get,
  2888. mi2s_tx_sample_rate_put),
  2889. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  2890. mi2s_tx_sample_rate_get,
  2891. mi2s_tx_sample_rate_put),
  2892. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  2893. usb_audio_rx_format_get, usb_audio_rx_format_put),
  2894. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  2895. usb_audio_tx_format_get, usb_audio_tx_format_put),
  2896. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  2897. tdm_rx_format_get,
  2898. tdm_rx_format_put),
  2899. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  2900. tdm_rx_format_get,
  2901. tdm_rx_format_put),
  2902. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  2903. tdm_rx_format_get,
  2904. tdm_rx_format_put),
  2905. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  2906. tdm_tx_format_get,
  2907. tdm_tx_format_put),
  2908. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  2909. tdm_tx_format_get,
  2910. tdm_tx_format_put),
  2911. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  2912. tdm_tx_format_get,
  2913. tdm_tx_format_put),
  2914. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2915. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2916. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  2917. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2918. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  2919. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2920. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2921. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2922. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  2923. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2924. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  2925. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2926. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  2927. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2928. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  2929. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2930. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  2931. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2932. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  2933. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2934. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  2935. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2936. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  2937. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2938. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  2939. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  2940. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  2941. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  2942. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  2943. proxy_rx_ch_get, proxy_rx_ch_put),
  2944. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  2945. tdm_rx_ch_get,
  2946. tdm_rx_ch_put),
  2947. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  2948. tdm_rx_ch_get,
  2949. tdm_rx_ch_put),
  2950. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  2951. tdm_rx_ch_get,
  2952. tdm_rx_ch_put),
  2953. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  2954. tdm_tx_ch_get,
  2955. tdm_tx_ch_put),
  2956. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  2957. tdm_tx_ch_get,
  2958. tdm_tx_ch_put),
  2959. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  2960. tdm_tx_ch_get,
  2961. tdm_tx_ch_put),
  2962. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  2963. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2964. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  2965. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2966. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  2967. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2968. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  2969. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2970. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  2971. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2972. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  2973. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2974. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  2975. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  2976. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  2977. ext_disp_rx_format_get, ext_disp_rx_format_put),
  2978. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  2979. ext_disp_rx_sample_rate_get,
  2980. ext_disp_rx_sample_rate_put),
  2981. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  2982. msm_bt_sample_rate_get,
  2983. msm_bt_sample_rate_put),
  2984. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  2985. msm_bt_sample_rate_rx_get,
  2986. msm_bt_sample_rate_rx_put),
  2987. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  2988. msm_bt_sample_rate_tx_get,
  2989. msm_bt_sample_rate_tx_put),
  2990. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_loopback_tx_chs,
  2991. afe_loopback_tx_ch_get, afe_loopback_tx_ch_put),
  2992. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  2993. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  2994. };
  2995. static const struct snd_kcontrol_new msm_snd_controls[] = {
  2996. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2997. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2998. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2999. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3000. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3001. aux_pcm_rx_sample_rate_get,
  3002. aux_pcm_rx_sample_rate_put),
  3003. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3004. aux_pcm_tx_sample_rate_get,
  3005. aux_pcm_tx_sample_rate_put),
  3006. };
  3007. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  3008. {
  3009. int idx;
  3010. switch (be_id) {
  3011. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3012. idx = EXT_DISP_RX_IDX_DP;
  3013. break;
  3014. default:
  3015. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  3016. idx = -EINVAL;
  3017. break;
  3018. }
  3019. return idx;
  3020. }
  3021. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  3022. struct snd_pcm_hw_params *params)
  3023. {
  3024. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3025. struct snd_interval *rate = hw_param_interval(params,
  3026. SNDRV_PCM_HW_PARAM_RATE);
  3027. struct snd_interval *channels = hw_param_interval(params,
  3028. SNDRV_PCM_HW_PARAM_CHANNELS);
  3029. int idx = 0, rc = 0;
  3030. pr_debug("%s: format = %d, rate = %d\n",
  3031. __func__, params_format(params), params_rate(params));
  3032. switch (dai_link->id) {
  3033. case MSM_BACKEND_DAI_USB_RX:
  3034. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3035. usb_rx_cfg.bit_format);
  3036. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3037. channels->min = channels->max = usb_rx_cfg.channels;
  3038. break;
  3039. case MSM_BACKEND_DAI_USB_TX:
  3040. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3041. usb_tx_cfg.bit_format);
  3042. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3043. channels->min = channels->max = usb_tx_cfg.channels;
  3044. break;
  3045. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3046. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3047. if (idx < 0) {
  3048. pr_err("%s: Incorrect ext disp idx %d\n",
  3049. __func__, idx);
  3050. rc = idx;
  3051. goto done;
  3052. }
  3053. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3054. ext_disp_rx_cfg[idx].bit_format);
  3055. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3056. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3057. break;
  3058. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3059. channels->min = channels->max = proxy_rx_cfg.channels;
  3060. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3061. break;
  3062. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3063. channels->min = channels->max =
  3064. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3065. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3066. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3067. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3068. break;
  3069. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3070. channels->min = channels->max =
  3071. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3072. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3073. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3074. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3075. break;
  3076. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3077. channels->min = channels->max =
  3078. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3079. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3080. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3081. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3082. break;
  3083. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3084. channels->min = channels->max =
  3085. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3086. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3087. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3088. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3089. break;
  3090. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3091. channels->min = channels->max =
  3092. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3093. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3094. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3095. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3096. break;
  3097. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3098. channels->min = channels->max =
  3099. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3100. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3101. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3102. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3103. break;
  3104. case MSM_BACKEND_DAI_AUXPCM_RX:
  3105. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3106. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3107. rate->min = rate->max =
  3108. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3109. channels->min = channels->max =
  3110. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3111. break;
  3112. case MSM_BACKEND_DAI_AUXPCM_TX:
  3113. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3114. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3115. rate->min = rate->max =
  3116. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3117. channels->min = channels->max =
  3118. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3119. break;
  3120. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3121. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3122. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3123. rate->min = rate->max =
  3124. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3125. channels->min = channels->max =
  3126. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3127. break;
  3128. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3129. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3130. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3131. rate->min = rate->max =
  3132. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3133. channels->min = channels->max =
  3134. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3135. break;
  3136. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3137. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3138. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3139. rate->min = rate->max =
  3140. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3141. channels->min = channels->max =
  3142. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3143. break;
  3144. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3145. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3146. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3147. rate->min = rate->max =
  3148. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  3149. channels->min = channels->max =
  3150. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  3151. break;
  3152. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  3153. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3154. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  3155. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  3156. channels->min = channels->max =
  3157. mi2s_rx_cfg[PRIM_MI2S].channels;
  3158. break;
  3159. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  3160. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3161. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  3162. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  3163. channels->min = channels->max =
  3164. mi2s_tx_cfg[PRIM_MI2S].channels;
  3165. break;
  3166. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  3167. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3168. mi2s_rx_cfg[SEC_MI2S].bit_format);
  3169. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  3170. channels->min = channels->max =
  3171. mi2s_rx_cfg[SEC_MI2S].channels;
  3172. break;
  3173. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  3174. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3175. mi2s_tx_cfg[SEC_MI2S].bit_format);
  3176. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  3177. channels->min = channels->max =
  3178. mi2s_tx_cfg[SEC_MI2S].channels;
  3179. break;
  3180. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  3181. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3182. mi2s_rx_cfg[TERT_MI2S].bit_format);
  3183. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  3184. channels->min = channels->max =
  3185. mi2s_rx_cfg[TERT_MI2S].channels;
  3186. break;
  3187. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  3188. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3189. mi2s_tx_cfg[TERT_MI2S].bit_format);
  3190. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  3191. channels->min = channels->max =
  3192. mi2s_tx_cfg[TERT_MI2S].channels;
  3193. break;
  3194. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3195. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3196. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3197. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3198. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3199. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3200. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3201. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3202. cdc_dma_rx_cfg[idx].bit_format);
  3203. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  3204. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  3205. break;
  3206. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3207. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3208. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3209. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3210. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3211. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3212. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3213. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3214. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3215. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3216. cdc_dma_tx_cfg[idx].bit_format);
  3217. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  3218. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  3219. break;
  3220. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3221. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3222. SNDRV_PCM_FORMAT_S32_LE);
  3223. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  3224. channels->min = channels->max = msm_vi_feed_tx_ch;
  3225. break;
  3226. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  3227. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3228. slim_rx_cfg[SLIM_RX_7].bit_format);
  3229. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  3230. channels->min = channels->max =
  3231. slim_rx_cfg[SLIM_RX_7].channels;
  3232. break;
  3233. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  3234. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  3235. channels->min = channels->max =
  3236. slim_tx_cfg[SLIM_TX_7].channels;
  3237. break;
  3238. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  3239. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  3240. channels->min = channels->max =
  3241. slim_tx_cfg[SLIM_TX_8].channels;
  3242. break;
  3243. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  3244. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3245. afe_loopback_tx_cfg[idx].bit_format);
  3246. rate->min = rate->max = afe_loopback_tx_cfg[idx].sample_rate;
  3247. channels->min = channels->max =
  3248. afe_loopback_tx_cfg[idx].channels;
  3249. break;
  3250. default:
  3251. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3252. break;
  3253. }
  3254. done:
  3255. return rc;
  3256. }
  3257. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  3258. {
  3259. struct snd_soc_card *card = component->card;
  3260. struct msm_asoc_mach_data *pdata =
  3261. snd_soc_card_get_drvdata(card);
  3262. if (!pdata->fsa_handle)
  3263. return false;
  3264. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  3265. }
  3266. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  3267. {
  3268. int value = 0;
  3269. bool ret = false;
  3270. struct snd_soc_card *card;
  3271. struct msm_asoc_mach_data *pdata;
  3272. if (!component) {
  3273. pr_err("%s component is NULL\n", __func__);
  3274. return false;
  3275. }
  3276. card = component->card;
  3277. pdata = snd_soc_card_get_drvdata(card);
  3278. if (!pdata)
  3279. return false;
  3280. if (wcd_mbhc_cfg.enable_usbc_analog)
  3281. return msm_usbc_swap_gnd_mic(component, active);
  3282. /* if usbc is not defined, swap using us_euro_gpio_p */
  3283. if (pdata->us_euro_gpio_p) {
  3284. value = msm_cdc_pinctrl_get_state(
  3285. pdata->us_euro_gpio_p);
  3286. if (value)
  3287. msm_cdc_pinctrl_select_sleep_state(
  3288. pdata->us_euro_gpio_p);
  3289. else
  3290. msm_cdc_pinctrl_select_active_state(
  3291. pdata->us_euro_gpio_p);
  3292. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  3293. __func__, value, !value);
  3294. ret = true;
  3295. }
  3296. return ret;
  3297. }
  3298. static int kona_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  3299. struct snd_pcm_hw_params *params)
  3300. {
  3301. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3302. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3303. int ret = 0;
  3304. int slot_width = 32;
  3305. int channels, slots;
  3306. unsigned int slot_mask, rate, clk_freq;
  3307. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  3308. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  3309. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  3310. switch (cpu_dai->id) {
  3311. case AFE_PORT_ID_PRIMARY_TDM_RX:
  3312. slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3313. break;
  3314. case AFE_PORT_ID_SECONDARY_TDM_RX:
  3315. slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3316. break;
  3317. case AFE_PORT_ID_TERTIARY_TDM_RX:
  3318. slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3319. break;
  3320. case AFE_PORT_ID_PRIMARY_TDM_TX:
  3321. slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3322. break;
  3323. case AFE_PORT_ID_SECONDARY_TDM_TX:
  3324. slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3325. break;
  3326. case AFE_PORT_ID_TERTIARY_TDM_TX:
  3327. slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3328. break;
  3329. default:
  3330. pr_err("%s: dai id 0x%x not supported\n",
  3331. __func__, cpu_dai->id);
  3332. return -EINVAL;
  3333. }
  3334. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3335. /*2 slot config - bits 0 and 1 set for the first two slots */
  3336. slot_mask = 0x0000FFFF >> (16 - slots);
  3337. channels = slots;
  3338. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  3339. __func__, slot_width, slots);
  3340. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  3341. slots, slot_width);
  3342. if (ret < 0) {
  3343. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  3344. __func__, ret);
  3345. goto end;
  3346. }
  3347. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3348. 0, NULL, channels, slot_offset);
  3349. if (ret < 0) {
  3350. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  3351. __func__, ret);
  3352. goto end;
  3353. }
  3354. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  3355. /*2 slot config - bits 0 and 1 set for the first two slots */
  3356. slot_mask = 0x0000FFFF >> (16 - slots);
  3357. channels = slots;
  3358. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  3359. __func__, slot_width, slots);
  3360. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  3361. slots, slot_width);
  3362. if (ret < 0) {
  3363. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  3364. __func__, ret);
  3365. goto end;
  3366. }
  3367. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3368. channels, slot_offset, 0, NULL);
  3369. if (ret < 0) {
  3370. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  3371. __func__, ret);
  3372. goto end;
  3373. }
  3374. } else {
  3375. ret = -EINVAL;
  3376. pr_err("%s: invalid use case, err:%d\n",
  3377. __func__, ret);
  3378. goto end;
  3379. }
  3380. rate = params_rate(params);
  3381. clk_freq = rate * slot_width * slots;
  3382. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  3383. if (ret < 0)
  3384. pr_err("%s: failed to set tdm clk, err:%d\n",
  3385. __func__, ret);
  3386. end:
  3387. return ret;
  3388. }
  3389. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  3390. struct snd_pcm_hw_params *params)
  3391. {
  3392. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3393. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3394. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3395. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3396. int ret = 0;
  3397. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  3398. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3399. u32 user_set_tx_ch = 0;
  3400. u32 user_set_rx_ch = 0;
  3401. u32 ch_id;
  3402. ret = snd_soc_dai_get_channel_map(codec_dai,
  3403. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  3404. &rx_ch_cdc_dma);
  3405. if (ret < 0) {
  3406. pr_err("%s: failed to get codec chan map, err:%d\n",
  3407. __func__, ret);
  3408. goto err;
  3409. }
  3410. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3411. switch (dai_link->id) {
  3412. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3413. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3414. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3415. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3416. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3417. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3418. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  3419. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  3420. {
  3421. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3422. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  3423. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  3424. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  3425. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  3426. user_set_rx_ch, &rx_ch_cdc_dma);
  3427. if (ret < 0) {
  3428. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3429. __func__, ret);
  3430. goto err;
  3431. }
  3432. }
  3433. break;
  3434. }
  3435. } else {
  3436. switch (dai_link->id) {
  3437. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3438. {
  3439. user_set_tx_ch = msm_vi_feed_tx_ch;
  3440. }
  3441. break;
  3442. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3443. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3444. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3445. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3446. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3447. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3448. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3449. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3450. {
  3451. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3452. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  3453. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  3454. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  3455. }
  3456. break;
  3457. }
  3458. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  3459. &tx_ch_cdc_dma, 0, 0);
  3460. if (ret < 0) {
  3461. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3462. __func__, ret);
  3463. goto err;
  3464. }
  3465. }
  3466. err:
  3467. return ret;
  3468. }
  3469. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  3470. {
  3471. cpumask_t mask;
  3472. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  3473. pm_qos_remove_request(&substream->latency_pm_qos_req);
  3474. cpumask_clear(&mask);
  3475. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  3476. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  3477. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  3478. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  3479. pm_qos_add_request(&substream->latency_pm_qos_req,
  3480. PM_QOS_CPU_DMA_LATENCY,
  3481. MSM_LL_QOS_VALUE);
  3482. return 0;
  3483. }
  3484. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  3485. {
  3486. int ret = 0;
  3487. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3488. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3489. int index = cpu_dai->id;
  3490. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  3491. dev_dbg(rtd->card->dev,
  3492. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  3493. __func__, substream->name, substream->stream,
  3494. cpu_dai->name, cpu_dai->id);
  3495. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3496. ret = -EINVAL;
  3497. dev_err(rtd->card->dev,
  3498. "%s: CPU DAI id (%d) out of range\n",
  3499. __func__, cpu_dai->id);
  3500. goto err;
  3501. }
  3502. /*
  3503. * Mutex protection in case the same MI2S
  3504. * interface using for both TX and RX so
  3505. * that the same clock won't be enable twice.
  3506. */
  3507. mutex_lock(&mi2s_intf_conf[index].lock);
  3508. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  3509. /* Check if msm needs to provide the clock to the interface */
  3510. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  3511. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  3512. fmt = SND_SOC_DAIFMT_CBM_CFM;
  3513. }
  3514. ret = msm_mi2s_set_sclk(substream, true);
  3515. if (ret < 0) {
  3516. dev_err(rtd->card->dev,
  3517. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  3518. __func__, ret);
  3519. goto clean_up;
  3520. }
  3521. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  3522. if (ret < 0) {
  3523. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  3524. __func__, index, ret);
  3525. goto clk_off;
  3526. }
  3527. }
  3528. clk_off:
  3529. if (ret < 0)
  3530. msm_mi2s_set_sclk(substream, false);
  3531. clean_up:
  3532. if (ret < 0)
  3533. mi2s_intf_conf[index].ref_cnt--;
  3534. mutex_unlock(&mi2s_intf_conf[index].lock);
  3535. err:
  3536. return ret;
  3537. }
  3538. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  3539. {
  3540. int ret = 0;
  3541. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3542. int index = rtd->cpu_dai->id;
  3543. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  3544. substream->name, substream->stream);
  3545. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3546. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  3547. return;
  3548. }
  3549. mutex_lock(&mi2s_intf_conf[index].lock);
  3550. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  3551. ret = msm_mi2s_set_sclk(substream, false);
  3552. if (ret < 0)
  3553. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  3554. __func__, index, ret);
  3555. }
  3556. mutex_unlock(&mi2s_intf_conf[index].lock);
  3557. }
  3558. static int msm_wcn_hw_params_lito(struct snd_pcm_substream *substream,
  3559. struct snd_pcm_hw_params *params)
  3560. {
  3561. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3562. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3563. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3564. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3565. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO];
  3566. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3567. int ret = 0;
  3568. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  3569. codec_dai->name, codec_dai->id);
  3570. ret = snd_soc_dai_get_channel_map(codec_dai,
  3571. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3572. if (ret) {
  3573. dev_err(rtd->dev,
  3574. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  3575. __func__, ret);
  3576. goto err;
  3577. }
  3578. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  3579. __func__, tx_ch_cnt, dai_link->id);
  3580. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3581. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  3582. if (ret)
  3583. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  3584. __func__, ret);
  3585. err:
  3586. return ret;
  3587. }
  3588. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  3589. struct snd_pcm_hw_params *params)
  3590. {
  3591. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3592. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3593. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3594. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3595. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  3596. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3597. int ret = 0;
  3598. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  3599. codec_dai->name, codec_dai->id);
  3600. ret = snd_soc_dai_get_channel_map(codec_dai,
  3601. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3602. if (ret) {
  3603. dev_err(rtd->dev,
  3604. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  3605. __func__, ret);
  3606. goto err;
  3607. }
  3608. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  3609. __func__, tx_ch_cnt, dai_link->id);
  3610. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3611. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  3612. if (ret)
  3613. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  3614. __func__, ret);
  3615. err:
  3616. return ret;
  3617. }
  3618. static struct snd_soc_ops kona_tdm_be_ops = {
  3619. .hw_params = kona_tdm_snd_hw_params,
  3620. };
  3621. static struct snd_soc_ops msm_mi2s_be_ops = {
  3622. .startup = msm_mi2s_snd_startup,
  3623. .shutdown = msm_mi2s_snd_shutdown,
  3624. };
  3625. static struct snd_soc_ops msm_fe_qos_ops = {
  3626. .prepare = msm_fe_qos_prepare,
  3627. };
  3628. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  3629. .hw_params = msm_snd_cdc_dma_hw_params,
  3630. };
  3631. static struct snd_soc_ops msm_wcn_ops = {
  3632. .hw_params = msm_wcn_hw_params,
  3633. };
  3634. static struct snd_soc_ops msm_wcn_ops_lito = {
  3635. .hw_params = msm_wcn_hw_params_lito,
  3636. };
  3637. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  3638. struct snd_kcontrol *kcontrol, int event)
  3639. {
  3640. struct msm_asoc_mach_data *pdata = NULL;
  3641. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  3642. int ret = 0;
  3643. u32 dmic_idx;
  3644. int *dmic_gpio_cnt;
  3645. struct device_node *dmic_gpio;
  3646. char *wname;
  3647. wname = strpbrk(w->name, "012345");
  3648. if (!wname) {
  3649. dev_err(component->dev, "%s: widget not found\n", __func__);
  3650. return -EINVAL;
  3651. }
  3652. ret = kstrtouint(wname, 10, &dmic_idx);
  3653. if (ret < 0) {
  3654. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  3655. __func__);
  3656. return -EINVAL;
  3657. }
  3658. pdata = snd_soc_card_get_drvdata(component->card);
  3659. switch (dmic_idx) {
  3660. case 0:
  3661. case 1:
  3662. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  3663. dmic_gpio = pdata->dmic01_gpio_p;
  3664. break;
  3665. case 2:
  3666. case 3:
  3667. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  3668. dmic_gpio = pdata->dmic23_gpio_p;
  3669. break;
  3670. case 4:
  3671. case 5:
  3672. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  3673. dmic_gpio = pdata->dmic45_gpio_p;
  3674. break;
  3675. default:
  3676. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  3677. __func__);
  3678. return -EINVAL;
  3679. }
  3680. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  3681. __func__, event, dmic_idx, *dmic_gpio_cnt);
  3682. switch (event) {
  3683. case SND_SOC_DAPM_PRE_PMU:
  3684. (*dmic_gpio_cnt)++;
  3685. if (*dmic_gpio_cnt == 1) {
  3686. ret = msm_cdc_pinctrl_select_active_state(
  3687. dmic_gpio);
  3688. if (ret < 0) {
  3689. pr_err("%s: gpio set cannot be activated %sd",
  3690. __func__, "dmic_gpio");
  3691. return ret;
  3692. }
  3693. }
  3694. break;
  3695. case SND_SOC_DAPM_POST_PMD:
  3696. (*dmic_gpio_cnt)--;
  3697. if (*dmic_gpio_cnt == 0) {
  3698. ret = msm_cdc_pinctrl_select_sleep_state(
  3699. dmic_gpio);
  3700. if (ret < 0) {
  3701. pr_err("%s: gpio set cannot be de-activated %sd",
  3702. __func__, "dmic_gpio");
  3703. return ret;
  3704. }
  3705. }
  3706. break;
  3707. default:
  3708. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  3709. return -EINVAL;
  3710. }
  3711. return 0;
  3712. }
  3713. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  3714. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  3715. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  3716. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  3717. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3718. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  3719. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  3720. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  3721. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  3722. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  3723. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  3724. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  3725. };
  3726. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  3727. {
  3728. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  3729. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  3730. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3731. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  3732. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  3733. }
  3734. static int msm_wcn_init_lito(struct snd_soc_pcm_runtime *rtd)
  3735. {
  3736. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  3737. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO] = {159, 160, 161};
  3738. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3739. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  3740. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  3741. }
  3742. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  3743. {
  3744. int ret = -EINVAL;
  3745. struct snd_soc_component *component;
  3746. struct snd_soc_dapm_context *dapm;
  3747. struct snd_card *card;
  3748. struct snd_info_entry *entry;
  3749. struct snd_soc_component *aux_comp;
  3750. struct msm_asoc_mach_data *pdata =
  3751. snd_soc_card_get_drvdata(rtd->card);
  3752. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  3753. if (!component) {
  3754. pr_err("%s: could not find component for bolero_codec\n",
  3755. __func__);
  3756. return ret;
  3757. }
  3758. dapm = snd_soc_component_get_dapm(component);
  3759. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  3760. ARRAY_SIZE(msm_int_snd_controls));
  3761. if (ret < 0) {
  3762. pr_err("%s: add_component_controls failed: %d\n",
  3763. __func__, ret);
  3764. return ret;
  3765. }
  3766. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  3767. ARRAY_SIZE(msm_common_snd_controls));
  3768. if (ret < 0) {
  3769. pr_err("%s: add common snd controls failed: %d\n",
  3770. __func__, ret);
  3771. return ret;
  3772. }
  3773. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  3774. ARRAY_SIZE(msm_int_dapm_widgets));
  3775. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  3776. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  3777. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  3778. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  3779. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  3780. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  3781. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  3782. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  3783. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  3784. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  3785. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  3786. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  3787. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  3788. snd_soc_dapm_sync(dapm);
  3789. /*
  3790. * Send speaker configuration only for WSA8810.
  3791. * Default configuration is for WSA8815.
  3792. */
  3793. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  3794. __func__, rtd->card->num_aux_devs);
  3795. if (rtd->card->num_aux_devs &&
  3796. !list_empty(&rtd->card->component_dev_list)) {
  3797. aux_comp = list_first_entry(
  3798. &rtd->card->component_dev_list,
  3799. struct snd_soc_component,
  3800. card_aux_list);
  3801. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  3802. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  3803. wsa_macro_set_spkr_mode(component,
  3804. WSA_MACRO_SPKR_MODE_1);
  3805. wsa_macro_set_spkr_gain_offset(component,
  3806. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  3807. }
  3808. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  3809. sm_port_map);
  3810. }
  3811. card = rtd->card->snd_card;
  3812. if (!pdata->codec_root) {
  3813. entry = snd_info_create_subdir(card->module, "codecs",
  3814. card->proc_root);
  3815. if (!entry) {
  3816. pr_debug("%s: Cannot create codecs module entry\n",
  3817. __func__);
  3818. ret = 0;
  3819. goto err;
  3820. }
  3821. pdata->codec_root = entry;
  3822. }
  3823. bolero_info_create_codec_entry(pdata->codec_root, component);
  3824. bolero_register_wake_irq(component, false);
  3825. codec_reg_done = true;
  3826. return 0;
  3827. err:
  3828. return ret;
  3829. }
  3830. static void *def_wcd_mbhc_cal(void)
  3831. {
  3832. void *wcd_mbhc_cal;
  3833. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  3834. u16 *btn_high;
  3835. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  3836. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  3837. if (!wcd_mbhc_cal)
  3838. return NULL;
  3839. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  3840. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  3841. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  3842. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  3843. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  3844. btn_high[0] = 75;
  3845. btn_high[1] = 150;
  3846. btn_high[2] = 237;
  3847. btn_high[3] = 500;
  3848. btn_high[4] = 500;
  3849. btn_high[5] = 500;
  3850. btn_high[6] = 500;
  3851. btn_high[7] = 500;
  3852. return wcd_mbhc_cal;
  3853. }
  3854. /* Digital audio interface glue - connects codec <---> CPU */
  3855. static struct snd_soc_dai_link msm_common_dai_links[] = {
  3856. /* FrontEnd DAI Links */
  3857. {/* hw:x,0 */
  3858. .name = MSM_DAILINK_NAME(Media1),
  3859. .stream_name = "MultiMedia1",
  3860. .cpu_dai_name = "MultiMedia1",
  3861. .platform_name = "msm-pcm-dsp.0",
  3862. .dynamic = 1,
  3863. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3864. .dpcm_playback = 1,
  3865. .dpcm_capture = 1,
  3866. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3867. SND_SOC_DPCM_TRIGGER_POST},
  3868. .codec_dai_name = "snd-soc-dummy-dai",
  3869. .codec_name = "snd-soc-dummy",
  3870. .ignore_suspend = 1,
  3871. /* this dainlink has playback support */
  3872. .ignore_pmdown_time = 1,
  3873. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  3874. },
  3875. {/* hw:x,1 */
  3876. .name = MSM_DAILINK_NAME(Media2),
  3877. .stream_name = "MultiMedia2",
  3878. .cpu_dai_name = "MultiMedia2",
  3879. .platform_name = "msm-pcm-dsp.0",
  3880. .dynamic = 1,
  3881. .dpcm_playback = 1,
  3882. .dpcm_capture = 1,
  3883. .codec_dai_name = "snd-soc-dummy-dai",
  3884. .codec_name = "snd-soc-dummy",
  3885. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3886. SND_SOC_DPCM_TRIGGER_POST},
  3887. .ignore_suspend = 1,
  3888. /* this dainlink has playback support */
  3889. .ignore_pmdown_time = 1,
  3890. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  3891. },
  3892. {/* hw:x,2 */
  3893. .name = "VoiceMMode1",
  3894. .stream_name = "VoiceMMode1",
  3895. .cpu_dai_name = "VoiceMMode1",
  3896. .platform_name = "msm-pcm-voice",
  3897. .dynamic = 1,
  3898. .dpcm_playback = 1,
  3899. .dpcm_capture = 1,
  3900. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3901. SND_SOC_DPCM_TRIGGER_POST},
  3902. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3903. .ignore_suspend = 1,
  3904. .ignore_pmdown_time = 1,
  3905. .codec_dai_name = "snd-soc-dummy-dai",
  3906. .codec_name = "snd-soc-dummy",
  3907. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  3908. },
  3909. {/* hw:x,3 */
  3910. .name = "MSM VoIP",
  3911. .stream_name = "VoIP",
  3912. .cpu_dai_name = "VoIP",
  3913. .platform_name = "msm-voip-dsp",
  3914. .dynamic = 1,
  3915. .dpcm_playback = 1,
  3916. .dpcm_capture = 1,
  3917. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3918. SND_SOC_DPCM_TRIGGER_POST},
  3919. .codec_dai_name = "snd-soc-dummy-dai",
  3920. .codec_name = "snd-soc-dummy",
  3921. .ignore_suspend = 1,
  3922. /* this dainlink has playback support */
  3923. .ignore_pmdown_time = 1,
  3924. .id = MSM_FRONTEND_DAI_VOIP,
  3925. },
  3926. {/* hw:x,4 */
  3927. .name = MSM_DAILINK_NAME(ULL),
  3928. .stream_name = "MultiMedia3",
  3929. .cpu_dai_name = "MultiMedia3",
  3930. .platform_name = "msm-pcm-dsp.2",
  3931. .dynamic = 1,
  3932. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3933. .dpcm_playback = 1,
  3934. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3935. SND_SOC_DPCM_TRIGGER_POST},
  3936. .codec_dai_name = "snd-soc-dummy-dai",
  3937. .codec_name = "snd-soc-dummy",
  3938. .ignore_suspend = 1,
  3939. /* this dainlink has playback support */
  3940. .ignore_pmdown_time = 1,
  3941. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  3942. },
  3943. {/* hw:x,5 */
  3944. .name = "MSM AFE-PCM RX",
  3945. .stream_name = "AFE-PROXY RX",
  3946. .cpu_dai_name = "msm-dai-q6-dev.241",
  3947. .codec_name = "msm-stub-codec.1",
  3948. .codec_dai_name = "msm-stub-rx",
  3949. .platform_name = "msm-pcm-afe",
  3950. .dpcm_playback = 1,
  3951. .ignore_suspend = 1,
  3952. /* this dainlink has playback support */
  3953. .ignore_pmdown_time = 1,
  3954. },
  3955. {/* hw:x,6 */
  3956. .name = "MSM AFE-PCM TX",
  3957. .stream_name = "AFE-PROXY TX",
  3958. .cpu_dai_name = "msm-dai-q6-dev.240",
  3959. .codec_name = "msm-stub-codec.1",
  3960. .codec_dai_name = "msm-stub-tx",
  3961. .platform_name = "msm-pcm-afe",
  3962. .dpcm_capture = 1,
  3963. .ignore_suspend = 1,
  3964. },
  3965. {/* hw:x,7 */
  3966. .name = MSM_DAILINK_NAME(Compress1),
  3967. .stream_name = "Compress1",
  3968. .cpu_dai_name = "MultiMedia4",
  3969. .platform_name = "msm-compress-dsp",
  3970. .dynamic = 1,
  3971. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  3972. .dpcm_playback = 1,
  3973. .dpcm_capture = 1,
  3974. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3975. SND_SOC_DPCM_TRIGGER_POST},
  3976. .codec_dai_name = "snd-soc-dummy-dai",
  3977. .codec_name = "snd-soc-dummy",
  3978. .ignore_suspend = 1,
  3979. .ignore_pmdown_time = 1,
  3980. /* this dainlink has playback support */
  3981. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  3982. },
  3983. /* Hostless PCM purpose */
  3984. {/* hw:x,8 */
  3985. .name = "AUXPCM Hostless",
  3986. .stream_name = "AUXPCM Hostless",
  3987. .cpu_dai_name = "AUXPCM_HOSTLESS",
  3988. .platform_name = "msm-pcm-hostless",
  3989. .dynamic = 1,
  3990. .dpcm_playback = 1,
  3991. .dpcm_capture = 1,
  3992. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3993. SND_SOC_DPCM_TRIGGER_POST},
  3994. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3995. .ignore_suspend = 1,
  3996. /* this dainlink has playback support */
  3997. .ignore_pmdown_time = 1,
  3998. .codec_dai_name = "snd-soc-dummy-dai",
  3999. .codec_name = "snd-soc-dummy",
  4000. },
  4001. {/* hw:x,9 */
  4002. .name = MSM_DAILINK_NAME(LowLatency),
  4003. .stream_name = "MultiMedia5",
  4004. .cpu_dai_name = "MultiMedia5",
  4005. .platform_name = "msm-pcm-dsp.1",
  4006. .dynamic = 1,
  4007. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4008. .dpcm_playback = 1,
  4009. .dpcm_capture = 1,
  4010. .codec_dai_name = "snd-soc-dummy-dai",
  4011. .codec_name = "snd-soc-dummy",
  4012. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4013. SND_SOC_DPCM_TRIGGER_POST},
  4014. .ignore_suspend = 1,
  4015. /* this dainlink has playback support */
  4016. .ignore_pmdown_time = 1,
  4017. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  4018. .ops = &msm_fe_qos_ops,
  4019. },
  4020. {/* hw:x,10 */
  4021. .name = "Listen 1 Audio Service",
  4022. .stream_name = "Listen 1 Audio Service",
  4023. .cpu_dai_name = "LSM1",
  4024. .platform_name = "msm-lsm-client",
  4025. .dynamic = 1,
  4026. .dpcm_capture = 1,
  4027. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4028. SND_SOC_DPCM_TRIGGER_POST },
  4029. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4030. .ignore_suspend = 1,
  4031. .codec_dai_name = "snd-soc-dummy-dai",
  4032. .codec_name = "snd-soc-dummy",
  4033. .id = MSM_FRONTEND_DAI_LSM1,
  4034. },
  4035. /* Multiple Tunnel instances */
  4036. {/* hw:x,11 */
  4037. .name = MSM_DAILINK_NAME(Compress2),
  4038. .stream_name = "Compress2",
  4039. .cpu_dai_name = "MultiMedia7",
  4040. .platform_name = "msm-compress-dsp",
  4041. .dynamic = 1,
  4042. .dpcm_playback = 1,
  4043. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4044. SND_SOC_DPCM_TRIGGER_POST},
  4045. .codec_dai_name = "snd-soc-dummy-dai",
  4046. .codec_name = "snd-soc-dummy",
  4047. .ignore_suspend = 1,
  4048. .ignore_pmdown_time = 1,
  4049. /* this dainlink has playback support */
  4050. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  4051. },
  4052. {/* hw:x,12 */
  4053. .name = MSM_DAILINK_NAME(MultiMedia10),
  4054. .stream_name = "MultiMedia10",
  4055. .cpu_dai_name = "MultiMedia10",
  4056. .platform_name = "msm-pcm-dsp.1",
  4057. .dynamic = 1,
  4058. .dpcm_playback = 1,
  4059. .dpcm_capture = 1,
  4060. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4061. SND_SOC_DPCM_TRIGGER_POST},
  4062. .codec_dai_name = "snd-soc-dummy-dai",
  4063. .codec_name = "snd-soc-dummy",
  4064. .ignore_suspend = 1,
  4065. .ignore_pmdown_time = 1,
  4066. /* this dainlink has playback support */
  4067. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  4068. },
  4069. {/* hw:x,13 */
  4070. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  4071. .stream_name = "MM_NOIRQ",
  4072. .cpu_dai_name = "MultiMedia8",
  4073. .platform_name = "msm-pcm-dsp-noirq",
  4074. .dynamic = 1,
  4075. .dpcm_playback = 1,
  4076. .dpcm_capture = 1,
  4077. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4078. SND_SOC_DPCM_TRIGGER_POST},
  4079. .codec_dai_name = "snd-soc-dummy-dai",
  4080. .codec_name = "snd-soc-dummy",
  4081. .ignore_suspend = 1,
  4082. .ignore_pmdown_time = 1,
  4083. /* this dainlink has playback support */
  4084. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  4085. .ops = &msm_fe_qos_ops,
  4086. },
  4087. /* HDMI Hostless */
  4088. {/* hw:x,14 */
  4089. .name = "HDMI_RX_HOSTLESS",
  4090. .stream_name = "HDMI_RX_HOSTLESS",
  4091. .cpu_dai_name = "HDMI_HOSTLESS",
  4092. .platform_name = "msm-pcm-hostless",
  4093. .dynamic = 1,
  4094. .dpcm_playback = 1,
  4095. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4096. SND_SOC_DPCM_TRIGGER_POST},
  4097. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4098. .ignore_suspend = 1,
  4099. .ignore_pmdown_time = 1,
  4100. .codec_dai_name = "snd-soc-dummy-dai",
  4101. .codec_name = "snd-soc-dummy",
  4102. },
  4103. {/* hw:x,15 */
  4104. .name = "VoiceMMode2",
  4105. .stream_name = "VoiceMMode2",
  4106. .cpu_dai_name = "VoiceMMode2",
  4107. .platform_name = "msm-pcm-voice",
  4108. .dynamic = 1,
  4109. .dpcm_playback = 1,
  4110. .dpcm_capture = 1,
  4111. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4112. SND_SOC_DPCM_TRIGGER_POST},
  4113. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4114. .ignore_suspend = 1,
  4115. .ignore_pmdown_time = 1,
  4116. .codec_dai_name = "snd-soc-dummy-dai",
  4117. .codec_name = "snd-soc-dummy",
  4118. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  4119. },
  4120. /* LSM FE */
  4121. {/* hw:x,16 */
  4122. .name = "Listen 2 Audio Service",
  4123. .stream_name = "Listen 2 Audio Service",
  4124. .cpu_dai_name = "LSM2",
  4125. .platform_name = "msm-lsm-client",
  4126. .dynamic = 1,
  4127. .dpcm_capture = 1,
  4128. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4129. SND_SOC_DPCM_TRIGGER_POST },
  4130. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4131. .ignore_suspend = 1,
  4132. .codec_dai_name = "snd-soc-dummy-dai",
  4133. .codec_name = "snd-soc-dummy",
  4134. .id = MSM_FRONTEND_DAI_LSM2,
  4135. },
  4136. {/* hw:x,17 */
  4137. .name = "Listen 3 Audio Service",
  4138. .stream_name = "Listen 3 Audio Service",
  4139. .cpu_dai_name = "LSM3",
  4140. .platform_name = "msm-lsm-client",
  4141. .dynamic = 1,
  4142. .dpcm_capture = 1,
  4143. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4144. SND_SOC_DPCM_TRIGGER_POST },
  4145. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4146. .ignore_suspend = 1,
  4147. .codec_dai_name = "snd-soc-dummy-dai",
  4148. .codec_name = "snd-soc-dummy",
  4149. .id = MSM_FRONTEND_DAI_LSM3,
  4150. },
  4151. {/* hw:x,18 */
  4152. .name = "Listen 4 Audio Service",
  4153. .stream_name = "Listen 4 Audio Service",
  4154. .cpu_dai_name = "LSM4",
  4155. .platform_name = "msm-lsm-client",
  4156. .dynamic = 1,
  4157. .dpcm_capture = 1,
  4158. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4159. SND_SOC_DPCM_TRIGGER_POST },
  4160. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4161. .ignore_suspend = 1,
  4162. .codec_dai_name = "snd-soc-dummy-dai",
  4163. .codec_name = "snd-soc-dummy",
  4164. .id = MSM_FRONTEND_DAI_LSM4,
  4165. },
  4166. {/* hw:x,19 */
  4167. .name = "Listen 5 Audio Service",
  4168. .stream_name = "Listen 5 Audio Service",
  4169. .cpu_dai_name = "LSM5",
  4170. .platform_name = "msm-lsm-client",
  4171. .dynamic = 1,
  4172. .dpcm_capture = 1,
  4173. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4174. SND_SOC_DPCM_TRIGGER_POST },
  4175. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4176. .ignore_suspend = 1,
  4177. .codec_dai_name = "snd-soc-dummy-dai",
  4178. .codec_name = "snd-soc-dummy",
  4179. .id = MSM_FRONTEND_DAI_LSM5,
  4180. },
  4181. {/* hw:x,20 */
  4182. .name = "Listen 6 Audio Service",
  4183. .stream_name = "Listen 6 Audio Service",
  4184. .cpu_dai_name = "LSM6",
  4185. .platform_name = "msm-lsm-client",
  4186. .dynamic = 1,
  4187. .dpcm_capture = 1,
  4188. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4189. SND_SOC_DPCM_TRIGGER_POST },
  4190. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4191. .ignore_suspend = 1,
  4192. .codec_dai_name = "snd-soc-dummy-dai",
  4193. .codec_name = "snd-soc-dummy",
  4194. .id = MSM_FRONTEND_DAI_LSM6,
  4195. },
  4196. {/* hw:x,21 */
  4197. .name = "Listen 7 Audio Service",
  4198. .stream_name = "Listen 7 Audio Service",
  4199. .cpu_dai_name = "LSM7",
  4200. .platform_name = "msm-lsm-client",
  4201. .dynamic = 1,
  4202. .dpcm_capture = 1,
  4203. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4204. SND_SOC_DPCM_TRIGGER_POST },
  4205. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4206. .ignore_suspend = 1,
  4207. .codec_dai_name = "snd-soc-dummy-dai",
  4208. .codec_name = "snd-soc-dummy",
  4209. .id = MSM_FRONTEND_DAI_LSM7,
  4210. },
  4211. {/* hw:x,22 */
  4212. .name = "Listen 8 Audio Service",
  4213. .stream_name = "Listen 8 Audio Service",
  4214. .cpu_dai_name = "LSM8",
  4215. .platform_name = "msm-lsm-client",
  4216. .dynamic = 1,
  4217. .dpcm_capture = 1,
  4218. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4219. SND_SOC_DPCM_TRIGGER_POST },
  4220. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4221. .ignore_suspend = 1,
  4222. .codec_dai_name = "snd-soc-dummy-dai",
  4223. .codec_name = "snd-soc-dummy",
  4224. .id = MSM_FRONTEND_DAI_LSM8,
  4225. },
  4226. {/* hw:x,23 */
  4227. .name = MSM_DAILINK_NAME(Media9),
  4228. .stream_name = "MultiMedia9",
  4229. .cpu_dai_name = "MultiMedia9",
  4230. .platform_name = "msm-pcm-dsp.0",
  4231. .dynamic = 1,
  4232. .dpcm_playback = 1,
  4233. .dpcm_capture = 1,
  4234. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4235. SND_SOC_DPCM_TRIGGER_POST},
  4236. .codec_dai_name = "snd-soc-dummy-dai",
  4237. .codec_name = "snd-soc-dummy",
  4238. .ignore_suspend = 1,
  4239. /* this dainlink has playback support */
  4240. .ignore_pmdown_time = 1,
  4241. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  4242. },
  4243. {/* hw:x,24 */
  4244. .name = MSM_DAILINK_NAME(Compress4),
  4245. .stream_name = "Compress4",
  4246. .cpu_dai_name = "MultiMedia11",
  4247. .platform_name = "msm-compress-dsp",
  4248. .dynamic = 1,
  4249. .dpcm_playback = 1,
  4250. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4251. SND_SOC_DPCM_TRIGGER_POST},
  4252. .codec_dai_name = "snd-soc-dummy-dai",
  4253. .codec_name = "snd-soc-dummy",
  4254. .ignore_suspend = 1,
  4255. .ignore_pmdown_time = 1,
  4256. /* this dainlink has playback support */
  4257. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  4258. },
  4259. {/* hw:x,25 */
  4260. .name = MSM_DAILINK_NAME(Compress5),
  4261. .stream_name = "Compress5",
  4262. .cpu_dai_name = "MultiMedia12",
  4263. .platform_name = "msm-compress-dsp",
  4264. .dynamic = 1,
  4265. .dpcm_playback = 1,
  4266. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4267. SND_SOC_DPCM_TRIGGER_POST},
  4268. .codec_dai_name = "snd-soc-dummy-dai",
  4269. .codec_name = "snd-soc-dummy",
  4270. .ignore_suspend = 1,
  4271. .ignore_pmdown_time = 1,
  4272. /* this dainlink has playback support */
  4273. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  4274. },
  4275. {/* hw:x,26 */
  4276. .name = MSM_DAILINK_NAME(Compress6),
  4277. .stream_name = "Compress6",
  4278. .cpu_dai_name = "MultiMedia13",
  4279. .platform_name = "msm-compress-dsp",
  4280. .dynamic = 1,
  4281. .dpcm_playback = 1,
  4282. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4283. SND_SOC_DPCM_TRIGGER_POST},
  4284. .codec_dai_name = "snd-soc-dummy-dai",
  4285. .codec_name = "snd-soc-dummy",
  4286. .ignore_suspend = 1,
  4287. .ignore_pmdown_time = 1,
  4288. /* this dainlink has playback support */
  4289. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  4290. },
  4291. {/* hw:x,27 */
  4292. .name = MSM_DAILINK_NAME(Compress7),
  4293. .stream_name = "Compress7",
  4294. .cpu_dai_name = "MultiMedia14",
  4295. .platform_name = "msm-compress-dsp",
  4296. .dynamic = 1,
  4297. .dpcm_playback = 1,
  4298. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4299. SND_SOC_DPCM_TRIGGER_POST},
  4300. .codec_dai_name = "snd-soc-dummy-dai",
  4301. .codec_name = "snd-soc-dummy",
  4302. .ignore_suspend = 1,
  4303. .ignore_pmdown_time = 1,
  4304. /* this dainlink has playback support */
  4305. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  4306. },
  4307. {/* hw:x,28 */
  4308. .name = MSM_DAILINK_NAME(Compress8),
  4309. .stream_name = "Compress8",
  4310. .cpu_dai_name = "MultiMedia15",
  4311. .platform_name = "msm-compress-dsp",
  4312. .dynamic = 1,
  4313. .dpcm_playback = 1,
  4314. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4315. SND_SOC_DPCM_TRIGGER_POST},
  4316. .codec_dai_name = "snd-soc-dummy-dai",
  4317. .codec_name = "snd-soc-dummy",
  4318. .ignore_suspend = 1,
  4319. .ignore_pmdown_time = 1,
  4320. /* this dainlink has playback support */
  4321. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  4322. },
  4323. {/* hw:x,29 */
  4324. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  4325. .stream_name = "MM_NOIRQ_2",
  4326. .cpu_dai_name = "MultiMedia16",
  4327. .platform_name = "msm-pcm-dsp-noirq",
  4328. .dynamic = 1,
  4329. .dpcm_playback = 1,
  4330. .dpcm_capture = 1,
  4331. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4332. SND_SOC_DPCM_TRIGGER_POST},
  4333. .codec_dai_name = "snd-soc-dummy-dai",
  4334. .codec_name = "snd-soc-dummy",
  4335. .ignore_suspend = 1,
  4336. .ignore_pmdown_time = 1,
  4337. /* this dainlink has playback support */
  4338. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  4339. },
  4340. {/* hw:x,30 */
  4341. .name = "CDC_DMA Hostless",
  4342. .stream_name = "CDC_DMA Hostless",
  4343. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  4344. .platform_name = "msm-pcm-hostless",
  4345. .dynamic = 1,
  4346. .dpcm_playback = 1,
  4347. .dpcm_capture = 1,
  4348. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4349. SND_SOC_DPCM_TRIGGER_POST},
  4350. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4351. .ignore_suspend = 1,
  4352. /* this dailink has playback support */
  4353. .ignore_pmdown_time = 1,
  4354. .codec_dai_name = "snd-soc-dummy-dai",
  4355. .codec_name = "snd-soc-dummy",
  4356. },
  4357. {/* hw:x,31 */
  4358. .name = "TX3_CDC_DMA Hostless",
  4359. .stream_name = "TX3_CDC_DMA Hostless",
  4360. .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS",
  4361. .platform_name = "msm-pcm-hostless",
  4362. .dynamic = 1,
  4363. .dpcm_capture = 1,
  4364. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4365. SND_SOC_DPCM_TRIGGER_POST},
  4366. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4367. .ignore_suspend = 1,
  4368. .codec_dai_name = "snd-soc-dummy-dai",
  4369. .codec_name = "snd-soc-dummy",
  4370. },
  4371. {/* hw:x,32 */
  4372. .name = "Tertiary MI2S TX_Hostless",
  4373. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  4374. .cpu_dai_name = "TERT_MI2S_TX_HOSTLESS",
  4375. .platform_name = "msm-pcm-hostless",
  4376. .dynamic = 1,
  4377. .dpcm_capture = 1,
  4378. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4379. SND_SOC_DPCM_TRIGGER_POST},
  4380. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4381. .ignore_suspend = 1,
  4382. .ignore_pmdown_time = 1,
  4383. .codec_dai_name = "snd-soc-dummy-dai",
  4384. .codec_name = "snd-soc-dummy",
  4385. },
  4386. };
  4387. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  4388. {/* hw:x,33 */
  4389. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  4390. .stream_name = "WSA CDC DMA0 Capture",
  4391. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  4392. .platform_name = "msm-pcm-hostless",
  4393. .codec_name = "bolero_codec",
  4394. .codec_dai_name = "wsa_macro_vifeedback",
  4395. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  4396. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4397. .ignore_suspend = 1,
  4398. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4399. .ops = &msm_cdc_dma_be_ops,
  4400. },
  4401. };
  4402. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  4403. {/* hw:x,34 */
  4404. .name = MSM_DAILINK_NAME(ASM Loopback),
  4405. .stream_name = "MultiMedia6",
  4406. .cpu_dai_name = "MultiMedia6",
  4407. .platform_name = "msm-pcm-loopback",
  4408. .dynamic = 1,
  4409. .dpcm_playback = 1,
  4410. .dpcm_capture = 1,
  4411. .codec_dai_name = "snd-soc-dummy-dai",
  4412. .codec_name = "snd-soc-dummy",
  4413. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4414. SND_SOC_DPCM_TRIGGER_POST},
  4415. .ignore_suspend = 1,
  4416. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4417. .ignore_pmdown_time = 1,
  4418. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  4419. },
  4420. {/* hw:x,35 */
  4421. .name = "USB Audio Hostless",
  4422. .stream_name = "USB Audio Hostless",
  4423. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  4424. .platform_name = "msm-pcm-hostless",
  4425. .dynamic = 1,
  4426. .dpcm_playback = 1,
  4427. .dpcm_capture = 1,
  4428. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4429. SND_SOC_DPCM_TRIGGER_POST},
  4430. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4431. .ignore_suspend = 1,
  4432. .ignore_pmdown_time = 1,
  4433. .codec_dai_name = "snd-soc-dummy-dai",
  4434. .codec_name = "snd-soc-dummy",
  4435. },
  4436. {/* hw:x,36 */
  4437. .name = "SLIMBUS_7 Hostless",
  4438. .stream_name = "SLIMBUS_7 Hostless",
  4439. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  4440. .platform_name = "msm-pcm-hostless",
  4441. .dynamic = 1,
  4442. .dpcm_capture = 1,
  4443. .dpcm_playback = 1,
  4444. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4445. SND_SOC_DPCM_TRIGGER_POST},
  4446. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4447. .ignore_suspend = 1,
  4448. .ignore_pmdown_time = 1,
  4449. .codec_dai_name = "snd-soc-dummy-dai",
  4450. .codec_name = "snd-soc-dummy",
  4451. },
  4452. {/* hw:x,37 */
  4453. .name = "Compress Capture",
  4454. .stream_name = "Compress9",
  4455. .cpu_dai_name = "MultiMedia17",
  4456. .platform_name = "msm-compress-dsp",
  4457. .dynamic = 1,
  4458. .dpcm_capture = 1,
  4459. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4460. SND_SOC_DPCM_TRIGGER_POST},
  4461. .codec_dai_name = "snd-soc-dummy-dai",
  4462. .codec_name = "snd-soc-dummy",
  4463. .ignore_suspend = 1,
  4464. .ignore_pmdown_time = 1,
  4465. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  4466. },
  4467. {/* hw:x,38 */
  4468. .name = "SLIMBUS_8 Hostless",
  4469. .stream_name = "SLIMBUS_8 Hostless",
  4470. .cpu_dai_name = "SLIMBUS8_HOSTLESS",
  4471. .platform_name = "msm-pcm-hostless",
  4472. .dynamic = 1,
  4473. .dpcm_capture = 1,
  4474. .dpcm_playback = 1,
  4475. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4476. SND_SOC_DPCM_TRIGGER_POST},
  4477. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4478. .ignore_suspend = 1,
  4479. .ignore_pmdown_time = 1,
  4480. .codec_dai_name = "snd-soc-dummy-dai",
  4481. .codec_name = "snd-soc-dummy",
  4482. },
  4483. };
  4484. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  4485. /* Backend AFE DAI Links */
  4486. {
  4487. .name = LPASS_BE_AFE_PCM_RX,
  4488. .stream_name = "AFE Playback",
  4489. .cpu_dai_name = "msm-dai-q6-dev.224",
  4490. .platform_name = "msm-pcm-routing",
  4491. .codec_name = "msm-stub-codec.1",
  4492. .codec_dai_name = "msm-stub-rx",
  4493. .no_pcm = 1,
  4494. .dpcm_playback = 1,
  4495. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  4496. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4497. /* this dainlink has playback support */
  4498. .ignore_pmdown_time = 1,
  4499. .ignore_suspend = 1,
  4500. },
  4501. {
  4502. .name = LPASS_BE_AFE_PCM_TX,
  4503. .stream_name = "AFE Capture",
  4504. .cpu_dai_name = "msm-dai-q6-dev.225",
  4505. .platform_name = "msm-pcm-routing",
  4506. .codec_name = "msm-stub-codec.1",
  4507. .codec_dai_name = "msm-stub-tx",
  4508. .no_pcm = 1,
  4509. .dpcm_capture = 1,
  4510. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  4511. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4512. .ignore_suspend = 1,
  4513. },
  4514. /* Incall Record Uplink BACK END DAI Link */
  4515. {
  4516. .name = LPASS_BE_INCALL_RECORD_TX,
  4517. .stream_name = "Voice Uplink Capture",
  4518. .cpu_dai_name = "msm-dai-q6-dev.32772",
  4519. .platform_name = "msm-pcm-routing",
  4520. .codec_name = "msm-stub-codec.1",
  4521. .codec_dai_name = "msm-stub-tx",
  4522. .no_pcm = 1,
  4523. .dpcm_capture = 1,
  4524. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  4525. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4526. .ignore_suspend = 1,
  4527. },
  4528. /* Incall Record Downlink BACK END DAI Link */
  4529. {
  4530. .name = LPASS_BE_INCALL_RECORD_RX,
  4531. .stream_name = "Voice Downlink Capture",
  4532. .cpu_dai_name = "msm-dai-q6-dev.32771",
  4533. .platform_name = "msm-pcm-routing",
  4534. .codec_name = "msm-stub-codec.1",
  4535. .codec_dai_name = "msm-stub-tx",
  4536. .no_pcm = 1,
  4537. .dpcm_capture = 1,
  4538. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  4539. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4540. .ignore_suspend = 1,
  4541. },
  4542. /* Incall Music BACK END DAI Link */
  4543. {
  4544. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  4545. .stream_name = "Voice Farend Playback",
  4546. .cpu_dai_name = "msm-dai-q6-dev.32773",
  4547. .platform_name = "msm-pcm-routing",
  4548. .codec_name = "msm-stub-codec.1",
  4549. .codec_dai_name = "msm-stub-rx",
  4550. .no_pcm = 1,
  4551. .dpcm_playback = 1,
  4552. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  4553. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4554. .ignore_suspend = 1,
  4555. .ignore_pmdown_time = 1,
  4556. },
  4557. /* Incall Music 2 BACK END DAI Link */
  4558. {
  4559. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  4560. .stream_name = "Voice2 Farend Playback",
  4561. .cpu_dai_name = "msm-dai-q6-dev.32770",
  4562. .platform_name = "msm-pcm-routing",
  4563. .codec_name = "msm-stub-codec.1",
  4564. .codec_dai_name = "msm-stub-rx",
  4565. .no_pcm = 1,
  4566. .dpcm_playback = 1,
  4567. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  4568. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4569. .ignore_suspend = 1,
  4570. .ignore_pmdown_time = 1,
  4571. },
  4572. {
  4573. .name = LPASS_BE_USB_AUDIO_RX,
  4574. .stream_name = "USB Audio Playback",
  4575. .cpu_dai_name = "msm-dai-q6-dev.28672",
  4576. .platform_name = "msm-pcm-routing",
  4577. .codec_name = "msm-stub-codec.1",
  4578. .codec_dai_name = "msm-stub-rx",
  4579. .dynamic_be = 1,
  4580. .no_pcm = 1,
  4581. .dpcm_playback = 1,
  4582. .id = MSM_BACKEND_DAI_USB_RX,
  4583. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4584. .ignore_pmdown_time = 1,
  4585. .ignore_suspend = 1,
  4586. },
  4587. {
  4588. .name = LPASS_BE_USB_AUDIO_TX,
  4589. .stream_name = "USB Audio Capture",
  4590. .cpu_dai_name = "msm-dai-q6-dev.28673",
  4591. .platform_name = "msm-pcm-routing",
  4592. .codec_name = "msm-stub-codec.1",
  4593. .codec_dai_name = "msm-stub-tx",
  4594. .no_pcm = 1,
  4595. .dpcm_capture = 1,
  4596. .id = MSM_BACKEND_DAI_USB_TX,
  4597. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4598. .ignore_suspend = 1,
  4599. },
  4600. {
  4601. .name = LPASS_BE_PRI_TDM_RX_0,
  4602. .stream_name = "Primary TDM0 Playback",
  4603. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  4604. .platform_name = "msm-pcm-routing",
  4605. .codec_name = "msm-stub-codec.1",
  4606. .codec_dai_name = "msm-stub-rx",
  4607. .no_pcm = 1,
  4608. .dpcm_playback = 1,
  4609. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  4610. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4611. .ops = &kona_tdm_be_ops,
  4612. .ignore_suspend = 1,
  4613. .ignore_pmdown_time = 1,
  4614. },
  4615. {
  4616. .name = LPASS_BE_PRI_TDM_TX_0,
  4617. .stream_name = "Primary TDM0 Capture",
  4618. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  4619. .platform_name = "msm-pcm-routing",
  4620. .codec_name = "msm-stub-codec.1",
  4621. .codec_dai_name = "msm-stub-tx",
  4622. .no_pcm = 1,
  4623. .dpcm_capture = 1,
  4624. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  4625. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4626. .ops = &kona_tdm_be_ops,
  4627. .ignore_suspend = 1,
  4628. },
  4629. {
  4630. .name = LPASS_BE_SEC_TDM_RX_0,
  4631. .stream_name = "Secondary TDM0 Playback",
  4632. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  4633. .platform_name = "msm-pcm-routing",
  4634. .codec_name = "msm-stub-codec.1",
  4635. .codec_dai_name = "msm-stub-rx",
  4636. .no_pcm = 1,
  4637. .dpcm_playback = 1,
  4638. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  4639. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4640. .ops = &kona_tdm_be_ops,
  4641. .ignore_suspend = 1,
  4642. .ignore_pmdown_time = 1,
  4643. },
  4644. {
  4645. .name = LPASS_BE_SEC_TDM_TX_0,
  4646. .stream_name = "Secondary TDM0 Capture",
  4647. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  4648. .platform_name = "msm-pcm-routing",
  4649. .codec_name = "msm-stub-codec.1",
  4650. .codec_dai_name = "msm-stub-tx",
  4651. .no_pcm = 1,
  4652. .dpcm_capture = 1,
  4653. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  4654. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4655. .ops = &kona_tdm_be_ops,
  4656. .ignore_suspend = 1,
  4657. },
  4658. {
  4659. .name = LPASS_BE_TERT_TDM_RX_0,
  4660. .stream_name = "Tertiary TDM0 Playback",
  4661. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  4662. .platform_name = "msm-pcm-routing",
  4663. .codec_name = "msm-stub-codec.1",
  4664. .codec_dai_name = "msm-stub-rx",
  4665. .no_pcm = 1,
  4666. .dpcm_playback = 1,
  4667. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  4668. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4669. .ops = &kona_tdm_be_ops,
  4670. .ignore_suspend = 1,
  4671. .ignore_pmdown_time = 1,
  4672. },
  4673. {
  4674. .name = LPASS_BE_TERT_TDM_TX_0,
  4675. .stream_name = "Tertiary TDM0 Capture",
  4676. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  4677. .platform_name = "msm-pcm-routing",
  4678. .codec_name = "msm-stub-codec.1",
  4679. .codec_dai_name = "msm-stub-tx",
  4680. .no_pcm = 1,
  4681. .dpcm_capture = 1,
  4682. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  4683. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4684. .ops = &kona_tdm_be_ops,
  4685. .ignore_suspend = 1,
  4686. },
  4687. };
  4688. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  4689. {
  4690. .name = LPASS_BE_SLIMBUS_7_RX,
  4691. .stream_name = "Slimbus7 Playback",
  4692. .cpu_dai_name = "msm-dai-q6-dev.16398",
  4693. .platform_name = "msm-pcm-routing",
  4694. .codec_name = "btfmslim_slave",
  4695. /* BT codec driver determines capabilities based on
  4696. * dai name, bt codecdai name should always contains
  4697. * supported usecase information
  4698. */
  4699. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  4700. .no_pcm = 1,
  4701. .dpcm_playback = 1,
  4702. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  4703. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4704. .init = &msm_wcn_init,
  4705. .ops = &msm_wcn_ops,
  4706. /* dai link has playback support */
  4707. .ignore_pmdown_time = 1,
  4708. .ignore_suspend = 1,
  4709. },
  4710. {
  4711. .name = LPASS_BE_SLIMBUS_7_TX,
  4712. .stream_name = "Slimbus7 Capture",
  4713. .cpu_dai_name = "msm-dai-q6-dev.16399",
  4714. .platform_name = "msm-pcm-routing",
  4715. .codec_name = "btfmslim_slave",
  4716. .codec_dai_name = "btfm_bt_sco_slim_tx",
  4717. .no_pcm = 1,
  4718. .dpcm_capture = 1,
  4719. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  4720. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4721. .ops = &msm_wcn_ops,
  4722. .ignore_suspend = 1,
  4723. },
  4724. };
  4725. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  4726. {
  4727. .name = LPASS_BE_SLIMBUS_7_RX,
  4728. .stream_name = "Slimbus7 Playback",
  4729. .cpu_dai_name = "msm-dai-q6-dev.16398",
  4730. .platform_name = "msm-pcm-routing",
  4731. .codec_name = "btfmslim_slave",
  4732. /* BT codec driver determines capabilities based on
  4733. * dai name, bt codecdai name should always contains
  4734. * supported usecase information
  4735. */
  4736. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  4737. .no_pcm = 1,
  4738. .dpcm_playback = 1,
  4739. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  4740. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4741. .init = &msm_wcn_init_lito,
  4742. .ops = &msm_wcn_ops_lito,
  4743. /* dai link has playback support */
  4744. .ignore_pmdown_time = 1,
  4745. .ignore_suspend = 1,
  4746. },
  4747. {
  4748. .name = LPASS_BE_SLIMBUS_7_TX,
  4749. .stream_name = "Slimbus7 Capture",
  4750. .cpu_dai_name = "msm-dai-q6-dev.16399",
  4751. .platform_name = "msm-pcm-routing",
  4752. .codec_name = "btfmslim_slave",
  4753. .codec_dai_name = "btfm_bt_sco_slim_tx",
  4754. .no_pcm = 1,
  4755. .dpcm_capture = 1,
  4756. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  4757. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4758. .ops = &msm_wcn_ops_lito,
  4759. .ignore_suspend = 1,
  4760. },
  4761. {
  4762. .name = LPASS_BE_SLIMBUS_8_TX,
  4763. .stream_name = "Slimbus8 Capture",
  4764. .cpu_dai_name = "msm-dai-q6-dev.16401",
  4765. .platform_name = "msm-pcm-routing",
  4766. .codec_name = "btfmslim_slave",
  4767. .codec_dai_name = "btfm_fm_slim_tx",
  4768. .no_pcm = 1,
  4769. .dpcm_capture = 1,
  4770. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  4771. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4772. .ops = &msm_wcn_ops_lito,
  4773. .ignore_suspend = 1,
  4774. },
  4775. };
  4776. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  4777. /* DISP PORT BACK END DAI Link */
  4778. {
  4779. .name = LPASS_BE_DISPLAY_PORT,
  4780. .stream_name = "Display Port Playback",
  4781. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4782. .platform_name = "msm-pcm-routing",
  4783. .codec_name = "msm-ext-disp-audio-codec-rx",
  4784. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  4785. .no_pcm = 1,
  4786. .dpcm_playback = 1,
  4787. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  4788. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4789. .ignore_pmdown_time = 1,
  4790. .ignore_suspend = 1,
  4791. },
  4792. /* DISP PORT 1 BACK END DAI Link */
  4793. {
  4794. .name = LPASS_BE_DISPLAY_PORT1,
  4795. .stream_name = "Display Port1 Playback",
  4796. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4797. .platform_name = "msm-pcm-routing",
  4798. .codec_name = "msm-ext-disp-audio-codec-rx",
  4799. .codec_dai_name = "msm_dp_audio_codec_rx1_dai",
  4800. .no_pcm = 1,
  4801. .dpcm_playback = 1,
  4802. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  4803. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4804. .ignore_pmdown_time = 1,
  4805. .ignore_suspend = 1,
  4806. },
  4807. };
  4808. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  4809. {
  4810. .name = LPASS_BE_PRI_MI2S_RX,
  4811. .stream_name = "Primary MI2S Playback",
  4812. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4813. .platform_name = "msm-pcm-routing",
  4814. .codec_name = "msm-stub-codec.1",
  4815. .codec_dai_name = "msm-stub-rx",
  4816. .no_pcm = 1,
  4817. .dpcm_playback = 1,
  4818. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  4819. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4820. .ops = &msm_mi2s_be_ops,
  4821. .ignore_suspend = 1,
  4822. .ignore_pmdown_time = 1,
  4823. },
  4824. {
  4825. .name = LPASS_BE_PRI_MI2S_TX,
  4826. .stream_name = "Primary MI2S Capture",
  4827. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4828. .platform_name = "msm-pcm-routing",
  4829. .codec_name = "msm-stub-codec.1",
  4830. .codec_dai_name = "msm-stub-tx",
  4831. .no_pcm = 1,
  4832. .dpcm_capture = 1,
  4833. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  4834. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4835. .ops = &msm_mi2s_be_ops,
  4836. .ignore_suspend = 1,
  4837. },
  4838. {
  4839. .name = LPASS_BE_SEC_MI2S_RX,
  4840. .stream_name = "Secondary MI2S Playback",
  4841. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4842. .platform_name = "msm-pcm-routing",
  4843. .codec_name = "msm-stub-codec.1",
  4844. .codec_dai_name = "msm-stub-rx",
  4845. .no_pcm = 1,
  4846. .dpcm_playback = 1,
  4847. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  4848. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4849. .ops = &msm_mi2s_be_ops,
  4850. .ignore_suspend = 1,
  4851. .ignore_pmdown_time = 1,
  4852. },
  4853. {
  4854. .name = LPASS_BE_SEC_MI2S_TX,
  4855. .stream_name = "Secondary MI2S Capture",
  4856. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4857. .platform_name = "msm-pcm-routing",
  4858. .codec_name = "msm-stub-codec.1",
  4859. .codec_dai_name = "msm-stub-tx",
  4860. .no_pcm = 1,
  4861. .dpcm_capture = 1,
  4862. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  4863. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4864. .ops = &msm_mi2s_be_ops,
  4865. .ignore_suspend = 1,
  4866. },
  4867. {
  4868. .name = LPASS_BE_TERT_MI2S_RX,
  4869. .stream_name = "Tertiary MI2S Playback",
  4870. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4871. .platform_name = "msm-pcm-routing",
  4872. .codec_name = "msm-stub-codec.1",
  4873. .codec_dai_name = "msm-stub-rx",
  4874. .no_pcm = 1,
  4875. .dpcm_playback = 1,
  4876. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  4877. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4878. .ops = &msm_mi2s_be_ops,
  4879. .ignore_suspend = 1,
  4880. .ignore_pmdown_time = 1,
  4881. },
  4882. {
  4883. .name = LPASS_BE_TERT_MI2S_TX,
  4884. .stream_name = "Tertiary MI2S Capture",
  4885. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4886. .platform_name = "msm-pcm-routing",
  4887. .codec_name = "msm-stub-codec.1",
  4888. .codec_dai_name = "msm-stub-tx",
  4889. .no_pcm = 1,
  4890. .dpcm_capture = 1,
  4891. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  4892. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4893. .ops = &msm_mi2s_be_ops,
  4894. .ignore_suspend = 1,
  4895. },
  4896. };
  4897. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  4898. /* Primary AUX PCM Backend DAI Links */
  4899. {
  4900. .name = LPASS_BE_AUXPCM_RX,
  4901. .stream_name = "AUX PCM Playback",
  4902. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4903. .platform_name = "msm-pcm-routing",
  4904. .codec_name = "msm-stub-codec.1",
  4905. .codec_dai_name = "msm-stub-rx",
  4906. .no_pcm = 1,
  4907. .dpcm_playback = 1,
  4908. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  4909. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4910. .ignore_pmdown_time = 1,
  4911. .ignore_suspend = 1,
  4912. },
  4913. {
  4914. .name = LPASS_BE_AUXPCM_TX,
  4915. .stream_name = "AUX PCM Capture",
  4916. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4917. .platform_name = "msm-pcm-routing",
  4918. .codec_name = "msm-stub-codec.1",
  4919. .codec_dai_name = "msm-stub-tx",
  4920. .no_pcm = 1,
  4921. .dpcm_capture = 1,
  4922. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  4923. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4924. .ignore_suspend = 1,
  4925. },
  4926. /* Secondary AUX PCM Backend DAI Links */
  4927. {
  4928. .name = LPASS_BE_SEC_AUXPCM_RX,
  4929. .stream_name = "Sec AUX PCM Playback",
  4930. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4931. .platform_name = "msm-pcm-routing",
  4932. .codec_name = "msm-stub-codec.1",
  4933. .codec_dai_name = "msm-stub-rx",
  4934. .no_pcm = 1,
  4935. .dpcm_playback = 1,
  4936. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  4937. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4938. .ignore_pmdown_time = 1,
  4939. .ignore_suspend = 1,
  4940. },
  4941. {
  4942. .name = LPASS_BE_SEC_AUXPCM_TX,
  4943. .stream_name = "Sec AUX PCM Capture",
  4944. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4945. .platform_name = "msm-pcm-routing",
  4946. .codec_name = "msm-stub-codec.1",
  4947. .codec_dai_name = "msm-stub-tx",
  4948. .no_pcm = 1,
  4949. .dpcm_capture = 1,
  4950. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  4951. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4952. .ignore_suspend = 1,
  4953. },
  4954. /* Tertiary AUX PCM Backend DAI Links */
  4955. {
  4956. .name = LPASS_BE_TERT_AUXPCM_RX,
  4957. .stream_name = "Tert AUX PCM Playback",
  4958. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4959. .platform_name = "msm-pcm-routing",
  4960. .codec_name = "msm-stub-codec.1",
  4961. .codec_dai_name = "msm-stub-rx",
  4962. .no_pcm = 1,
  4963. .dpcm_playback = 1,
  4964. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  4965. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4966. .ignore_suspend = 1,
  4967. },
  4968. {
  4969. .name = LPASS_BE_TERT_AUXPCM_TX,
  4970. .stream_name = "Tert AUX PCM Capture",
  4971. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4972. .platform_name = "msm-pcm-routing",
  4973. .codec_name = "msm-stub-codec.1",
  4974. .codec_dai_name = "msm-stub-tx",
  4975. .no_pcm = 1,
  4976. .dpcm_capture = 1,
  4977. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  4978. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4979. .ignore_suspend = 1,
  4980. },
  4981. };
  4982. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  4983. /* WSA CDC DMA Backend DAI Links */
  4984. {
  4985. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  4986. .stream_name = "WSA CDC DMA0 Playback",
  4987. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  4988. .platform_name = "msm-pcm-routing",
  4989. .codec_name = "bolero_codec",
  4990. .codec_dai_name = "wsa_macro_rx1",
  4991. .no_pcm = 1,
  4992. .dpcm_playback = 1,
  4993. .init = &msm_int_audrx_init,
  4994. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  4995. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4996. .ignore_pmdown_time = 1,
  4997. .ignore_suspend = 1,
  4998. .ops = &msm_cdc_dma_be_ops,
  4999. },
  5000. {
  5001. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  5002. .stream_name = "WSA CDC DMA1 Playback",
  5003. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  5004. .platform_name = "msm-pcm-routing",
  5005. .codec_name = "bolero_codec",
  5006. .codec_dai_name = "wsa_macro_rx_mix",
  5007. .no_pcm = 1,
  5008. .dpcm_playback = 1,
  5009. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  5010. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5011. .ignore_pmdown_time = 1,
  5012. .ignore_suspend = 1,
  5013. .ops = &msm_cdc_dma_be_ops,
  5014. },
  5015. {
  5016. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  5017. .stream_name = "WSA CDC DMA1 Capture",
  5018. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  5019. .platform_name = "msm-pcm-routing",
  5020. .codec_name = "bolero_codec",
  5021. .codec_dai_name = "wsa_macro_echo",
  5022. .no_pcm = 1,
  5023. .dpcm_capture = 1,
  5024. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  5025. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5026. .ignore_suspend = 1,
  5027. .ops = &msm_cdc_dma_be_ops,
  5028. },
  5029. };
  5030. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  5031. /* RX CDC DMA Backend DAI Links */
  5032. {
  5033. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  5034. .stream_name = "RX CDC DMA0 Playback",
  5035. .cpu_dai_name = "msm-dai-cdc-dma-dev.45104",
  5036. .platform_name = "msm-pcm-routing",
  5037. .codec_name = "bolero_codec",
  5038. .codec_dai_name = "rx_macro_rx1",
  5039. .dynamic_be = 1,
  5040. .no_pcm = 1,
  5041. .dpcm_playback = 1,
  5042. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  5043. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5044. .ignore_pmdown_time = 1,
  5045. .ignore_suspend = 1,
  5046. .ops = &msm_cdc_dma_be_ops,
  5047. },
  5048. {
  5049. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  5050. .stream_name = "RX CDC DMA1 Playback",
  5051. .cpu_dai_name = "msm-dai-cdc-dma-dev.45106",
  5052. .platform_name = "msm-pcm-routing",
  5053. .codec_name = "bolero_codec",
  5054. .codec_dai_name = "rx_macro_rx2",
  5055. .dynamic_be = 1,
  5056. .no_pcm = 1,
  5057. .dpcm_playback = 1,
  5058. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  5059. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5060. .ignore_pmdown_time = 1,
  5061. .ignore_suspend = 1,
  5062. .ops = &msm_cdc_dma_be_ops,
  5063. },
  5064. {
  5065. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  5066. .stream_name = "RX CDC DMA2 Playback",
  5067. .cpu_dai_name = "msm-dai-cdc-dma-dev.45108",
  5068. .platform_name = "msm-pcm-routing",
  5069. .codec_name = "bolero_codec",
  5070. .codec_dai_name = "rx_macro_rx3",
  5071. .dynamic_be = 1,
  5072. .no_pcm = 1,
  5073. .dpcm_playback = 1,
  5074. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  5075. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5076. .ignore_pmdown_time = 1,
  5077. .ignore_suspend = 1,
  5078. .ops = &msm_cdc_dma_be_ops,
  5079. },
  5080. {
  5081. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  5082. .stream_name = "RX CDC DMA3 Playback",
  5083. .cpu_dai_name = "msm-dai-cdc-dma-dev.45110",
  5084. .platform_name = "msm-pcm-routing",
  5085. .codec_name = "bolero_codec",
  5086. .codec_dai_name = "rx_macro_rx4",
  5087. .dynamic_be = 1,
  5088. .no_pcm = 1,
  5089. .dpcm_playback = 1,
  5090. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  5091. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5092. .ignore_pmdown_time = 1,
  5093. .ignore_suspend = 1,
  5094. .ops = &msm_cdc_dma_be_ops,
  5095. },
  5096. /* TX CDC DMA Backend DAI Links */
  5097. {
  5098. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  5099. .stream_name = "TX CDC DMA3 Capture",
  5100. .cpu_dai_name = "msm-dai-cdc-dma-dev.45111",
  5101. .platform_name = "msm-pcm-routing",
  5102. .codec_name = "bolero_codec",
  5103. .codec_dai_name = "tx_macro_tx1",
  5104. .no_pcm = 1,
  5105. .dpcm_capture = 1,
  5106. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  5107. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5108. .ignore_suspend = 1,
  5109. .ops = &msm_cdc_dma_be_ops,
  5110. },
  5111. {
  5112. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  5113. .stream_name = "TX CDC DMA4 Capture",
  5114. .cpu_dai_name = "msm-dai-cdc-dma-dev.45113",
  5115. .platform_name = "msm-pcm-routing",
  5116. .codec_name = "bolero_codec",
  5117. .codec_dai_name = "tx_macro_tx2",
  5118. .no_pcm = 1,
  5119. .dpcm_capture = 1,
  5120. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  5121. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5122. .ignore_suspend = 1,
  5123. .ops = &msm_cdc_dma_be_ops,
  5124. },
  5125. };
  5126. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  5127. {
  5128. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  5129. .stream_name = "VA CDC DMA0 Capture",
  5130. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  5131. .platform_name = "msm-pcm-routing",
  5132. .codec_name = "bolero_codec",
  5133. .codec_dai_name = "va_macro_tx1",
  5134. .no_pcm = 1,
  5135. .dpcm_capture = 1,
  5136. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  5137. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5138. .ignore_suspend = 1,
  5139. .ops = &msm_cdc_dma_be_ops,
  5140. },
  5141. {
  5142. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  5143. .stream_name = "VA CDC DMA1 Capture",
  5144. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  5145. .platform_name = "msm-pcm-routing",
  5146. .codec_name = "bolero_codec",
  5147. .codec_dai_name = "va_macro_tx2",
  5148. .no_pcm = 1,
  5149. .dpcm_capture = 1,
  5150. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  5151. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5152. .ignore_suspend = 1,
  5153. .ops = &msm_cdc_dma_be_ops,
  5154. },
  5155. {
  5156. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  5157. .stream_name = "VA CDC DMA2 Capture",
  5158. .cpu_dai_name = "msm-dai-cdc-dma-dev.45093",
  5159. .platform_name = "msm-pcm-routing",
  5160. .codec_name = "bolero_codec",
  5161. .codec_dai_name = "va_macro_tx3",
  5162. .no_pcm = 1,
  5163. .dpcm_capture = 1,
  5164. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  5165. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5166. .ignore_suspend = 1,
  5167. .ops = &msm_cdc_dma_be_ops,
  5168. },
  5169. };
  5170. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  5171. {
  5172. .name = LPASS_BE_AFE_LOOPBACK_TX,
  5173. .stream_name = "AFE Loopback Capture",
  5174. .cpu_dai_name = "msm-dai-q6-dev.24577",
  5175. .platform_name = "msm-pcm-routing",
  5176. .codec_name = "msm-stub-codec.1",
  5177. .codec_dai_name = "msm-stub-tx",
  5178. .no_pcm = 1,
  5179. .dpcm_capture = 1,
  5180. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  5181. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5182. .ignore_pmdown_time = 1,
  5183. .ignore_suspend = 1,
  5184. },
  5185. };
  5186. static struct snd_soc_dai_link msm_kona_dai_links[
  5187. ARRAY_SIZE(msm_common_dai_links) +
  5188. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  5189. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  5190. ARRAY_SIZE(msm_common_be_dai_links) +
  5191. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  5192. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  5193. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  5194. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  5195. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  5196. ARRAY_SIZE(ext_disp_be_dai_link) +
  5197. ARRAY_SIZE(msm_wcn_be_dai_links) +
  5198. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link) +
  5199. ARRAY_SIZE(msm_wcn_btfm_be_dai_links)];
  5200. static int msm_populate_dai_link_component_of_node(
  5201. struct snd_soc_card *card)
  5202. {
  5203. int i, index, ret = 0;
  5204. struct device *cdev = card->dev;
  5205. struct snd_soc_dai_link *dai_link = card->dai_link;
  5206. struct device_node *np;
  5207. if (!cdev) {
  5208. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  5209. return -ENODEV;
  5210. }
  5211. for (i = 0; i < card->num_links; i++) {
  5212. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  5213. continue;
  5214. /* populate platform_of_node for snd card dai links */
  5215. if (dai_link[i].platform_name &&
  5216. !dai_link[i].platform_of_node) {
  5217. index = of_property_match_string(cdev->of_node,
  5218. "asoc-platform-names",
  5219. dai_link[i].platform_name);
  5220. if (index < 0) {
  5221. dev_err(cdev, "%s: No match found for platform name: %s\n",
  5222. __func__, dai_link[i].platform_name);
  5223. ret = index;
  5224. goto err;
  5225. }
  5226. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  5227. index);
  5228. if (!np) {
  5229. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  5230. __func__, dai_link[i].platform_name,
  5231. index);
  5232. ret = -ENODEV;
  5233. goto err;
  5234. }
  5235. dai_link[i].platform_of_node = np;
  5236. dai_link[i].platform_name = NULL;
  5237. }
  5238. /* populate cpu_of_node for snd card dai links */
  5239. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  5240. index = of_property_match_string(cdev->of_node,
  5241. "asoc-cpu-names",
  5242. dai_link[i].cpu_dai_name);
  5243. if (index >= 0) {
  5244. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  5245. index);
  5246. if (!np) {
  5247. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  5248. __func__,
  5249. dai_link[i].cpu_dai_name);
  5250. ret = -ENODEV;
  5251. goto err;
  5252. }
  5253. dai_link[i].cpu_of_node = np;
  5254. dai_link[i].cpu_dai_name = NULL;
  5255. }
  5256. }
  5257. /* populate codec_of_node for snd card dai links */
  5258. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  5259. index = of_property_match_string(cdev->of_node,
  5260. "asoc-codec-names",
  5261. dai_link[i].codec_name);
  5262. if (index < 0)
  5263. continue;
  5264. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  5265. index);
  5266. if (!np) {
  5267. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  5268. __func__, dai_link[i].codec_name);
  5269. ret = -ENODEV;
  5270. goto err;
  5271. }
  5272. dai_link[i].codec_of_node = np;
  5273. dai_link[i].codec_name = NULL;
  5274. }
  5275. }
  5276. err:
  5277. return ret;
  5278. }
  5279. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  5280. {
  5281. int ret = -EINVAL;
  5282. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  5283. if (!component) {
  5284. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  5285. return ret;
  5286. }
  5287. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  5288. ARRAY_SIZE(msm_snd_controls));
  5289. if (ret < 0) {
  5290. dev_err(component->dev,
  5291. "%s: add_codec_controls failed, err = %d\n",
  5292. __func__, ret);
  5293. return ret;
  5294. }
  5295. return ret;
  5296. }
  5297. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  5298. struct snd_pcm_hw_params *params)
  5299. {
  5300. return 0;
  5301. }
  5302. static struct snd_soc_ops msm_stub_be_ops = {
  5303. .hw_params = msm_snd_stub_hw_params,
  5304. };
  5305. struct snd_soc_card snd_soc_card_stub_msm = {
  5306. .name = "kona-stub-snd-card",
  5307. };
  5308. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  5309. /* FrontEnd DAI Links */
  5310. {
  5311. .name = "MSMSTUB Media1",
  5312. .stream_name = "MultiMedia1",
  5313. .cpu_dai_name = "MultiMedia1",
  5314. .platform_name = "msm-pcm-dsp.0",
  5315. .dynamic = 1,
  5316. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5317. .dpcm_playback = 1,
  5318. .dpcm_capture = 1,
  5319. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5320. SND_SOC_DPCM_TRIGGER_POST},
  5321. .codec_dai_name = "snd-soc-dummy-dai",
  5322. .codec_name = "snd-soc-dummy",
  5323. .ignore_suspend = 1,
  5324. /* this dainlink has playback support */
  5325. .ignore_pmdown_time = 1,
  5326. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  5327. },
  5328. };
  5329. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  5330. /* Backend DAI Links */
  5331. {
  5332. .name = LPASS_BE_AUXPCM_RX,
  5333. .stream_name = "AUX PCM Playback",
  5334. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  5335. .platform_name = "msm-pcm-routing",
  5336. .codec_name = "msm-stub-codec.1",
  5337. .codec_dai_name = "msm-stub-rx",
  5338. .no_pcm = 1,
  5339. .dpcm_playback = 1,
  5340. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  5341. .init = &msm_audrx_stub_init,
  5342. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5343. .ignore_pmdown_time = 1,
  5344. .ignore_suspend = 1,
  5345. .ops = &msm_stub_be_ops,
  5346. },
  5347. {
  5348. .name = LPASS_BE_AUXPCM_TX,
  5349. .stream_name = "AUX PCM Capture",
  5350. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  5351. .platform_name = "msm-pcm-routing",
  5352. .codec_name = "msm-stub-codec.1",
  5353. .codec_dai_name = "msm-stub-tx",
  5354. .no_pcm = 1,
  5355. .dpcm_capture = 1,
  5356. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  5357. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5358. .ignore_suspend = 1,
  5359. .ops = &msm_stub_be_ops,
  5360. },
  5361. };
  5362. static struct snd_soc_dai_link msm_stub_dai_links[
  5363. ARRAY_SIZE(msm_stub_fe_dai_links) +
  5364. ARRAY_SIZE(msm_stub_be_dai_links)];
  5365. static const struct of_device_id kona_asoc_machine_of_match[] = {
  5366. { .compatible = "qcom,kona-asoc-snd",
  5367. .data = "codec"},
  5368. { .compatible = "qcom,kona-asoc-snd-stub",
  5369. .data = "stub_codec"},
  5370. {},
  5371. };
  5372. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  5373. {
  5374. struct snd_soc_card *card = NULL;
  5375. struct snd_soc_dai_link *dailink = NULL;
  5376. int len_1 = 0;
  5377. int len_2 = 0;
  5378. int total_links = 0;
  5379. int rc = 0;
  5380. u32 mi2s_audio_intf = 0;
  5381. u32 auxpcm_audio_intf = 0;
  5382. u32 val = 0;
  5383. u32 wcn_btfm_intf = 0;
  5384. const struct of_device_id *match;
  5385. match = of_match_node(kona_asoc_machine_of_match, dev->of_node);
  5386. if (!match) {
  5387. dev_err(dev, "%s: No DT match found for sound card\n",
  5388. __func__);
  5389. return NULL;
  5390. }
  5391. if (!strcmp(match->data, "codec")) {
  5392. card = &snd_soc_card_kona_msm;
  5393. memcpy(msm_kona_dai_links + total_links,
  5394. msm_common_dai_links,
  5395. sizeof(msm_common_dai_links));
  5396. total_links += ARRAY_SIZE(msm_common_dai_links);
  5397. memcpy(msm_kona_dai_links + total_links,
  5398. msm_bolero_fe_dai_links,
  5399. sizeof(msm_bolero_fe_dai_links));
  5400. total_links +=
  5401. ARRAY_SIZE(msm_bolero_fe_dai_links);
  5402. memcpy(msm_kona_dai_links + total_links,
  5403. msm_common_misc_fe_dai_links,
  5404. sizeof(msm_common_misc_fe_dai_links));
  5405. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  5406. memcpy(msm_kona_dai_links + total_links,
  5407. msm_common_be_dai_links,
  5408. sizeof(msm_common_be_dai_links));
  5409. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  5410. memcpy(msm_kona_dai_links + total_links,
  5411. msm_wsa_cdc_dma_be_dai_links,
  5412. sizeof(msm_wsa_cdc_dma_be_dai_links));
  5413. total_links +=
  5414. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  5415. memcpy(msm_kona_dai_links + total_links,
  5416. msm_rx_tx_cdc_dma_be_dai_links,
  5417. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  5418. total_links +=
  5419. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  5420. memcpy(msm_kona_dai_links + total_links,
  5421. msm_va_cdc_dma_be_dai_links,
  5422. sizeof(msm_va_cdc_dma_be_dai_links));
  5423. total_links +=
  5424. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  5425. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  5426. &mi2s_audio_intf);
  5427. if (rc) {
  5428. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  5429. __func__);
  5430. } else {
  5431. if (mi2s_audio_intf) {
  5432. memcpy(msm_kona_dai_links + total_links,
  5433. msm_mi2s_be_dai_links,
  5434. sizeof(msm_mi2s_be_dai_links));
  5435. total_links +=
  5436. ARRAY_SIZE(msm_mi2s_be_dai_links);
  5437. }
  5438. }
  5439. rc = of_property_read_u32(dev->of_node,
  5440. "qcom,auxpcm-audio-intf",
  5441. &auxpcm_audio_intf);
  5442. if (rc) {
  5443. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  5444. __func__);
  5445. } else {
  5446. if (auxpcm_audio_intf) {
  5447. memcpy(msm_kona_dai_links + total_links,
  5448. msm_auxpcm_be_dai_links,
  5449. sizeof(msm_auxpcm_be_dai_links));
  5450. total_links +=
  5451. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  5452. }
  5453. }
  5454. rc = of_property_read_u32(dev->of_node,
  5455. "qcom,ext-disp-audio-rx", &val);
  5456. if (!rc && val) {
  5457. dev_dbg(dev, "%s(): ext disp audio support present\n",
  5458. __func__);
  5459. memcpy(msm_kona_dai_links + total_links,
  5460. ext_disp_be_dai_link,
  5461. sizeof(ext_disp_be_dai_link));
  5462. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  5463. }
  5464. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  5465. if (!rc && val) {
  5466. dev_dbg(dev, "%s(): WCN BT support present\n",
  5467. __func__);
  5468. memcpy(msm_kona_dai_links + total_links,
  5469. msm_wcn_be_dai_links,
  5470. sizeof(msm_wcn_be_dai_links));
  5471. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  5472. }
  5473. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  5474. &val);
  5475. if (!rc && val) {
  5476. memcpy(msm_kona_dai_links + total_links,
  5477. msm_afe_rxtx_lb_be_dai_link,
  5478. sizeof(msm_afe_rxtx_lb_be_dai_link));
  5479. total_links +=
  5480. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  5481. }
  5482. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  5483. &wcn_btfm_intf);
  5484. if (rc) {
  5485. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  5486. __func__);
  5487. } else {
  5488. if (wcn_btfm_intf) {
  5489. memcpy(msm_kona_dai_links + total_links,
  5490. msm_wcn_btfm_be_dai_links,
  5491. sizeof(msm_wcn_btfm_be_dai_links));
  5492. total_links +=
  5493. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  5494. }
  5495. }
  5496. dailink = msm_kona_dai_links;
  5497. } else if(!strcmp(match->data, "stub_codec")) {
  5498. card = &snd_soc_card_stub_msm;
  5499. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  5500. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  5501. memcpy(msm_stub_dai_links,
  5502. msm_stub_fe_dai_links,
  5503. sizeof(msm_stub_fe_dai_links));
  5504. memcpy(msm_stub_dai_links + len_1,
  5505. msm_stub_be_dai_links,
  5506. sizeof(msm_stub_be_dai_links));
  5507. dailink = msm_stub_dai_links;
  5508. total_links = len_2;
  5509. }
  5510. if (card) {
  5511. card->dai_link = dailink;
  5512. card->num_links = total_links;
  5513. }
  5514. return card;
  5515. }
  5516. static int msm_wsa881x_init(struct snd_soc_component *component)
  5517. {
  5518. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5519. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5520. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  5521. SPKR_L_BOOST, SPKR_L_VI};
  5522. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  5523. SPKR_R_BOOST, SPKR_R_VI};
  5524. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  5525. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  5526. struct msm_asoc_mach_data *pdata;
  5527. struct snd_soc_dapm_context *dapm;
  5528. struct snd_card *card;
  5529. struct snd_info_entry *entry;
  5530. int ret = 0;
  5531. if (!component) {
  5532. pr_err("%s component is NULL\n", __func__);
  5533. return -EINVAL;
  5534. }
  5535. card = component->card->snd_card;
  5536. dapm = snd_soc_component_get_dapm(component);
  5537. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  5538. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  5539. __func__, component->name);
  5540. wsa881x_set_channel_map(component, &spkleft_ports[0],
  5541. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5542. &ch_rate[0], &spkleft_port_types[0]);
  5543. if (dapm->component) {
  5544. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  5545. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  5546. }
  5547. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  5548. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  5549. __func__, component->name);
  5550. wsa881x_set_channel_map(component, &spkright_ports[0],
  5551. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5552. &ch_rate[0], &spkright_port_types[0]);
  5553. if (dapm->component) {
  5554. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  5555. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  5556. }
  5557. } else {
  5558. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  5559. component->name);
  5560. ret = -EINVAL;
  5561. goto err;
  5562. }
  5563. pdata = snd_soc_card_get_drvdata(component->card);
  5564. if (!pdata->codec_root) {
  5565. entry = snd_info_create_subdir(card->module, "codecs",
  5566. card->proc_root);
  5567. if (!entry) {
  5568. pr_err("%s: Cannot create codecs module entry\n",
  5569. __func__);
  5570. ret = 0;
  5571. goto err;
  5572. }
  5573. pdata->codec_root = entry;
  5574. }
  5575. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  5576. component);
  5577. err:
  5578. return ret;
  5579. }
  5580. static int msm_aux_codec_init(struct snd_soc_component *component)
  5581. {
  5582. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  5583. int ret = 0;
  5584. void *mbhc_calibration;
  5585. struct snd_info_entry *entry;
  5586. struct snd_card *card = component->card->snd_card;
  5587. struct msm_asoc_mach_data *pdata;
  5588. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  5589. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  5590. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  5591. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  5592. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  5593. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  5594. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  5595. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  5596. snd_soc_dapm_sync(dapm);
  5597. pdata = snd_soc_card_get_drvdata(component->card);
  5598. if (!pdata->codec_root) {
  5599. entry = snd_info_create_subdir(card->module, "codecs",
  5600. card->proc_root);
  5601. if (!entry) {
  5602. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  5603. __func__);
  5604. ret = 0;
  5605. goto mbhc_cfg_cal;
  5606. }
  5607. pdata->codec_root = entry;
  5608. }
  5609. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  5610. mbhc_cfg_cal:
  5611. mbhc_calibration = def_wcd_mbhc_cal();
  5612. if (!mbhc_calibration)
  5613. return -ENOMEM;
  5614. wcd_mbhc_cfg.calibration = mbhc_calibration;
  5615. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  5616. if (ret) {
  5617. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  5618. __func__, ret);
  5619. goto err_hs_detect;
  5620. }
  5621. return 0;
  5622. err_hs_detect:
  5623. kfree(mbhc_calibration);
  5624. return ret;
  5625. }
  5626. static int msm_init_aux_dev(struct platform_device *pdev,
  5627. struct snd_soc_card *card)
  5628. {
  5629. struct device_node *wsa_of_node;
  5630. struct device_node *aux_codec_of_node;
  5631. u32 wsa_max_devs;
  5632. u32 wsa_dev_cnt;
  5633. u32 codec_aux_dev_cnt = 0;
  5634. int i;
  5635. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  5636. struct aux_codec_dev_info *aux_cdc_dev_info;
  5637. const char *auxdev_name_prefix[1];
  5638. char *dev_name_str = NULL;
  5639. int found = 0;
  5640. int codecs_found = 0;
  5641. int ret = 0;
  5642. /* Get maximum WSA device count for this platform */
  5643. ret = of_property_read_u32(pdev->dev.of_node,
  5644. "qcom,wsa-max-devs", &wsa_max_devs);
  5645. if (ret) {
  5646. dev_info(&pdev->dev,
  5647. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  5648. __func__, pdev->dev.of_node->full_name, ret);
  5649. wsa_max_devs = 0;
  5650. goto codec_aux_dev;
  5651. }
  5652. if (wsa_max_devs == 0) {
  5653. dev_warn(&pdev->dev,
  5654. "%s: Max WSA devices is 0 for this target?\n",
  5655. __func__);
  5656. goto codec_aux_dev;
  5657. }
  5658. /* Get count of WSA device phandles for this platform */
  5659. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  5660. "qcom,wsa-devs", NULL);
  5661. if (wsa_dev_cnt == -ENOENT) {
  5662. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  5663. __func__);
  5664. goto err;
  5665. } else if (wsa_dev_cnt <= 0) {
  5666. dev_err(&pdev->dev,
  5667. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  5668. __func__, wsa_dev_cnt);
  5669. ret = -EINVAL;
  5670. goto err;
  5671. }
  5672. /*
  5673. * Expect total phandles count to be NOT less than maximum possible
  5674. * WSA count. However, if it is less, then assign same value to
  5675. * max count as well.
  5676. */
  5677. if (wsa_dev_cnt < wsa_max_devs) {
  5678. dev_dbg(&pdev->dev,
  5679. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  5680. __func__, wsa_max_devs, wsa_dev_cnt);
  5681. wsa_max_devs = wsa_dev_cnt;
  5682. }
  5683. /* Make sure prefix string passed for each WSA device */
  5684. ret = of_property_count_strings(pdev->dev.of_node,
  5685. "qcom,wsa-aux-dev-prefix");
  5686. if (ret != wsa_dev_cnt) {
  5687. dev_err(&pdev->dev,
  5688. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  5689. __func__, wsa_dev_cnt, ret);
  5690. ret = -EINVAL;
  5691. goto err;
  5692. }
  5693. /*
  5694. * Alloc mem to store phandle and index info of WSA device, if already
  5695. * registered with ALSA core
  5696. */
  5697. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  5698. sizeof(struct msm_wsa881x_dev_info),
  5699. GFP_KERNEL);
  5700. if (!wsa881x_dev_info) {
  5701. ret = -ENOMEM;
  5702. goto err;
  5703. }
  5704. /*
  5705. * search and check whether all WSA devices are already
  5706. * registered with ALSA core or not. If found a node, store
  5707. * the node and the index in a local array of struct for later
  5708. * use.
  5709. */
  5710. for (i = 0; i < wsa_dev_cnt; i++) {
  5711. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  5712. "qcom,wsa-devs", i);
  5713. if (unlikely(!wsa_of_node)) {
  5714. /* we should not be here */
  5715. dev_err(&pdev->dev,
  5716. "%s: wsa dev node is not present\n",
  5717. __func__);
  5718. ret = -EINVAL;
  5719. goto err;
  5720. }
  5721. if (soc_find_component(wsa_of_node, NULL)) {
  5722. /* WSA device registered with ALSA core */
  5723. wsa881x_dev_info[found].of_node = wsa_of_node;
  5724. wsa881x_dev_info[found].index = i;
  5725. found++;
  5726. if (found == wsa_max_devs)
  5727. break;
  5728. }
  5729. }
  5730. if (found < wsa_max_devs) {
  5731. dev_dbg(&pdev->dev,
  5732. "%s: failed to find %d components. Found only %d\n",
  5733. __func__, wsa_max_devs, found);
  5734. return -EPROBE_DEFER;
  5735. }
  5736. dev_info(&pdev->dev,
  5737. "%s: found %d wsa881x devices registered with ALSA core\n",
  5738. __func__, found);
  5739. codec_aux_dev:
  5740. /* Get count of aux codec device phandles for this platform */
  5741. codec_aux_dev_cnt = of_count_phandle_with_args(
  5742. pdev->dev.of_node,
  5743. "qcom,codec-aux-devs", NULL);
  5744. if (codec_aux_dev_cnt == -ENOENT) {
  5745. dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n",
  5746. __func__);
  5747. goto err;
  5748. } else if (codec_aux_dev_cnt <= 0) {
  5749. dev_err(&pdev->dev,
  5750. "%s: Error reading aux codec device from DT, dev_cnt=%d\n",
  5751. __func__, codec_aux_dev_cnt);
  5752. ret = -EINVAL;
  5753. goto err;
  5754. }
  5755. /*
  5756. * Alloc mem to store phandle and index info of aux codec
  5757. * if already registered with ALSA core
  5758. */
  5759. aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_aux_dev_cnt,
  5760. sizeof(struct aux_codec_dev_info),
  5761. GFP_KERNEL);
  5762. if (!aux_cdc_dev_info) {
  5763. ret = -ENOMEM;
  5764. goto err;
  5765. }
  5766. /*
  5767. * search and check whether all aux codecs are already
  5768. * registered with ALSA core or not. If found a node, store
  5769. * the node and the index in a local array of struct for later
  5770. * use.
  5771. */
  5772. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5773. aux_codec_of_node = of_parse_phandle(pdev->dev.of_node,
  5774. "qcom,codec-aux-devs", i);
  5775. if (unlikely(!aux_codec_of_node)) {
  5776. /* we should not be here */
  5777. dev_err(&pdev->dev,
  5778. "%s: aux codec dev node is not present\n",
  5779. __func__);
  5780. ret = -EINVAL;
  5781. goto err;
  5782. }
  5783. if (soc_find_component(aux_codec_of_node, NULL)) {
  5784. /* AUX codec registered with ALSA core */
  5785. aux_cdc_dev_info[codecs_found].of_node =
  5786. aux_codec_of_node;
  5787. aux_cdc_dev_info[codecs_found].index = i;
  5788. codecs_found++;
  5789. }
  5790. }
  5791. if (codecs_found < codec_aux_dev_cnt) {
  5792. dev_dbg(&pdev->dev,
  5793. "%s: failed to find %d components. Found only %d\n",
  5794. __func__, codec_aux_dev_cnt, codecs_found);
  5795. return -EPROBE_DEFER;
  5796. }
  5797. dev_info(&pdev->dev,
  5798. "%s: found %d AUX codecs registered with ALSA core\n",
  5799. __func__, codecs_found);
  5800. card->num_aux_devs = wsa_max_devs + codec_aux_dev_cnt;
  5801. card->num_configs = wsa_max_devs + codec_aux_dev_cnt;
  5802. /* Alloc array of AUX devs struct */
  5803. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  5804. sizeof(struct snd_soc_aux_dev),
  5805. GFP_KERNEL);
  5806. if (!msm_aux_dev) {
  5807. ret = -ENOMEM;
  5808. goto err;
  5809. }
  5810. /* Alloc array of codec conf struct */
  5811. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs,
  5812. sizeof(struct snd_soc_codec_conf),
  5813. GFP_KERNEL);
  5814. if (!msm_codec_conf) {
  5815. ret = -ENOMEM;
  5816. goto err;
  5817. }
  5818. for (i = 0; i < wsa_max_devs; i++) {
  5819. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  5820. GFP_KERNEL);
  5821. if (!dev_name_str) {
  5822. ret = -ENOMEM;
  5823. goto err;
  5824. }
  5825. ret = of_property_read_string_index(pdev->dev.of_node,
  5826. "qcom,wsa-aux-dev-prefix",
  5827. wsa881x_dev_info[i].index,
  5828. auxdev_name_prefix);
  5829. if (ret) {
  5830. dev_err(&pdev->dev,
  5831. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  5832. __func__, ret);
  5833. ret = -EINVAL;
  5834. goto err;
  5835. }
  5836. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  5837. msm_aux_dev[i].name = dev_name_str;
  5838. msm_aux_dev[i].codec_name = NULL;
  5839. msm_aux_dev[i].codec_of_node =
  5840. wsa881x_dev_info[i].of_node;
  5841. msm_aux_dev[i].init = msm_wsa881x_init;
  5842. msm_codec_conf[i].dev_name = NULL;
  5843. msm_codec_conf[i].name_prefix = auxdev_name_prefix[0];
  5844. msm_codec_conf[i].of_node =
  5845. wsa881x_dev_info[i].of_node;
  5846. }
  5847. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5848. msm_aux_dev[wsa_max_devs + i].name = NULL;
  5849. msm_aux_dev[wsa_max_devs + i].codec_name = NULL;
  5850. msm_aux_dev[wsa_max_devs + i].codec_of_node =
  5851. aux_cdc_dev_info[i].of_node;
  5852. msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init;
  5853. msm_codec_conf[wsa_max_devs + i].dev_name = NULL;
  5854. msm_codec_conf[wsa_max_devs + i].name_prefix =
  5855. NULL;
  5856. msm_codec_conf[wsa_max_devs + i].of_node =
  5857. aux_cdc_dev_info[i].of_node;
  5858. }
  5859. card->codec_conf = msm_codec_conf;
  5860. card->aux_dev = msm_aux_dev;
  5861. err:
  5862. return ret;
  5863. }
  5864. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  5865. {
  5866. int count = 0;
  5867. u32 mi2s_master_slave[MI2S_MAX];
  5868. int ret = 0;
  5869. for (count = 0; count < MI2S_MAX; count++) {
  5870. mutex_init(&mi2s_intf_conf[count].lock);
  5871. mi2s_intf_conf[count].ref_cnt = 0;
  5872. }
  5873. ret = of_property_read_u32_array(pdev->dev.of_node,
  5874. "qcom,msm-mi2s-master",
  5875. mi2s_master_slave, MI2S_MAX);
  5876. if (ret) {
  5877. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  5878. __func__);
  5879. } else {
  5880. for (count = 0; count < MI2S_MAX; count++) {
  5881. mi2s_intf_conf[count].msm_is_mi2s_master =
  5882. mi2s_master_slave[count];
  5883. }
  5884. }
  5885. }
  5886. static void msm_i2s_auxpcm_deinit(void)
  5887. {
  5888. int count = 0;
  5889. for (count = 0; count < MI2S_MAX; count++) {
  5890. mutex_destroy(&mi2s_intf_conf[count].lock);
  5891. mi2s_intf_conf[count].ref_cnt = 0;
  5892. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  5893. }
  5894. }
  5895. static int kona_ssr_enable(struct device *dev, void *data)
  5896. {
  5897. struct platform_device *pdev = to_platform_device(dev);
  5898. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5899. int ret = 0;
  5900. if (!card) {
  5901. dev_err(dev, "%s: card is NULL\n", __func__);
  5902. ret = -EINVAL;
  5903. goto err;
  5904. }
  5905. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5906. /* TODO */
  5907. dev_dbg(dev, "%s: TODO \n", __func__);
  5908. }
  5909. snd_soc_card_change_online_state(card, 1);
  5910. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  5911. err:
  5912. return ret;
  5913. }
  5914. static void kona_ssr_disable(struct device *dev, void *data)
  5915. {
  5916. struct platform_device *pdev = to_platform_device(dev);
  5917. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5918. if (!card) {
  5919. dev_err(dev, "%s: card is NULL\n", __func__);
  5920. return;
  5921. }
  5922. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  5923. snd_soc_card_change_online_state(card, 0);
  5924. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5925. /* TODO */
  5926. dev_dbg(dev, "%s: TODO \n", __func__);
  5927. }
  5928. }
  5929. static const struct snd_event_ops kona_ssr_ops = {
  5930. .enable = kona_ssr_enable,
  5931. .disable = kona_ssr_disable,
  5932. };
  5933. static int msm_audio_ssr_compare(struct device *dev, void *data)
  5934. {
  5935. struct device_node *node = data;
  5936. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  5937. __func__, dev->of_node, node);
  5938. return (dev->of_node && dev->of_node == node);
  5939. }
  5940. static int msm_audio_ssr_register(struct device *dev)
  5941. {
  5942. struct device_node *np = dev->of_node;
  5943. struct snd_event_clients *ssr_clients = NULL;
  5944. struct device_node *node = NULL;
  5945. int ret = 0;
  5946. int i = 0;
  5947. for (i = 0; ; i++) {
  5948. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  5949. if (!node)
  5950. break;
  5951. snd_event_mstr_add_client(&ssr_clients,
  5952. msm_audio_ssr_compare, node);
  5953. }
  5954. ret = snd_event_master_register(dev, &kona_ssr_ops,
  5955. ssr_clients, NULL);
  5956. if (!ret)
  5957. snd_event_notify(dev, SND_EVENT_UP);
  5958. return ret;
  5959. }
  5960. static int msm_asoc_machine_probe(struct platform_device *pdev)
  5961. {
  5962. struct snd_soc_card *card = NULL;
  5963. struct msm_asoc_mach_data *pdata = NULL;
  5964. const char *mbhc_audio_jack_type = NULL;
  5965. int ret = 0;
  5966. if (!pdev->dev.of_node) {
  5967. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  5968. return -EINVAL;
  5969. }
  5970. pdata = devm_kzalloc(&pdev->dev,
  5971. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  5972. if (!pdata)
  5973. return -ENOMEM;
  5974. card = populate_snd_card_dailinks(&pdev->dev);
  5975. if (!card) {
  5976. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  5977. ret = -EINVAL;
  5978. goto err;
  5979. }
  5980. card->dev = &pdev->dev;
  5981. platform_set_drvdata(pdev, card);
  5982. snd_soc_card_set_drvdata(card, pdata);
  5983. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  5984. if (ret) {
  5985. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  5986. __func__, ret);
  5987. goto err;
  5988. }
  5989. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  5990. if (ret) {
  5991. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  5992. __func__, ret);
  5993. goto err;
  5994. }
  5995. ret = msm_populate_dai_link_component_of_node(card);
  5996. if (ret) {
  5997. ret = -EPROBE_DEFER;
  5998. goto err;
  5999. }
  6000. ret = msm_init_aux_dev(pdev, card);
  6001. if (ret)
  6002. goto err;
  6003. ret = devm_snd_soc_register_card(&pdev->dev, card);
  6004. if (ret == -EPROBE_DEFER) {
  6005. if (codec_reg_done)
  6006. ret = -EINVAL;
  6007. goto err;
  6008. } else if (ret) {
  6009. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  6010. __func__, ret);
  6011. goto err;
  6012. }
  6013. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  6014. __func__, card->name);
  6015. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6016. "qcom,hph-en1-gpio", 0);
  6017. if (!pdata->hph_en1_gpio_p) {
  6018. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  6019. __func__, "qcom,hph-en1-gpio",
  6020. pdev->dev.of_node->full_name);
  6021. }
  6022. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6023. "qcom,hph-en0-gpio", 0);
  6024. if (!pdata->hph_en0_gpio_p) {
  6025. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  6026. __func__, "qcom,hph-en0-gpio",
  6027. pdev->dev.of_node->full_name);
  6028. }
  6029. ret = of_property_read_string(pdev->dev.of_node,
  6030. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  6031. if (ret) {
  6032. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  6033. __func__, "qcom,mbhc-audio-jack-type",
  6034. pdev->dev.of_node->full_name);
  6035. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  6036. } else {
  6037. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  6038. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  6039. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  6040. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  6041. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  6042. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  6043. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  6044. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  6045. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  6046. } else {
  6047. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  6048. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  6049. }
  6050. }
  6051. /*
  6052. * Parse US-Euro gpio info from DT. Report no error if us-euro
  6053. * entry is not found in DT file as some targets do not support
  6054. * US-Euro detection
  6055. */
  6056. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6057. "qcom,us-euro-gpios", 0);
  6058. if (!pdata->us_euro_gpio_p) {
  6059. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  6060. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  6061. } else {
  6062. dev_dbg(&pdev->dev, "%s detected\n",
  6063. "qcom,us-euro-gpios");
  6064. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  6065. }
  6066. if (wcd_mbhc_cfg.enable_usbc_analog)
  6067. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  6068. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  6069. "fsa4480-i2c-handle", 0);
  6070. if (!pdata->fsa_handle)
  6071. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  6072. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  6073. msm_i2s_auxpcm_init(pdev);
  6074. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6075. "qcom,cdc-dmic01-gpios",
  6076. 0);
  6077. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6078. "qcom,cdc-dmic23-gpios",
  6079. 0);
  6080. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6081. "qcom,cdc-dmic45-gpios",
  6082. 0);
  6083. ret = msm_audio_ssr_register(&pdev->dev);
  6084. if (ret)
  6085. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  6086. __func__, ret);
  6087. is_initial_boot = true;
  6088. return 0;
  6089. err:
  6090. devm_kfree(&pdev->dev, pdata);
  6091. return ret;
  6092. }
  6093. static int msm_asoc_machine_remove(struct platform_device *pdev)
  6094. {
  6095. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6096. snd_event_master_deregister(&pdev->dev);
  6097. snd_soc_unregister_card(card);
  6098. msm_i2s_auxpcm_deinit();
  6099. return 0;
  6100. }
  6101. static struct platform_driver kona_asoc_machine_driver = {
  6102. .driver = {
  6103. .name = DRV_NAME,
  6104. .owner = THIS_MODULE,
  6105. .pm = &snd_soc_pm_ops,
  6106. .of_match_table = kona_asoc_machine_of_match,
  6107. },
  6108. .probe = msm_asoc_machine_probe,
  6109. .remove = msm_asoc_machine_remove,
  6110. };
  6111. module_platform_driver(kona_asoc_machine_driver);
  6112. MODULE_DESCRIPTION("ALSA SoC msm");
  6113. MODULE_LICENSE("GPL v2");
  6114. MODULE_ALIAS("platform:" DRV_NAME);
  6115. MODULE_DEVICE_TABLE(of, kona_asoc_machine_of_match);