sdm855.c 206 KB

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