sdm855.c 188 KB

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