sm8150.c 210 KB

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