sm8150.c 212 KB

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