bengal.c 187 KB

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