msm-dai-q6-v2.c 184 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/init.h>
  5. #include <linux/module.h>
  6. #include <linux/device.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/bitops.h>
  9. #include <linux/slab.h>
  10. #include <linux/clk.h>
  11. #include <linux/of_device.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/soc.h>
  15. #include <sound/pcm_params.h>
  16. #include <dsp/audio_prm.h>
  17. #include <dsp/apr_audio-v2.h>
  18. #include <dsp/sp_params.h>
  19. #include "msm-dai-q6-v2.h"
  20. #include <asoc/core.h>
  21. #define AFE_CLK_VERSION_V1 1
  22. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  23. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  24. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  25. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  26. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  27. #define MSM_DAI_SEN_AUXPCM_DT_DEV_ID 6
  28. #define MSM_DAI_TWS_CHANNEL_MODE_ONE 1
  29. #define MSM_DAI_TWS_CHANNEL_MODE_TWO 2
  30. #define spdif_clock_value(rate) (2*rate*32*2)
  31. #define CHANNEL_STATUS_SIZE 24
  32. #define CHANNEL_STATUS_MASK_INIT 0x0
  33. #define CHANNEL_STATUS_MASK 0x4
  34. #define PREEMPH_MASK 0x38
  35. #define PREEMPH_SHIFT 3
  36. #define GET_PREEMPH(b) ((b & PREEMPH_MASK) >> PREEMPH_SHIFT)
  37. #define AFE_API_VERSION_CLOCK_SET 1
  38. #define MSM_DAI_SYSFS_ENTRY_MAX_LEN 64
  39. #define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  40. SNDRV_PCM_FMTBIT_S24_LE | \
  41. SNDRV_PCM_FMTBIT_S32_LE)
  42. //static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id);
  43. enum {
  44. ENC_FMT_NONE,
  45. DEC_FMT_NONE = ENC_FMT_NONE,
  46. ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  47. DEC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  48. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  49. DEC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  50. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  51. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  52. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  53. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  54. ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  55. DEC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  56. DEC_FMT_MP3 = ASM_MEDIA_FMT_MP3,
  57. ENC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  58. DEC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  59. };
  60. enum {
  61. SPKR_1,
  62. SPKR_2,
  63. };
  64. static const struct afe_clk_set lpass_clk_set_default = {
  65. AFE_API_VERSION_CLOCK_SET,
  66. CLOCK_ID_PRI_PCM_IBIT,
  67. OSR_CLOCK_2_P048_MHZ,
  68. CLOCK_ATTRIBUTE_COUPLE_NO,
  69. CLOCK_ROOT_DEFAULT,
  70. 0,
  71. };
  72. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  73. AFE_API_VERSION_I2S_CONFIG,
  74. OSR_CLOCK_2_P048_MHZ,
  75. 0,
  76. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  77. CLOCK_ROOT_DEFAULT,
  78. Q6AFE_LPASS_MODE_CLK1_VALID,
  79. 0,
  80. };
  81. enum {
  82. STATUS_PORT_STARTED, /* track if AFE port has started */
  83. /* track AFE Tx port status for bi-directional transfers */
  84. STATUS_TX_PORT,
  85. /* track AFE Rx port status for bi-directional transfers */
  86. STATUS_RX_PORT,
  87. STATUS_MAX
  88. };
  89. enum {
  90. RATE_8KHZ,
  91. RATE_16KHZ,
  92. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  93. };
  94. enum {
  95. IDX_PRIMARY_TDM_RX_0,
  96. IDX_PRIMARY_TDM_RX_1,
  97. IDX_PRIMARY_TDM_RX_2,
  98. IDX_PRIMARY_TDM_RX_3,
  99. IDX_PRIMARY_TDM_RX_4,
  100. IDX_PRIMARY_TDM_RX_5,
  101. IDX_PRIMARY_TDM_RX_6,
  102. IDX_PRIMARY_TDM_RX_7,
  103. IDX_PRIMARY_TDM_TX_0,
  104. IDX_PRIMARY_TDM_TX_1,
  105. IDX_PRIMARY_TDM_TX_2,
  106. IDX_PRIMARY_TDM_TX_3,
  107. IDX_PRIMARY_TDM_TX_4,
  108. IDX_PRIMARY_TDM_TX_5,
  109. IDX_PRIMARY_TDM_TX_6,
  110. IDX_PRIMARY_TDM_TX_7,
  111. IDX_SECONDARY_TDM_RX_0,
  112. IDX_SECONDARY_TDM_RX_1,
  113. IDX_SECONDARY_TDM_RX_2,
  114. IDX_SECONDARY_TDM_RX_3,
  115. IDX_SECONDARY_TDM_RX_4,
  116. IDX_SECONDARY_TDM_RX_5,
  117. IDX_SECONDARY_TDM_RX_6,
  118. IDX_SECONDARY_TDM_RX_7,
  119. IDX_SECONDARY_TDM_TX_0,
  120. IDX_SECONDARY_TDM_TX_1,
  121. IDX_SECONDARY_TDM_TX_2,
  122. IDX_SECONDARY_TDM_TX_3,
  123. IDX_SECONDARY_TDM_TX_4,
  124. IDX_SECONDARY_TDM_TX_5,
  125. IDX_SECONDARY_TDM_TX_6,
  126. IDX_SECONDARY_TDM_TX_7,
  127. IDX_TERTIARY_TDM_RX_0,
  128. IDX_TERTIARY_TDM_RX_1,
  129. IDX_TERTIARY_TDM_RX_2,
  130. IDX_TERTIARY_TDM_RX_3,
  131. IDX_TERTIARY_TDM_RX_4,
  132. IDX_TERTIARY_TDM_RX_5,
  133. IDX_TERTIARY_TDM_RX_6,
  134. IDX_TERTIARY_TDM_RX_7,
  135. IDX_TERTIARY_TDM_TX_0,
  136. IDX_TERTIARY_TDM_TX_1,
  137. IDX_TERTIARY_TDM_TX_2,
  138. IDX_TERTIARY_TDM_TX_3,
  139. IDX_TERTIARY_TDM_TX_4,
  140. IDX_TERTIARY_TDM_TX_5,
  141. IDX_TERTIARY_TDM_TX_6,
  142. IDX_TERTIARY_TDM_TX_7,
  143. IDX_QUATERNARY_TDM_RX_0,
  144. IDX_QUATERNARY_TDM_RX_1,
  145. IDX_QUATERNARY_TDM_RX_2,
  146. IDX_QUATERNARY_TDM_RX_3,
  147. IDX_QUATERNARY_TDM_RX_4,
  148. IDX_QUATERNARY_TDM_RX_5,
  149. IDX_QUATERNARY_TDM_RX_6,
  150. IDX_QUATERNARY_TDM_RX_7,
  151. IDX_QUATERNARY_TDM_TX_0,
  152. IDX_QUATERNARY_TDM_TX_1,
  153. IDX_QUATERNARY_TDM_TX_2,
  154. IDX_QUATERNARY_TDM_TX_3,
  155. IDX_QUATERNARY_TDM_TX_4,
  156. IDX_QUATERNARY_TDM_TX_5,
  157. IDX_QUATERNARY_TDM_TX_6,
  158. IDX_QUATERNARY_TDM_TX_7,
  159. IDX_QUINARY_TDM_RX_0,
  160. IDX_QUINARY_TDM_RX_1,
  161. IDX_QUINARY_TDM_RX_2,
  162. IDX_QUINARY_TDM_RX_3,
  163. IDX_QUINARY_TDM_RX_4,
  164. IDX_QUINARY_TDM_RX_5,
  165. IDX_QUINARY_TDM_RX_6,
  166. IDX_QUINARY_TDM_RX_7,
  167. IDX_QUINARY_TDM_TX_0,
  168. IDX_QUINARY_TDM_TX_1,
  169. IDX_QUINARY_TDM_TX_2,
  170. IDX_QUINARY_TDM_TX_3,
  171. IDX_QUINARY_TDM_TX_4,
  172. IDX_QUINARY_TDM_TX_5,
  173. IDX_QUINARY_TDM_TX_6,
  174. IDX_QUINARY_TDM_TX_7,
  175. IDX_SENARY_TDM_RX_0,
  176. IDX_SENARY_TDM_RX_1,
  177. IDX_SENARY_TDM_RX_2,
  178. IDX_SENARY_TDM_RX_3,
  179. IDX_SENARY_TDM_RX_4,
  180. IDX_SENARY_TDM_RX_5,
  181. IDX_SENARY_TDM_RX_6,
  182. IDX_SENARY_TDM_RX_7,
  183. IDX_SENARY_TDM_TX_0,
  184. IDX_SENARY_TDM_TX_1,
  185. IDX_SENARY_TDM_TX_2,
  186. IDX_SENARY_TDM_TX_3,
  187. IDX_SENARY_TDM_TX_4,
  188. IDX_SENARY_TDM_TX_5,
  189. IDX_SENARY_TDM_TX_6,
  190. IDX_SENARY_TDM_TX_7,
  191. IDX_TDM_MAX,
  192. };
  193. enum {
  194. IDX_GROUP_PRIMARY_TDM_RX,
  195. IDX_GROUP_PRIMARY_TDM_TX,
  196. IDX_GROUP_SECONDARY_TDM_RX,
  197. IDX_GROUP_SECONDARY_TDM_TX,
  198. IDX_GROUP_TERTIARY_TDM_RX,
  199. IDX_GROUP_TERTIARY_TDM_TX,
  200. IDX_GROUP_QUATERNARY_TDM_RX,
  201. IDX_GROUP_QUATERNARY_TDM_TX,
  202. IDX_GROUP_QUINARY_TDM_RX,
  203. IDX_GROUP_QUINARY_TDM_TX,
  204. IDX_GROUP_SENARY_TDM_RX,
  205. IDX_GROUP_SENARY_TDM_TX,
  206. IDX_GROUP_TDM_MAX,
  207. };
  208. struct msm_dai_q6_dai_data {
  209. DECLARE_BITMAP(status_mask, STATUS_MAX);
  210. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  211. u32 rate;
  212. u32 channels;
  213. u32 bitwidth;
  214. u32 cal_mode;
  215. u32 afe_rx_in_channels;
  216. u16 afe_rx_in_bitformat;
  217. u32 afe_tx_out_channels;
  218. u16 afe_tx_out_bitformat;
  219. struct afe_enc_config enc_config;
  220. struct afe_dec_config dec_config;
  221. union afe_port_config port_config;
  222. u16 vi_feed_mono;
  223. };
  224. struct msm_dai_q6_mi2s_dai_config {
  225. u16 pdata_mi2s_lines;
  226. struct msm_dai_q6_dai_data mi2s_dai_data;
  227. };
  228. struct msm_dai_q6_mi2s_dai_data {
  229. u32 is_island_dai;
  230. struct msm_dai_q6_mi2s_dai_config tx_dai;
  231. struct msm_dai_q6_mi2s_dai_config rx_dai;
  232. };
  233. struct msm_dai_q6_meta_mi2s_dai_data {
  234. DECLARE_BITMAP(status_mask, STATUS_MAX);
  235. u16 num_member_ports;
  236. u16 member_port_id[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  237. u16 channel_mode[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  238. u32 rate;
  239. u32 channels;
  240. u32 bitwidth;
  241. union afe_port_config port_config;
  242. };
  243. struct msm_dai_q6_cdc_dma_dai_data {
  244. DECLARE_BITMAP(status_mask, STATUS_MAX);
  245. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  246. u32 rate;
  247. u32 channels;
  248. u32 bitwidth;
  249. u32 is_island_dai;
  250. union afe_port_config port_config;
  251. u32 cdc_dma_data_align;
  252. };
  253. struct msm_dai_q6_auxpcm_dai_data {
  254. /* BITMAP to track Rx and Tx port usage count */
  255. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  256. struct mutex rlock; /* auxpcm dev resource lock */
  257. u16 rx_pid; /* AUXPCM RX AFE port ID */
  258. u16 tx_pid; /* AUXPCM TX AFE port ID */
  259. u16 clk_ver;
  260. u32 is_island_dai;
  261. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  262. struct clk_cfg aux_clk_set; /* hold LPASS clock config. */
  263. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  264. };
  265. struct msm_dai_q6_tdm_dai_data {
  266. DECLARE_BITMAP(status_mask, STATUS_MAX);
  267. u32 rate;
  268. u32 channels;
  269. u32 bitwidth;
  270. u32 num_group_ports;
  271. u32 is_island_dai;
  272. struct clk_cfg clk_set; /* hold LPASS clock config. */
  273. union afe_port_group_config group_cfg; /* hold tdm group config */
  274. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  275. struct afe_param_id_tdm_lane_cfg lane_cfg; /* hold tdm lane config */
  276. };
  277. static DEFINE_MUTEX(tdm_mutex);
  278. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  279. static struct afe_param_id_tdm_lane_cfg tdm_lane_cfg = {
  280. AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX,
  281. 0x0,
  282. };
  283. /* cache of group cfg per parent node */
  284. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  285. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  286. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  287. 0,
  288. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  289. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  290. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  291. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  292. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  293. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  294. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  295. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  296. 8,
  297. 48000,
  298. 32,
  299. 8,
  300. 32,
  301. 0xFF,
  302. };
  303. static u32 num_tdm_group_ports;
  304. static struct clk_cfg tdm_clk_set = {
  305. CLOCK_ID_QUAD_TDM_EBIT,
  306. IBIT_CLOCK_DISABLE,
  307. CLOCK_ATTRIBUTE_INVERT_COUPLE_NO,
  308. CLOCK_ROOT_DEFAULT,
  309. };
  310. static int msm_dai_q6_get_tdm_clk_ref(u16 id)
  311. {
  312. switch (id) {
  313. case IDX_GROUP_PRIMARY_TDM_RX:
  314. case IDX_GROUP_PRIMARY_TDM_TX:
  315. return atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_RX]) +
  316. atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_TX]);
  317. case IDX_GROUP_SECONDARY_TDM_RX:
  318. case IDX_GROUP_SECONDARY_TDM_TX:
  319. return atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_RX]) +
  320. atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_TX]);
  321. case IDX_GROUP_TERTIARY_TDM_RX:
  322. case IDX_GROUP_TERTIARY_TDM_TX:
  323. return atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_RX]) +
  324. atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_TX]);
  325. case IDX_GROUP_QUATERNARY_TDM_RX:
  326. case IDX_GROUP_QUATERNARY_TDM_TX:
  327. return atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_RX]) +
  328. atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_TX]);
  329. case IDX_GROUP_QUINARY_TDM_RX:
  330. case IDX_GROUP_QUINARY_TDM_TX:
  331. return atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_RX]) +
  332. atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_TX]);
  333. case IDX_GROUP_SENARY_TDM_RX:
  334. case IDX_GROUP_SENARY_TDM_TX:
  335. return atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_RX]) +
  336. atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_TX]);
  337. default: return -EINVAL;
  338. }
  339. }
  340. int msm_dai_q6_get_group_idx(u16 id)
  341. {
  342. switch (id) {
  343. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  344. case AFE_PORT_ID_PRIMARY_TDM_RX:
  345. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  346. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  347. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  348. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  349. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  350. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  351. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  352. return IDX_GROUP_PRIMARY_TDM_RX;
  353. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  354. case AFE_PORT_ID_PRIMARY_TDM_TX:
  355. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  356. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  357. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  358. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  359. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  360. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  361. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  362. return IDX_GROUP_PRIMARY_TDM_TX;
  363. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  364. case AFE_PORT_ID_SECONDARY_TDM_RX:
  365. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  366. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  367. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  368. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  369. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  370. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  371. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  372. return IDX_GROUP_SECONDARY_TDM_RX;
  373. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  374. case AFE_PORT_ID_SECONDARY_TDM_TX:
  375. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  376. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  377. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  378. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  379. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  380. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  381. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  382. return IDX_GROUP_SECONDARY_TDM_TX;
  383. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  384. case AFE_PORT_ID_TERTIARY_TDM_RX:
  385. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  386. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  387. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  388. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  389. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  390. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  391. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  392. return IDX_GROUP_TERTIARY_TDM_RX;
  393. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  394. case AFE_PORT_ID_TERTIARY_TDM_TX:
  395. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  396. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  397. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  398. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  399. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  400. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  401. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  402. return IDX_GROUP_TERTIARY_TDM_TX;
  403. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  404. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  405. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  406. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  407. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  408. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  409. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  410. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  411. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  412. return IDX_GROUP_QUATERNARY_TDM_RX;
  413. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  414. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  415. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  416. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  417. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  418. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  419. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  420. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  421. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  422. return IDX_GROUP_QUATERNARY_TDM_TX;
  423. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  424. case AFE_PORT_ID_QUINARY_TDM_RX:
  425. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  426. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  427. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  428. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  429. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  430. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  431. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  432. return IDX_GROUP_QUINARY_TDM_RX;
  433. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  434. case AFE_PORT_ID_QUINARY_TDM_TX:
  435. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  436. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  437. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  438. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  439. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  440. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  441. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  442. return IDX_GROUP_QUINARY_TDM_TX;
  443. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  444. case AFE_PORT_ID_SENARY_TDM_RX:
  445. case AFE_PORT_ID_SENARY_TDM_RX_1:
  446. case AFE_PORT_ID_SENARY_TDM_RX_2:
  447. case AFE_PORT_ID_SENARY_TDM_RX_3:
  448. case AFE_PORT_ID_SENARY_TDM_RX_4:
  449. case AFE_PORT_ID_SENARY_TDM_RX_5:
  450. case AFE_PORT_ID_SENARY_TDM_RX_6:
  451. case AFE_PORT_ID_SENARY_TDM_RX_7:
  452. return IDX_GROUP_SENARY_TDM_RX;
  453. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  454. case AFE_PORT_ID_SENARY_TDM_TX:
  455. case AFE_PORT_ID_SENARY_TDM_TX_1:
  456. case AFE_PORT_ID_SENARY_TDM_TX_2:
  457. case AFE_PORT_ID_SENARY_TDM_TX_3:
  458. case AFE_PORT_ID_SENARY_TDM_TX_4:
  459. case AFE_PORT_ID_SENARY_TDM_TX_5:
  460. case AFE_PORT_ID_SENARY_TDM_TX_6:
  461. case AFE_PORT_ID_SENARY_TDM_TX_7:
  462. return IDX_GROUP_SENARY_TDM_TX;
  463. default: return -EINVAL;
  464. }
  465. }
  466. int msm_dai_q6_get_port_idx(u16 id)
  467. {
  468. switch (id) {
  469. case AFE_PORT_ID_PRIMARY_TDM_RX:
  470. return IDX_PRIMARY_TDM_RX_0;
  471. case AFE_PORT_ID_PRIMARY_TDM_TX:
  472. return IDX_PRIMARY_TDM_TX_0;
  473. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  474. return IDX_PRIMARY_TDM_RX_1;
  475. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  476. return IDX_PRIMARY_TDM_TX_1;
  477. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  478. return IDX_PRIMARY_TDM_RX_2;
  479. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  480. return IDX_PRIMARY_TDM_TX_2;
  481. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  482. return IDX_PRIMARY_TDM_RX_3;
  483. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  484. return IDX_PRIMARY_TDM_TX_3;
  485. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  486. return IDX_PRIMARY_TDM_RX_4;
  487. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  488. return IDX_PRIMARY_TDM_TX_4;
  489. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  490. return IDX_PRIMARY_TDM_RX_5;
  491. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  492. return IDX_PRIMARY_TDM_TX_5;
  493. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  494. return IDX_PRIMARY_TDM_RX_6;
  495. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  496. return IDX_PRIMARY_TDM_TX_6;
  497. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  498. return IDX_PRIMARY_TDM_RX_7;
  499. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  500. return IDX_PRIMARY_TDM_TX_7;
  501. case AFE_PORT_ID_SECONDARY_TDM_RX:
  502. return IDX_SECONDARY_TDM_RX_0;
  503. case AFE_PORT_ID_SECONDARY_TDM_TX:
  504. return IDX_SECONDARY_TDM_TX_0;
  505. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  506. return IDX_SECONDARY_TDM_RX_1;
  507. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  508. return IDX_SECONDARY_TDM_TX_1;
  509. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  510. return IDX_SECONDARY_TDM_RX_2;
  511. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  512. return IDX_SECONDARY_TDM_TX_2;
  513. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  514. return IDX_SECONDARY_TDM_RX_3;
  515. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  516. return IDX_SECONDARY_TDM_TX_3;
  517. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  518. return IDX_SECONDARY_TDM_RX_4;
  519. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  520. return IDX_SECONDARY_TDM_TX_4;
  521. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  522. return IDX_SECONDARY_TDM_RX_5;
  523. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  524. return IDX_SECONDARY_TDM_TX_5;
  525. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  526. return IDX_SECONDARY_TDM_RX_6;
  527. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  528. return IDX_SECONDARY_TDM_TX_6;
  529. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  530. return IDX_SECONDARY_TDM_RX_7;
  531. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  532. return IDX_SECONDARY_TDM_TX_7;
  533. case AFE_PORT_ID_TERTIARY_TDM_RX:
  534. return IDX_TERTIARY_TDM_RX_0;
  535. case AFE_PORT_ID_TERTIARY_TDM_TX:
  536. return IDX_TERTIARY_TDM_TX_0;
  537. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  538. return IDX_TERTIARY_TDM_RX_1;
  539. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  540. return IDX_TERTIARY_TDM_TX_1;
  541. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  542. return IDX_TERTIARY_TDM_RX_2;
  543. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  544. return IDX_TERTIARY_TDM_TX_2;
  545. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  546. return IDX_TERTIARY_TDM_RX_3;
  547. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  548. return IDX_TERTIARY_TDM_TX_3;
  549. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  550. return IDX_TERTIARY_TDM_RX_4;
  551. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  552. return IDX_TERTIARY_TDM_TX_4;
  553. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  554. return IDX_TERTIARY_TDM_RX_5;
  555. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  556. return IDX_TERTIARY_TDM_TX_5;
  557. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  558. return IDX_TERTIARY_TDM_RX_6;
  559. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  560. return IDX_TERTIARY_TDM_TX_6;
  561. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  562. return IDX_TERTIARY_TDM_RX_7;
  563. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  564. return IDX_TERTIARY_TDM_TX_7;
  565. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  566. return IDX_QUATERNARY_TDM_RX_0;
  567. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  568. return IDX_QUATERNARY_TDM_TX_0;
  569. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  570. return IDX_QUATERNARY_TDM_RX_1;
  571. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  572. return IDX_QUATERNARY_TDM_TX_1;
  573. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  574. return IDX_QUATERNARY_TDM_RX_2;
  575. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  576. return IDX_QUATERNARY_TDM_TX_2;
  577. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  578. return IDX_QUATERNARY_TDM_RX_3;
  579. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  580. return IDX_QUATERNARY_TDM_TX_3;
  581. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  582. return IDX_QUATERNARY_TDM_RX_4;
  583. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  584. return IDX_QUATERNARY_TDM_TX_4;
  585. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  586. return IDX_QUATERNARY_TDM_RX_5;
  587. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  588. return IDX_QUATERNARY_TDM_TX_5;
  589. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  590. return IDX_QUATERNARY_TDM_RX_6;
  591. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  592. return IDX_QUATERNARY_TDM_TX_6;
  593. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  594. return IDX_QUATERNARY_TDM_RX_7;
  595. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  596. return IDX_QUATERNARY_TDM_TX_7;
  597. case AFE_PORT_ID_QUINARY_TDM_RX:
  598. return IDX_QUINARY_TDM_RX_0;
  599. case AFE_PORT_ID_QUINARY_TDM_TX:
  600. return IDX_QUINARY_TDM_TX_0;
  601. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  602. return IDX_QUINARY_TDM_RX_1;
  603. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  604. return IDX_QUINARY_TDM_TX_1;
  605. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  606. return IDX_QUINARY_TDM_RX_2;
  607. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  608. return IDX_QUINARY_TDM_TX_2;
  609. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  610. return IDX_QUINARY_TDM_RX_3;
  611. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  612. return IDX_QUINARY_TDM_TX_3;
  613. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  614. return IDX_QUINARY_TDM_RX_4;
  615. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  616. return IDX_QUINARY_TDM_TX_4;
  617. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  618. return IDX_QUINARY_TDM_RX_5;
  619. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  620. return IDX_QUINARY_TDM_TX_5;
  621. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  622. return IDX_QUINARY_TDM_RX_6;
  623. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  624. return IDX_QUINARY_TDM_TX_6;
  625. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  626. return IDX_QUINARY_TDM_RX_7;
  627. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  628. return IDX_QUINARY_TDM_TX_7;
  629. case AFE_PORT_ID_SENARY_TDM_RX:
  630. return IDX_SENARY_TDM_RX_0;
  631. case AFE_PORT_ID_SENARY_TDM_TX:
  632. return IDX_SENARY_TDM_TX_0;
  633. case AFE_PORT_ID_SENARY_TDM_RX_1:
  634. return IDX_SENARY_TDM_RX_1;
  635. case AFE_PORT_ID_SENARY_TDM_TX_1:
  636. return IDX_SENARY_TDM_TX_1;
  637. case AFE_PORT_ID_SENARY_TDM_RX_2:
  638. return IDX_SENARY_TDM_RX_2;
  639. case AFE_PORT_ID_SENARY_TDM_TX_2:
  640. return IDX_SENARY_TDM_TX_2;
  641. case AFE_PORT_ID_SENARY_TDM_RX_3:
  642. return IDX_SENARY_TDM_RX_3;
  643. case AFE_PORT_ID_SENARY_TDM_TX_3:
  644. return IDX_SENARY_TDM_TX_3;
  645. case AFE_PORT_ID_SENARY_TDM_RX_4:
  646. return IDX_SENARY_TDM_RX_4;
  647. case AFE_PORT_ID_SENARY_TDM_TX_4:
  648. return IDX_SENARY_TDM_TX_4;
  649. case AFE_PORT_ID_SENARY_TDM_RX_5:
  650. return IDX_SENARY_TDM_RX_5;
  651. case AFE_PORT_ID_SENARY_TDM_TX_5:
  652. return IDX_SENARY_TDM_TX_5;
  653. case AFE_PORT_ID_SENARY_TDM_RX_6:
  654. return IDX_SENARY_TDM_RX_6;
  655. case AFE_PORT_ID_SENARY_TDM_TX_6:
  656. return IDX_SENARY_TDM_TX_6;
  657. case AFE_PORT_ID_SENARY_TDM_RX_7:
  658. return IDX_SENARY_TDM_RX_7;
  659. case AFE_PORT_ID_SENARY_TDM_TX_7:
  660. return IDX_SENARY_TDM_TX_7;
  661. default: return -EINVAL;
  662. }
  663. }
  664. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  665. {
  666. /* Max num of slots is bits per frame divided
  667. * by bits per sample which is 16
  668. */
  669. switch (frame_rate) {
  670. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  671. return 0;
  672. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  673. return 1;
  674. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  675. return 2;
  676. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  677. return 4;
  678. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  679. return 8;
  680. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  681. return 16;
  682. default:
  683. pr_err("%s Invalid bits per frame %d\n",
  684. __func__, frame_rate);
  685. return 0;
  686. }
  687. }
  688. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  689. {
  690. struct snd_soc_dapm_route intercon;
  691. struct snd_soc_dapm_context *dapm;
  692. if (!dai) {
  693. pr_err("%s: Invalid params dai\n", __func__);
  694. return -EINVAL;
  695. }
  696. if (!dai->driver) {
  697. pr_err("%s: Invalid params dai driver\n", __func__);
  698. return -EINVAL;
  699. }
  700. dapm = snd_soc_component_get_dapm(dai->component);
  701. memset(&intercon, 0, sizeof(intercon));
  702. if (dai->driver->playback.stream_name &&
  703. dai->driver->playback.aif_name) {
  704. dev_dbg(dai->dev, "%s: add route for widget %s",
  705. __func__, dai->driver->playback.stream_name);
  706. intercon.source = dai->driver->playback.aif_name;
  707. intercon.sink = dai->driver->playback.stream_name;
  708. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  709. __func__, intercon.source, intercon.sink);
  710. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  711. snd_soc_dapm_ignore_suspend(dapm, intercon.sink);
  712. }
  713. if (dai->driver->capture.stream_name &&
  714. dai->driver->capture.aif_name) {
  715. dev_dbg(dai->dev, "%s: add route for widget %s",
  716. __func__, dai->driver->capture.stream_name);
  717. intercon.sink = dai->driver->capture.aif_name;
  718. intercon.source = dai->driver->capture.stream_name;
  719. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  720. __func__, intercon.source, intercon.sink);
  721. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  722. snd_soc_dapm_ignore_suspend(dapm, intercon.source);
  723. }
  724. return 0;
  725. }
  726. static int msm_dai_q6_auxpcm_hw_params(
  727. struct snd_pcm_substream *substream,
  728. struct snd_pcm_hw_params *params,
  729. struct snd_soc_dai *dai)
  730. {
  731. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  732. dev_get_drvdata(dai->dev);
  733. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  734. int rc = 0;
  735. dai_data->channels = params_channels(params);
  736. dai_data->rate = params_rate(params);
  737. return rc;
  738. }
  739. static int msm_dai_q6_auxpcm_set_clk(
  740. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  741. u16 port_id, bool enable)
  742. {
  743. int rc;
  744. aux_dai_data->aux_clk_set.clk_id = aux_dai_data->clk_set.clk_id;
  745. aux_dai_data->aux_clk_set.clk_freq_in_hz = aux_dai_data->clk_set.clk_freq_in_hz;
  746. aux_dai_data->aux_clk_set.clk_attri = aux_dai_data->clk_set.clk_attri;
  747. aux_dai_data->aux_clk_set.clk_root = aux_dai_data->clk_set.clk_root;
  748. pr_debug("%s: clk_ver: %d, port_id: %d, enable: %d freq:%d\n", __func__,
  749. aux_dai_data->clk_ver, port_id, enable, aux_dai_data->aux_clk_set.clk_freq_in_hz);
  750. aux_dai_data->clk_set.enable = enable;
  751. rc = audio_prm_set_lpass_clk_cfg(&aux_dai_data->aux_clk_set, enable);
  752. if (!enable)
  753. rc = audio_prm_set_lpass_clk_cfg(&aux_dai_data->aux_clk_set, enable);
  754. return rc;
  755. }
  756. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  757. struct snd_soc_dai *dai)
  758. {
  759. int rc = 0;
  760. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  761. dev_get_drvdata(dai->dev);
  762. mutex_lock(&aux_dai_data->rlock);
  763. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  764. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  765. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  766. __func__, dai->id);
  767. goto exit;
  768. }
  769. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  770. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  771. clear_bit(STATUS_TX_PORT,
  772. aux_dai_data->auxpcm_port_status);
  773. else {
  774. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  775. __func__);
  776. goto exit;
  777. }
  778. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  779. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  780. clear_bit(STATUS_RX_PORT,
  781. aux_dai_data->auxpcm_port_status);
  782. else {
  783. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  784. __func__);
  785. goto exit;
  786. }
  787. }
  788. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  789. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  790. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  791. __func__);
  792. goto exit;
  793. }
  794. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  795. __func__, dai->id);
  796. if (rc < 0)
  797. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  798. if (rc < 0)
  799. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  800. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  801. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  802. exit:
  803. mutex_unlock(&aux_dai_data->rlock);
  804. }
  805. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  806. struct snd_soc_dai *dai)
  807. {
  808. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  809. dev_get_drvdata(dai->dev);
  810. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  811. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  812. int rc = 0;
  813. u32 pcm_clk_rate = 0;
  814. auxpcm_pdata = dai->dev->platform_data;
  815. mutex_lock(&aux_dai_data->rlock);
  816. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  817. if (test_bit(STATUS_TX_PORT,
  818. aux_dai_data->auxpcm_port_status)) {
  819. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  820. __func__);
  821. goto exit;
  822. } else
  823. set_bit(STATUS_TX_PORT,
  824. aux_dai_data->auxpcm_port_status);
  825. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  826. if (test_bit(STATUS_RX_PORT,
  827. aux_dai_data->auxpcm_port_status)) {
  828. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  829. __func__);
  830. goto exit;
  831. } else
  832. set_bit(STATUS_RX_PORT,
  833. aux_dai_data->auxpcm_port_status);
  834. }
  835. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  836. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  837. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  838. goto exit;
  839. }
  840. if (dai_data->rate == 8000) {
  841. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  842. } else if (dai_data->rate == 16000) {
  843. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  844. } else if (dai_data->rate == 32000) {
  845. pcm_clk_rate = (auxpcm_pdata->mode_32k.pcm_clk_rate);
  846. } else if (dai_data->rate == 48000) {
  847. pcm_clk_rate = (auxpcm_pdata->mode_48k.pcm_clk_rate);
  848. } else {
  849. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  850. dai_data->rate);
  851. rc = -EINVAL;
  852. goto fail;
  853. }
  854. pcm_clk_rate = dai_data->rate*16*8; //sample_rate * bitwidth * number_of_slots
  855. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  856. sizeof(struct afe_clk_set));
  857. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  858. switch (dai->id) {
  859. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  860. if (pcm_clk_rate)
  861. aux_dai_data->clk_set.clk_id =
  862. CLOCK_ID_PRI_PCM_IBIT;
  863. else
  864. aux_dai_data->clk_set.clk_id =
  865. CLOCK_ID_PRI_PCM_EBIT;
  866. break;
  867. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  868. if (pcm_clk_rate)
  869. aux_dai_data->clk_set.clk_id =
  870. CLOCK_ID_SEC_PCM_IBIT;
  871. else
  872. aux_dai_data->clk_set.clk_id =
  873. CLOCK_ID_SEC_PCM_EBIT;
  874. break;
  875. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  876. if (pcm_clk_rate)
  877. aux_dai_data->clk_set.clk_id =
  878. CLOCK_ID_TER_PCM_IBIT;
  879. else
  880. aux_dai_data->clk_set.clk_id =
  881. CLOCK_ID_TER_PCM_EBIT;
  882. break;
  883. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  884. if (pcm_clk_rate)
  885. aux_dai_data->clk_set.clk_id =
  886. CLOCK_ID_QUAD_PCM_IBIT;
  887. else
  888. aux_dai_data->clk_set.clk_id =
  889. CLOCK_ID_QUAD_PCM_EBIT;
  890. break;
  891. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  892. if (pcm_clk_rate)
  893. aux_dai_data->clk_set.clk_id =
  894. CLOCK_ID_QUI_PCM_IBIT;
  895. else
  896. aux_dai_data->clk_set.clk_id =
  897. CLOCK_ID_QUI_PCM_EBIT;
  898. break;
  899. case MSM_DAI_SEN_AUXPCM_DT_DEV_ID:
  900. if (pcm_clk_rate)
  901. aux_dai_data->clk_set.clk_id =
  902. CLOCK_ID_SEN_PCM_EBIT;
  903. else
  904. aux_dai_data->clk_set.clk_id =
  905. CLOCK_ID_SEN_PCM_EBIT;
  906. break;
  907. default:
  908. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  909. __func__, dai->id);
  910. break;
  911. }
  912. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  913. aux_dai_data->rx_pid, true);
  914. if (rc < 0) {
  915. dev_err(dai->dev,
  916. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  917. __func__);
  918. goto fail;
  919. }
  920. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  921. aux_dai_data->tx_pid, true);
  922. if (rc < 0) {
  923. dev_err(dai->dev,
  924. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  925. __func__);
  926. goto fail;
  927. }
  928. fail:
  929. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  930. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  931. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  932. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  933. exit:
  934. mutex_unlock(&aux_dai_data->rlock);
  935. return rc;
  936. }
  937. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  938. {
  939. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  940. aux_dai_data = dev_get_drvdata(dai->dev);
  941. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  942. __func__, dai->id);
  943. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  944. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  945. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  946. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  947. }
  948. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  949. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  950. return 0;
  951. }
  952. /*
  953. * For single CPU DAI registration, the dai id needs to be
  954. * set explicitly in the dai probe as ASoC does not read
  955. * the cpu->driver->id field rather it assigns the dai id
  956. * from the device name that is in the form %s.%d. This dai
  957. * id should be assigned to back-end AFE port id and used
  958. * during dai prepare. For multiple dai registration, it
  959. * is not required to call this function, however the dai->
  960. * driver->id field must be defined and set to corresponding
  961. * AFE Port id.
  962. */
  963. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  964. {
  965. if (!dai->driver) {
  966. dev_err(dai->dev, "DAI driver is not set\n");
  967. return;
  968. }
  969. if (!dai->driver->id) {
  970. dev_dbg(dai->dev, "DAI driver id is not set\n");
  971. return;
  972. }
  973. dai->id = dai->driver->id;
  974. }
  975. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  976. {
  977. int rc = 0;
  978. struct msm_dai_q6_auxpcm_dai_data *dai_data = NULL;
  979. if (!dai) {
  980. pr_err("%s: Invalid params dai\n", __func__);
  981. return -EINVAL;
  982. }
  983. if (!dai->dev) {
  984. pr_err("%s: Invalid params dai dev\n", __func__);
  985. return -EINVAL;
  986. }
  987. msm_dai_q6_set_dai_id(dai);
  988. dai_data = dev_get_drvdata(dai->dev);
  989. rc = msm_dai_q6_dai_add_route(dai);
  990. return rc;
  991. }
  992. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  993. .prepare = msm_dai_q6_auxpcm_prepare,
  994. .hw_params = msm_dai_q6_auxpcm_hw_params,
  995. .shutdown = msm_dai_q6_auxpcm_shutdown,
  996. };
  997. static const struct snd_soc_component_driver
  998. msm_dai_q6_aux_pcm_dai_component = {
  999. .name = "msm-auxpcm-dev",
  1000. };
  1001. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1002. {
  1003. .playback = {
  1004. .stream_name = "AUX PCM Playback",
  1005. .aif_name = "AUX_PCM_RX",
  1006. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  1007. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000,
  1008. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1009. .channels_min = 1,
  1010. .channels_max = 2,
  1011. .rate_max = 48000,
  1012. .rate_min = 8000,
  1013. },
  1014. .capture = {
  1015. .stream_name = "AUX PCM Capture",
  1016. .aif_name = "AUX_PCM_TX",
  1017. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  1018. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000,
  1019. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1020. .channels_min = 1,
  1021. .channels_max = 2,
  1022. .rate_max = 48000,
  1023. .rate_min = 8000,
  1024. },
  1025. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1026. .name = "Pri AUX PCM",
  1027. .ops = &msm_dai_q6_auxpcm_ops,
  1028. .probe = msm_dai_q6_aux_pcm_probe,
  1029. .remove = msm_dai_q6_dai_auxpcm_remove,
  1030. },
  1031. {
  1032. .playback = {
  1033. .stream_name = "Sec AUX PCM Playback",
  1034. .aif_name = "SEC_AUX_PCM_RX",
  1035. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1036. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1037. .channels_min = 1,
  1038. .channels_max = 1,
  1039. .rate_max = 16000,
  1040. .rate_min = 8000,
  1041. },
  1042. .capture = {
  1043. .stream_name = "Sec AUX PCM Capture",
  1044. .aif_name = "SEC_AUX_PCM_TX",
  1045. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1046. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1047. .channels_min = 1,
  1048. .channels_max = 1,
  1049. .rate_max = 16000,
  1050. .rate_min = 8000,
  1051. },
  1052. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1053. .name = "Sec AUX PCM",
  1054. .ops = &msm_dai_q6_auxpcm_ops,
  1055. .probe = msm_dai_q6_aux_pcm_probe,
  1056. .remove = msm_dai_q6_dai_auxpcm_remove,
  1057. },
  1058. {
  1059. .playback = {
  1060. .stream_name = "Tert AUX PCM Playback",
  1061. .aif_name = "TERT_AUX_PCM_RX",
  1062. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1063. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1064. .channels_min = 1,
  1065. .channels_max = 1,
  1066. .rate_max = 16000,
  1067. .rate_min = 8000,
  1068. },
  1069. .capture = {
  1070. .stream_name = "Tert AUX PCM Capture",
  1071. .aif_name = "TERT_AUX_PCM_TX",
  1072. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1073. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1074. .channels_min = 1,
  1075. .channels_max = 1,
  1076. .rate_max = 16000,
  1077. .rate_min = 8000,
  1078. },
  1079. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1080. .name = "Tert AUX PCM",
  1081. .ops = &msm_dai_q6_auxpcm_ops,
  1082. .probe = msm_dai_q6_aux_pcm_probe,
  1083. .remove = msm_dai_q6_dai_auxpcm_remove,
  1084. },
  1085. {
  1086. .playback = {
  1087. .stream_name = "Quat AUX PCM Playback",
  1088. .aif_name = "QUAT_AUX_PCM_RX",
  1089. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1090. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1091. .channels_min = 1,
  1092. .channels_max = 1,
  1093. .rate_max = 16000,
  1094. .rate_min = 8000,
  1095. },
  1096. .capture = {
  1097. .stream_name = "Quat AUX PCM Capture",
  1098. .aif_name = "QUAT_AUX_PCM_TX",
  1099. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1100. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1101. .channels_min = 1,
  1102. .channels_max = 1,
  1103. .rate_max = 16000,
  1104. .rate_min = 8000,
  1105. },
  1106. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1107. .name = "Quat AUX PCM",
  1108. .ops = &msm_dai_q6_auxpcm_ops,
  1109. .probe = msm_dai_q6_aux_pcm_probe,
  1110. .remove = msm_dai_q6_dai_auxpcm_remove,
  1111. },
  1112. {
  1113. .playback = {
  1114. .stream_name = "Quin AUX PCM Playback",
  1115. .aif_name = "QUIN_AUX_PCM_RX",
  1116. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1117. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1118. .channels_min = 1,
  1119. .channels_max = 1,
  1120. .rate_max = 16000,
  1121. .rate_min = 8000,
  1122. },
  1123. .capture = {
  1124. .stream_name = "Quin AUX PCM Capture",
  1125. .aif_name = "QUIN_AUX_PCM_TX",
  1126. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1127. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1128. .channels_min = 1,
  1129. .channels_max = 1,
  1130. .rate_max = 16000,
  1131. .rate_min = 8000,
  1132. },
  1133. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1134. .name = "Quin AUX PCM",
  1135. .ops = &msm_dai_q6_auxpcm_ops,
  1136. .probe = msm_dai_q6_aux_pcm_probe,
  1137. .remove = msm_dai_q6_dai_auxpcm_remove,
  1138. },
  1139. {
  1140. .playback = {
  1141. .stream_name = "Sen AUX PCM Playback",
  1142. .aif_name = "SEN_AUX_PCM_RX",
  1143. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1144. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1145. .channels_min = 1,
  1146. .channels_max = 1,
  1147. .rate_max = 16000,
  1148. .rate_min = 8000,
  1149. },
  1150. .capture = {
  1151. .stream_name = "Sen AUX PCM Capture",
  1152. .aif_name = "SEN_AUX_PCM_TX",
  1153. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1154. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1155. .channels_min = 1,
  1156. .channels_max = 1,
  1157. .rate_max = 16000,
  1158. .rate_min = 8000,
  1159. },
  1160. .id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID,
  1161. .name = "Sen AUX PCM",
  1162. .ops = &msm_dai_q6_auxpcm_ops,
  1163. .probe = msm_dai_q6_aux_pcm_probe,
  1164. .remove = msm_dai_q6_dai_auxpcm_remove,
  1165. },
  1166. };
  1167. static u16 num_of_bits_set(u16 sd_line_mask)
  1168. {
  1169. u8 num_bits_set = 0;
  1170. while (sd_line_mask) {
  1171. num_bits_set++;
  1172. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  1173. }
  1174. return num_bits_set;
  1175. }
  1176. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  1177. {
  1178. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  1179. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  1180. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  1181. uint32_t val = 0;
  1182. const char *intf_name;
  1183. int rc = 0, i = 0, len = 0;
  1184. const uint32_t *slot_mapping_array = NULL;
  1185. u32 array_length = 0;
  1186. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  1187. GFP_KERNEL);
  1188. if (!dai_data)
  1189. return -ENOMEM;
  1190. rc = of_property_read_u32(pdev->dev.of_node,
  1191. "qcom,msm-dai-is-island-supported",
  1192. &dai_data->is_island_dai);
  1193. if (rc)
  1194. dev_dbg(&pdev->dev, "island supported entry not found\n");
  1195. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  1196. GFP_KERNEL);
  1197. if (!auxpcm_pdata) {
  1198. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  1199. goto fail_pdata_nomem;
  1200. }
  1201. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  1202. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  1203. rc = of_property_read_u32_array(pdev->dev.of_node,
  1204. "qcom,msm-cpudai-auxpcm-mode",
  1205. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  1206. if (rc) {
  1207. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  1208. __func__);
  1209. goto fail_invalid_dt;
  1210. }
  1211. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  1212. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  1213. rc = of_property_read_u32_array(pdev->dev.of_node,
  1214. "qcom,msm-cpudai-auxpcm-sync",
  1215. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  1216. if (rc) {
  1217. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  1218. __func__);
  1219. goto fail_invalid_dt;
  1220. }
  1221. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  1222. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  1223. rc = of_property_read_u32_array(pdev->dev.of_node,
  1224. "qcom,msm-cpudai-auxpcm-frame",
  1225. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  1226. if (rc) {
  1227. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  1228. __func__);
  1229. goto fail_invalid_dt;
  1230. }
  1231. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  1232. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  1233. rc = of_property_read_u32_array(pdev->dev.of_node,
  1234. "qcom,msm-cpudai-auxpcm-quant",
  1235. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  1236. if (rc) {
  1237. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  1238. __func__);
  1239. goto fail_invalid_dt;
  1240. }
  1241. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  1242. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  1243. rc = of_property_read_u32_array(pdev->dev.of_node,
  1244. "qcom,msm-cpudai-auxpcm-num-slots",
  1245. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  1246. if (rc) {
  1247. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  1248. __func__);
  1249. goto fail_invalid_dt;
  1250. }
  1251. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  1252. if (auxpcm_pdata->mode_8k.num_slots >
  1253. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  1254. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  1255. __func__,
  1256. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  1257. auxpcm_pdata->mode_8k.num_slots);
  1258. rc = -EINVAL;
  1259. goto fail_invalid_dt;
  1260. }
  1261. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  1262. if (auxpcm_pdata->mode_16k.num_slots >
  1263. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  1264. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  1265. __func__,
  1266. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  1267. auxpcm_pdata->mode_16k.num_slots);
  1268. rc = -EINVAL;
  1269. goto fail_invalid_dt;
  1270. }
  1271. slot_mapping_array = of_get_property(pdev->dev.of_node,
  1272. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  1273. if (slot_mapping_array == NULL) {
  1274. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  1275. __func__);
  1276. rc = -EINVAL;
  1277. goto fail_invalid_dt;
  1278. }
  1279. array_length = auxpcm_pdata->mode_8k.num_slots +
  1280. auxpcm_pdata->mode_16k.num_slots;
  1281. if (len != sizeof(uint32_t) * array_length) {
  1282. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  1283. __func__, len, sizeof(uint32_t) * array_length);
  1284. rc = -EINVAL;
  1285. goto fail_invalid_dt;
  1286. }
  1287. auxpcm_pdata->mode_8k.slot_mapping =
  1288. kzalloc(sizeof(uint16_t) *
  1289. auxpcm_pdata->mode_8k.num_slots,
  1290. GFP_KERNEL);
  1291. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  1292. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  1293. __func__);
  1294. rc = -ENOMEM;
  1295. goto fail_invalid_dt;
  1296. }
  1297. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  1298. auxpcm_pdata->mode_8k.slot_mapping[i] =
  1299. (u16)be32_to_cpu(slot_mapping_array[i]);
  1300. auxpcm_pdata->mode_16k.slot_mapping =
  1301. kzalloc(sizeof(uint16_t) *
  1302. auxpcm_pdata->mode_16k.num_slots,
  1303. GFP_KERNEL);
  1304. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  1305. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  1306. __func__);
  1307. rc = -ENOMEM;
  1308. goto fail_invalid_16k_slot_mapping;
  1309. }
  1310. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  1311. auxpcm_pdata->mode_16k.slot_mapping[i] =
  1312. (u16)be32_to_cpu(slot_mapping_array[i +
  1313. auxpcm_pdata->mode_8k.num_slots]);
  1314. rc = of_property_read_u32_array(pdev->dev.of_node,
  1315. "qcom,msm-cpudai-auxpcm-data",
  1316. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  1317. if (rc) {
  1318. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  1319. __func__);
  1320. goto fail_invalid_dt1;
  1321. }
  1322. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  1323. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  1324. rc = of_property_read_u32_array(pdev->dev.of_node,
  1325. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  1326. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  1327. if (rc) {
  1328. dev_err(&pdev->dev,
  1329. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  1330. __func__);
  1331. goto fail_invalid_dt1;
  1332. }
  1333. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  1334. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  1335. rc = of_property_read_string(pdev->dev.of_node,
  1336. "qcom,msm-auxpcm-interface", &intf_name);
  1337. if (rc) {
  1338. dev_err(&pdev->dev,
  1339. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  1340. __func__);
  1341. goto fail_nodev_intf;
  1342. }
  1343. if (!strcmp(intf_name, "primary")) {
  1344. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  1345. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  1346. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  1347. i = 0;
  1348. } else if (!strcmp(intf_name, "secondary")) {
  1349. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  1350. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  1351. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  1352. i = 1;
  1353. } else if (!strcmp(intf_name, "tertiary")) {
  1354. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  1355. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  1356. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  1357. i = 2;
  1358. } else if (!strcmp(intf_name, "quaternary")) {
  1359. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  1360. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  1361. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  1362. i = 3;
  1363. } else if (!strcmp(intf_name, "quinary")) {
  1364. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  1365. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  1366. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  1367. i = 4;
  1368. } else if (!strcmp(intf_name, "senary")) {
  1369. dai_data->rx_pid = AFE_PORT_ID_SENARY_PCM_RX;
  1370. dai_data->tx_pid = AFE_PORT_ID_SENARY_PCM_TX;
  1371. pdev->id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID;
  1372. i = 5;
  1373. } else {
  1374. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  1375. __func__, intf_name);
  1376. goto fail_invalid_intf;
  1377. }
  1378. rc = of_property_read_u32(pdev->dev.of_node,
  1379. "qcom,msm-cpudai-afe-clk-ver", &val);
  1380. if (rc)
  1381. dai_data->clk_ver = AFE_CLK_VERSION_V1;
  1382. else
  1383. dai_data->clk_ver = val;
  1384. mutex_init(&dai_data->rlock);
  1385. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  1386. dev_set_drvdata(&pdev->dev, dai_data);
  1387. pdev->dev.platform_data = (void *) auxpcm_pdata;
  1388. rc = snd_soc_register_component(&pdev->dev,
  1389. &msm_dai_q6_aux_pcm_dai_component,
  1390. &msm_dai_q6_aux_pcm_dai[i], 1);
  1391. if (rc) {
  1392. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  1393. __func__, rc);
  1394. goto fail_reg_dai;
  1395. }
  1396. return rc;
  1397. fail_reg_dai:
  1398. fail_invalid_intf:
  1399. fail_nodev_intf:
  1400. fail_invalid_dt1:
  1401. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  1402. fail_invalid_16k_slot_mapping:
  1403. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  1404. fail_invalid_dt:
  1405. kfree(auxpcm_pdata);
  1406. fail_pdata_nomem:
  1407. kfree(dai_data);
  1408. return rc;
  1409. }
  1410. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  1411. {
  1412. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  1413. dai_data = dev_get_drvdata(&pdev->dev);
  1414. snd_soc_unregister_component(&pdev->dev);
  1415. mutex_destroy(&dai_data->rlock);
  1416. kfree(dai_data);
  1417. kfree(pdev->dev.platform_data);
  1418. return 0;
  1419. }
  1420. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  1421. { .compatible = "qcom,msm-auxpcm-dev", },
  1422. {}
  1423. };
  1424. static struct platform_driver msm_auxpcm_dev_driver = {
  1425. .probe = msm_auxpcm_dev_probe,
  1426. .remove = msm_auxpcm_dev_remove,
  1427. .driver = {
  1428. .name = "msm-auxpcm-dev",
  1429. .owner = THIS_MODULE,
  1430. .of_match_table = msm_auxpcm_dev_dt_match,
  1431. .suppress_bind_attrs = true,
  1432. },
  1433. };
  1434. /* Channel min and max are initialized base on platform data */
  1435. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  1436. {
  1437. .playback = {
  1438. .stream_name = "Slimbus Playback",
  1439. .aif_name = "SLIMBUS_0_RX",
  1440. .rates = SNDRV_PCM_RATE_8000_384000,
  1441. .formats = DAI_FORMATS_S16_S24_S32_LE,
  1442. .channels_min = 1,
  1443. .channels_max = 8,
  1444. .rate_min = 8000,
  1445. .rate_max = 384000,
  1446. },
  1447. .id = SLIMBUS_0_RX,
  1448. },
  1449. {
  1450. .playback = {
  1451. .stream_name = "Slimbus6 Playback",
  1452. .aif_name = "SLIMBUS_6_RX",
  1453. .rates = SNDRV_PCM_RATE_8000_384000,
  1454. .formats = DAI_FORMATS_S16_S24_S32_LE,
  1455. .channels_min = 1,
  1456. .channels_max = 2,
  1457. .rate_min = 8000,
  1458. .rate_max = 384000,
  1459. },
  1460. .id = SLIMBUS_6_RX,
  1461. },
  1462. };
  1463. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  1464. {
  1465. .capture = {
  1466. .stream_name = "Slimbus Capture",
  1467. .aif_name = "SLIMBUS_0_TX",
  1468. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1469. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  1470. SNDRV_PCM_RATE_192000,
  1471. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1472. SNDRV_PCM_FMTBIT_S24_LE |
  1473. SNDRV_PCM_FMTBIT_S24_3LE,
  1474. .channels_min = 1,
  1475. .channels_max = 8,
  1476. .rate_min = 8000,
  1477. .rate_max = 192000,
  1478. },
  1479. .id = SLIMBUS_0_TX,
  1480. },
  1481. };
  1482. /* Channel min and max are initialized base on platform data */
  1483. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  1484. {
  1485. .playback = {
  1486. .stream_name = "Primary MI2S Playback",
  1487. .aif_name = "PRI_MI2S_RX",
  1488. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1489. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1490. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1491. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  1492. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  1493. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  1494. SNDRV_PCM_RATE_384000,
  1495. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1496. SNDRV_PCM_FMTBIT_S24_LE |
  1497. SNDRV_PCM_FMTBIT_S24_3LE,
  1498. .rate_min = 8000,
  1499. .rate_max = 384000,
  1500. },
  1501. .capture = {
  1502. .stream_name = "Primary MI2S Capture",
  1503. .aif_name = "PRI_MI2S_TX",
  1504. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1505. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1506. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1507. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  1508. SNDRV_PCM_RATE_192000,
  1509. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1510. .rate_min = 8000,
  1511. .rate_max = 192000,
  1512. },
  1513. .name = "Primary MI2S",
  1514. .id = MSM_PRIM_MI2S,
  1515. },
  1516. {
  1517. .playback = {
  1518. .stream_name = "Secondary MI2S Playback",
  1519. .aif_name = "SEC_MI2S_RX",
  1520. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1521. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1522. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1523. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  1524. SNDRV_PCM_RATE_192000,
  1525. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1526. .rate_min = 8000,
  1527. .rate_max = 192000,
  1528. },
  1529. .capture = {
  1530. .stream_name = "Secondary MI2S Capture",
  1531. .aif_name = "SEC_MI2S_TX",
  1532. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1533. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1534. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1535. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  1536. SNDRV_PCM_RATE_192000,
  1537. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1538. .rate_min = 8000,
  1539. .rate_max = 192000,
  1540. },
  1541. .name = "Secondary MI2S",
  1542. .id = MSM_SEC_MI2S,
  1543. },
  1544. {
  1545. .playback = {
  1546. .stream_name = "Tertiary MI2S Playback",
  1547. .aif_name = "TERT_MI2S_RX",
  1548. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1549. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1550. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1551. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  1552. SNDRV_PCM_RATE_192000,
  1553. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1554. .rate_min = 8000,
  1555. .rate_max = 192000,
  1556. },
  1557. .capture = {
  1558. .stream_name = "Tertiary MI2S Capture",
  1559. .aif_name = "TERT_MI2S_TX",
  1560. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1561. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1562. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1563. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  1564. SNDRV_PCM_RATE_192000,
  1565. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1566. .rate_min = 8000,
  1567. .rate_max = 192000,
  1568. },
  1569. .name = "Tertiary MI2S",
  1570. .id = MSM_TERT_MI2S,
  1571. },
  1572. {
  1573. .playback = {
  1574. .stream_name = "Quaternary MI2S Playback",
  1575. .aif_name = "QUAT_MI2S_RX",
  1576. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1577. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1578. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1579. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  1580. SNDRV_PCM_RATE_192000,
  1581. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1582. .rate_min = 8000,
  1583. .rate_max = 192000,
  1584. },
  1585. .capture = {
  1586. .stream_name = "Quaternary MI2S Capture",
  1587. .aif_name = "QUAT_MI2S_TX",
  1588. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  1589. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  1590. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  1591. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  1592. SNDRV_PCM_RATE_192000,
  1593. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1594. .rate_min = 8000,
  1595. .rate_max = 192000,
  1596. },
  1597. .name = "Quaternary MI2S",
  1598. .id = MSM_QUAT_MI2S,
  1599. },
  1600. {
  1601. .playback = {
  1602. .stream_name = "Quinary MI2S Playback",
  1603. .aif_name = "QUIN_MI2S_RX",
  1604. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1605. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  1606. SNDRV_PCM_RATE_192000,
  1607. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1608. .rate_min = 8000,
  1609. .rate_max = 192000,
  1610. },
  1611. .capture = {
  1612. .stream_name = "Quinary MI2S Capture",
  1613. .aif_name = "QUIN_MI2S_TX",
  1614. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1615. SNDRV_PCM_RATE_16000,
  1616. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1617. .rate_min = 8000,
  1618. .rate_max = 48000,
  1619. },
  1620. .name = "Quinary MI2S",
  1621. .id = MSM_QUIN_MI2S,
  1622. },
  1623. {
  1624. .playback = {
  1625. .stream_name = "Senary MI2S Playback",
  1626. .aif_name = "SEN_MI2S_RX",
  1627. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1628. SNDRV_PCM_RATE_16000,
  1629. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1630. .rate_min = 8000,
  1631. .rate_max = 48000,
  1632. },
  1633. .capture = {
  1634. .stream_name = "Senary MI2S Capture",
  1635. .aif_name = "SENARY_MI2S_TX",
  1636. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1637. SNDRV_PCM_RATE_16000,
  1638. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1639. .rate_min = 8000,
  1640. .rate_max = 48000,
  1641. },
  1642. .name = "Senary MI2S",
  1643. .id = MSM_SENARY_MI2S,
  1644. },
  1645. {
  1646. .playback = {
  1647. .stream_name = "Secondary MI2S Playback SD1",
  1648. .aif_name = "SEC_MI2S_RX_SD1",
  1649. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1650. SNDRV_PCM_RATE_16000,
  1651. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1652. .rate_min = 8000,
  1653. .rate_max = 48000,
  1654. },
  1655. .id = MSM_SEC_MI2S_SD1,
  1656. },
  1657. {
  1658. .playback = {
  1659. .stream_name = "INT0 MI2S Playback",
  1660. .aif_name = "INT0_MI2S_RX",
  1661. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1662. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  1663. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  1664. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1665. SNDRV_PCM_FMTBIT_S24_LE |
  1666. SNDRV_PCM_FMTBIT_S24_3LE,
  1667. .rate_min = 8000,
  1668. .rate_max = 192000,
  1669. },
  1670. .capture = {
  1671. .stream_name = "INT0 MI2S Capture",
  1672. .aif_name = "INT0_MI2S_TX",
  1673. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1674. SNDRV_PCM_RATE_16000,
  1675. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1676. .rate_min = 8000,
  1677. .rate_max = 48000,
  1678. },
  1679. .name = "INT0 MI2S",
  1680. .id = MSM_INT0_MI2S,
  1681. },
  1682. {
  1683. .playback = {
  1684. .stream_name = "INT1 MI2S Playback",
  1685. .aif_name = "INT1_MI2S_RX",
  1686. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1687. SNDRV_PCM_RATE_16000,
  1688. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1689. SNDRV_PCM_FMTBIT_S24_LE |
  1690. SNDRV_PCM_FMTBIT_S24_3LE,
  1691. .rate_min = 8000,
  1692. .rate_max = 48000,
  1693. },
  1694. .capture = {
  1695. .stream_name = "INT1 MI2S Capture",
  1696. .aif_name = "INT1_MI2S_TX",
  1697. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1698. SNDRV_PCM_RATE_16000,
  1699. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1700. .rate_min = 8000,
  1701. .rate_max = 48000,
  1702. },
  1703. .name = "INT1 MI2S",
  1704. .id = MSM_INT1_MI2S,
  1705. },
  1706. {
  1707. .playback = {
  1708. .stream_name = "INT2 MI2S Playback",
  1709. .aif_name = "INT2_MI2S_RX",
  1710. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1711. SNDRV_PCM_RATE_16000,
  1712. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1713. SNDRV_PCM_FMTBIT_S24_LE |
  1714. SNDRV_PCM_FMTBIT_S24_3LE,
  1715. .rate_min = 8000,
  1716. .rate_max = 48000,
  1717. },
  1718. .capture = {
  1719. .stream_name = "INT2 MI2S Capture",
  1720. .aif_name = "INT2_MI2S_TX",
  1721. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1722. SNDRV_PCM_RATE_16000,
  1723. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1724. .rate_min = 8000,
  1725. .rate_max = 48000,
  1726. },
  1727. .name = "INT2 MI2S",
  1728. .id = MSM_INT2_MI2S,
  1729. },
  1730. {
  1731. .playback = {
  1732. .stream_name = "INT3 MI2S Playback",
  1733. .aif_name = "INT3_MI2S_RX",
  1734. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1735. SNDRV_PCM_RATE_16000,
  1736. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1737. SNDRV_PCM_FMTBIT_S24_LE |
  1738. SNDRV_PCM_FMTBIT_S24_3LE,
  1739. .rate_min = 8000,
  1740. .rate_max = 48000,
  1741. },
  1742. .capture = {
  1743. .stream_name = "INT3 MI2S Capture",
  1744. .aif_name = "INT3_MI2S_TX",
  1745. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1746. SNDRV_PCM_RATE_16000,
  1747. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1748. .rate_min = 8000,
  1749. .rate_max = 48000,
  1750. },
  1751. .name = "INT3 MI2S",
  1752. .id = MSM_INT3_MI2S,
  1753. },
  1754. {
  1755. .playback = {
  1756. .stream_name = "INT4 MI2S Playback",
  1757. .aif_name = "INT4_MI2S_RX",
  1758. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1759. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  1760. SNDRV_PCM_RATE_192000,
  1761. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1762. SNDRV_PCM_FMTBIT_S24_LE |
  1763. SNDRV_PCM_FMTBIT_S24_3LE,
  1764. .rate_min = 8000,
  1765. .rate_max = 192000,
  1766. },
  1767. .capture = {
  1768. .stream_name = "INT4 MI2S Capture",
  1769. .aif_name = "INT4_MI2S_TX",
  1770. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1771. SNDRV_PCM_RATE_16000,
  1772. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1773. .rate_min = 8000,
  1774. .rate_max = 48000,
  1775. },
  1776. .name = "INT4 MI2S",
  1777. .id = MSM_INT4_MI2S,
  1778. },
  1779. {
  1780. .playback = {
  1781. .stream_name = "INT5 MI2S Playback",
  1782. .aif_name = "INT5_MI2S_RX",
  1783. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1784. SNDRV_PCM_RATE_16000,
  1785. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1786. SNDRV_PCM_FMTBIT_S24_LE |
  1787. SNDRV_PCM_FMTBIT_S24_3LE,
  1788. .rate_min = 8000,
  1789. .rate_max = 48000,
  1790. },
  1791. .capture = {
  1792. .stream_name = "INT5 MI2S Capture",
  1793. .aif_name = "INT5_MI2S_TX",
  1794. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1795. SNDRV_PCM_RATE_16000,
  1796. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1797. .rate_min = 8000,
  1798. .rate_max = 48000,
  1799. },
  1800. .name = "INT5 MI2S",
  1801. .id = MSM_INT5_MI2S,
  1802. },
  1803. {
  1804. .playback = {
  1805. .stream_name = "INT6 MI2S Playback",
  1806. .aif_name = "INT6_MI2S_RX",
  1807. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1808. SNDRV_PCM_RATE_16000,
  1809. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1810. SNDRV_PCM_FMTBIT_S24_LE |
  1811. SNDRV_PCM_FMTBIT_S24_3LE,
  1812. .rate_min = 8000,
  1813. .rate_max = 48000,
  1814. },
  1815. .capture = {
  1816. .stream_name = "INT6 MI2S Capture",
  1817. .aif_name = "INT6_MI2S_TX",
  1818. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1819. SNDRV_PCM_RATE_16000,
  1820. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1821. .rate_min = 8000,
  1822. .rate_max = 48000,
  1823. },
  1824. .name = "INT6 MI2S",
  1825. .id = MSM_INT6_MI2S,
  1826. },
  1827. };
  1828. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  1829. unsigned int *ch_cnt)
  1830. {
  1831. u8 num_of_sd_lines;
  1832. num_of_sd_lines = num_of_bits_set(sd_lines);
  1833. switch (num_of_sd_lines) {
  1834. case 0:
  1835. pr_debug("%s: no line is assigned\n", __func__);
  1836. break;
  1837. case 1:
  1838. switch (sd_lines) {
  1839. case MSM_MI2S_SD0:
  1840. *config_ptr = AFE_PORT_I2S_SD0;
  1841. break;
  1842. case MSM_MI2S_SD1:
  1843. *config_ptr = AFE_PORT_I2S_SD1;
  1844. break;
  1845. case MSM_MI2S_SD2:
  1846. *config_ptr = AFE_PORT_I2S_SD2;
  1847. break;
  1848. case MSM_MI2S_SD3:
  1849. *config_ptr = AFE_PORT_I2S_SD3;
  1850. break;
  1851. case MSM_MI2S_SD4:
  1852. *config_ptr = AFE_PORT_I2S_SD4;
  1853. break;
  1854. case MSM_MI2S_SD5:
  1855. *config_ptr = AFE_PORT_I2S_SD5;
  1856. break;
  1857. case MSM_MI2S_SD6:
  1858. *config_ptr = AFE_PORT_I2S_SD6;
  1859. break;
  1860. case MSM_MI2S_SD7:
  1861. *config_ptr = AFE_PORT_I2S_SD7;
  1862. break;
  1863. default:
  1864. pr_err("%s: invalid SD lines %d\n",
  1865. __func__, sd_lines);
  1866. goto error_invalid_data;
  1867. }
  1868. break;
  1869. case 2:
  1870. switch (sd_lines) {
  1871. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  1872. *config_ptr = AFE_PORT_I2S_QUAD01;
  1873. break;
  1874. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  1875. *config_ptr = AFE_PORT_I2S_QUAD23;
  1876. break;
  1877. case MSM_MI2S_SD4 | MSM_MI2S_SD5:
  1878. *config_ptr = AFE_PORT_I2S_QUAD45;
  1879. break;
  1880. case MSM_MI2S_SD6 | MSM_MI2S_SD7:
  1881. *config_ptr = AFE_PORT_I2S_QUAD67;
  1882. break;
  1883. default:
  1884. pr_err("%s: invalid SD lines %d\n",
  1885. __func__, sd_lines);
  1886. goto error_invalid_data;
  1887. }
  1888. break;
  1889. case 3:
  1890. switch (sd_lines) {
  1891. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  1892. *config_ptr = AFE_PORT_I2S_6CHS;
  1893. break;
  1894. default:
  1895. pr_err("%s: invalid SD lines %d\n",
  1896. __func__, sd_lines);
  1897. goto error_invalid_data;
  1898. }
  1899. break;
  1900. case 4:
  1901. switch (sd_lines) {
  1902. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  1903. *config_ptr = AFE_PORT_I2S_8CHS;
  1904. break;
  1905. case MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  1906. *config_ptr = AFE_PORT_I2S_8CHS_2;
  1907. break;
  1908. default:
  1909. pr_err("%s: invalid SD lines %d\n",
  1910. __func__, sd_lines);
  1911. goto error_invalid_data;
  1912. }
  1913. break;
  1914. case 5:
  1915. switch (sd_lines) {
  1916. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  1917. | MSM_MI2S_SD3 | MSM_MI2S_SD4:
  1918. *config_ptr = AFE_PORT_I2S_10CHS;
  1919. break;
  1920. default:
  1921. pr_err("%s: invalid SD lines %d\n",
  1922. __func__, sd_lines);
  1923. goto error_invalid_data;
  1924. }
  1925. break;
  1926. case 6:
  1927. switch (sd_lines) {
  1928. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  1929. | MSM_MI2S_SD3 | MSM_MI2S_SD4 | MSM_MI2S_SD5:
  1930. *config_ptr = AFE_PORT_I2S_12CHS;
  1931. break;
  1932. default:
  1933. pr_err("%s: invalid SD lines %d\n",
  1934. __func__, sd_lines);
  1935. goto error_invalid_data;
  1936. }
  1937. break;
  1938. case 7:
  1939. switch (sd_lines) {
  1940. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  1941. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6:
  1942. *config_ptr = AFE_PORT_I2S_14CHS;
  1943. break;
  1944. default:
  1945. pr_err("%s: invalid SD lines %d\n",
  1946. __func__, sd_lines);
  1947. goto error_invalid_data;
  1948. }
  1949. break;
  1950. case 8:
  1951. switch (sd_lines) {
  1952. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  1953. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  1954. *config_ptr = AFE_PORT_I2S_16CHS;
  1955. break;
  1956. default:
  1957. pr_err("%s: invalid SD lines %d\n",
  1958. __func__, sd_lines);
  1959. goto error_invalid_data;
  1960. }
  1961. break;
  1962. default:
  1963. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  1964. goto error_invalid_data;
  1965. }
  1966. *ch_cnt = num_of_sd_lines;
  1967. return 0;
  1968. error_invalid_data:
  1969. pr_err("%s: invalid data\n", __func__);
  1970. return -EINVAL;
  1971. }
  1972. #if 0
  1973. static u16 msm_dai_q6_mi2s_get_num_channels(u16 config)
  1974. {
  1975. switch (config) {
  1976. case AFE_PORT_I2S_SD0:
  1977. case AFE_PORT_I2S_SD1:
  1978. case AFE_PORT_I2S_SD2:
  1979. case AFE_PORT_I2S_SD3:
  1980. case AFE_PORT_I2S_SD4:
  1981. case AFE_PORT_I2S_SD5:
  1982. case AFE_PORT_I2S_SD6:
  1983. case AFE_PORT_I2S_SD7:
  1984. return 2;
  1985. case AFE_PORT_I2S_QUAD01:
  1986. case AFE_PORT_I2S_QUAD23:
  1987. case AFE_PORT_I2S_QUAD45:
  1988. case AFE_PORT_I2S_QUAD67:
  1989. return 4;
  1990. case AFE_PORT_I2S_6CHS:
  1991. return 6;
  1992. case AFE_PORT_I2S_8CHS:
  1993. case AFE_PORT_I2S_8CHS_2:
  1994. return 8;
  1995. case AFE_PORT_I2S_10CHS:
  1996. return 10;
  1997. case AFE_PORT_I2S_12CHS:
  1998. return 12;
  1999. case AFE_PORT_I2S_14CHS:
  2000. return 14;
  2001. case AFE_PORT_I2S_16CHS:
  2002. return 16;
  2003. default:
  2004. pr_err("%s: invalid config\n", __func__);
  2005. return 0;
  2006. }
  2007. }
  2008. #endif
  2009. static int msm_dai_q6_mi2s_platform_data_validation(
  2010. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  2011. {
  2012. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  2013. struct msm_mi2s_pdata *mi2s_pdata =
  2014. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  2015. unsigned int ch_cnt;
  2016. int rc = 0;
  2017. u16 sd_line;
  2018. if (mi2s_pdata == NULL) {
  2019. pr_err("%s: mi2s_pdata NULL", __func__);
  2020. return -EINVAL;
  2021. }
  2022. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  2023. &sd_line, &ch_cnt);
  2024. if (rc < 0) {
  2025. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  2026. goto rtn;
  2027. }
  2028. if (ch_cnt) {
  2029. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  2030. sd_line;
  2031. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  2032. dai_driver->playback.channels_min = 1;
  2033. dai_driver->playback.channels_max = ch_cnt << 1;
  2034. } else {
  2035. dai_driver->playback.channels_min = 0;
  2036. dai_driver->playback.channels_max = 0;
  2037. }
  2038. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  2039. &sd_line, &ch_cnt);
  2040. if (rc < 0) {
  2041. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  2042. goto rtn;
  2043. }
  2044. if (ch_cnt) {
  2045. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  2046. sd_line;
  2047. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  2048. dai_driver->capture.channels_min = 1;
  2049. dai_driver->capture.channels_max = ch_cnt << 1;
  2050. } else {
  2051. dai_driver->capture.channels_min = 0;
  2052. dai_driver->capture.channels_max = 0;
  2053. }
  2054. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  2055. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  2056. dai_data->tx_dai.pdata_mi2s_lines);
  2057. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  2058. __func__, dai_driver->playback.channels_max,
  2059. dai_driver->capture.channels_max);
  2060. rtn:
  2061. return rc;
  2062. }
  2063. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  2064. .name = "msm-dai-q6-mi2s",
  2065. };
  2066. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  2067. {
  2068. struct msm_dai_q6_mi2s_dai_data *dai_data;
  2069. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  2070. u32 tx_line = 0;
  2071. u32 rx_line = 0;
  2072. u32 mi2s_intf = 0;
  2073. struct msm_mi2s_pdata *mi2s_pdata;
  2074. int rc;
  2075. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  2076. &mi2s_intf);
  2077. if (rc) {
  2078. dev_err(&pdev->dev,
  2079. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  2080. goto rtn;
  2081. }
  2082. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  2083. mi2s_intf);
  2084. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  2085. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  2086. dev_err(&pdev->dev,
  2087. "%s: Invalid MI2S ID %u from Device Tree\n",
  2088. __func__, mi2s_intf);
  2089. rc = -ENXIO;
  2090. goto rtn;
  2091. }
  2092. pdev->id = mi2s_intf;
  2093. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  2094. if (!mi2s_pdata) {
  2095. rc = -ENOMEM;
  2096. goto rtn;
  2097. }
  2098. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  2099. &rx_line);
  2100. if (rc) {
  2101. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  2102. "qcom,msm-mi2s-rx-lines");
  2103. goto free_pdata;
  2104. }
  2105. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  2106. &tx_line);
  2107. if (rc) {
  2108. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  2109. "qcom,msm-mi2s-tx-lines");
  2110. goto free_pdata;
  2111. }
  2112. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  2113. dev_name(&pdev->dev), rx_line, tx_line);
  2114. mi2s_pdata->rx_sd_lines = rx_line;
  2115. mi2s_pdata->tx_sd_lines = tx_line;
  2116. mi2s_pdata->intf_id = mi2s_intf;
  2117. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  2118. GFP_KERNEL);
  2119. if (!dai_data) {
  2120. rc = -ENOMEM;
  2121. goto free_pdata;
  2122. } else
  2123. dev_set_drvdata(&pdev->dev, dai_data);
  2124. rc = of_property_read_u32(pdev->dev.of_node,
  2125. "qcom,msm-dai-is-island-supported",
  2126. &dai_data->is_island_dai);
  2127. if (rc)
  2128. dev_dbg(&pdev->dev, "island supported entry not found\n");
  2129. pdev->dev.platform_data = mi2s_pdata;
  2130. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  2131. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  2132. if (rc < 0)
  2133. goto free_dai_data;
  2134. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  2135. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  2136. if (rc < 0)
  2137. goto err_register;
  2138. return 0;
  2139. err_register:
  2140. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  2141. free_dai_data:
  2142. kfree(dai_data);
  2143. free_pdata:
  2144. kfree(mi2s_pdata);
  2145. rtn:
  2146. return rc;
  2147. }
  2148. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  2149. {
  2150. snd_soc_unregister_component(&pdev->dev);
  2151. return 0;
  2152. }
  2153. #if 0
  2154. static int msm_dai_q6_dai_meta_mi2s_probe(struct snd_soc_dai *dai)
  2155. {
  2156. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  2157. (struct msm_meta_mi2s_pdata *) dai->dev->platform_data;
  2158. int rc = 0;
  2159. dai->id = meta_mi2s_pdata->intf_id;
  2160. rc = msm_dai_q6_dai_add_route(dai);
  2161. return rc;
  2162. }
  2163. static int msm_dai_q6_dai_meta_mi2s_remove(struct snd_soc_dai *dai)
  2164. {
  2165. return 0;
  2166. }
  2167. static int msm_dai_q6_meta_mi2s_startup(struct snd_pcm_substream *substream,
  2168. struct snd_soc_dai *dai)
  2169. {
  2170. return 0;
  2171. }
  2172. static int msm_meta_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  2173. {
  2174. int ret = 0;
  2175. switch (stream) {
  2176. case SNDRV_PCM_STREAM_PLAYBACK:
  2177. switch (mi2s_id) {
  2178. case MSM_PRIM_META_MI2S:
  2179. *port_id = AFE_PORT_ID_PRIMARY_META_MI2S_RX;
  2180. break;
  2181. case MSM_SEC_META_MI2S:
  2182. *port_id = AFE_PORT_ID_SECONDARY_META_MI2S_RX;
  2183. break;
  2184. default:
  2185. pr_err("%s: playback err id 0x%x\n",
  2186. __func__, mi2s_id);
  2187. ret = -1;
  2188. break;
  2189. }
  2190. break;
  2191. case SNDRV_PCM_STREAM_CAPTURE:
  2192. switch (mi2s_id) {
  2193. default:
  2194. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  2195. ret = -1;
  2196. break;
  2197. }
  2198. break;
  2199. default:
  2200. pr_err("%s: default err %d\n", __func__, stream);
  2201. ret = -1;
  2202. break;
  2203. }
  2204. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  2205. return ret;
  2206. }
  2207. static int msm_dai_q6_meta_mi2s_prepare(struct snd_pcm_substream *substream,
  2208. struct snd_soc_dai *dai)
  2209. {
  2210. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  2211. dev_get_drvdata(dai->dev);
  2212. u16 port_id = 0;
  2213. int rc = 0;
  2214. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  2215. &port_id) != 0) {
  2216. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  2217. __func__, port_id);
  2218. return -EINVAL;
  2219. }
  2220. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  2221. "dai_data->channels = %u sample_rate = %u\n", __func__,
  2222. dai->id, port_id, dai_data->channels, dai_data->rate);
  2223. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2224. /* PORT START should be set if prepare called
  2225. * in active state.
  2226. */
  2227. rc = afe_port_start(port_id, &dai_data->port_config,
  2228. dai_data->rate);
  2229. if (rc < 0)
  2230. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  2231. dai->id);
  2232. else
  2233. set_bit(STATUS_PORT_STARTED,
  2234. dai_data->status_mask);
  2235. }
  2236. return rc;
  2237. }
  2238. static int msm_dai_q6_meta_mi2s_hw_params(struct snd_pcm_substream *substream,
  2239. struct snd_pcm_hw_params *params,
  2240. struct snd_soc_dai *dai)
  2241. {
  2242. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  2243. dev_get_drvdata(dai->dev);
  2244. struct afe_param_id_meta_i2s_cfg *port_cfg =
  2245. &dai_data->port_config.meta_i2s;
  2246. int idx = 0;
  2247. u16 port_channels = 0;
  2248. u16 channels_left = 0;
  2249. dai_data->channels = params_channels(params);
  2250. channels_left = dai_data->channels;
  2251. /* map requested channels to channels that member ports provide */
  2252. for (idx = 0; idx < dai_data->num_member_ports; idx++) {
  2253. port_channels = msm_dai_q6_mi2s_get_num_channels(
  2254. dai_data->channel_mode[idx]);
  2255. if (channels_left >= port_channels) {
  2256. port_cfg->member_port_id[idx] =
  2257. dai_data->member_port_id[idx];
  2258. port_cfg->member_port_channel_mode[idx] =
  2259. dai_data->channel_mode[idx];
  2260. channels_left -= port_channels;
  2261. } else {
  2262. switch (channels_left) {
  2263. case 15:
  2264. case 16:
  2265. switch (dai_data->channel_mode[idx]) {
  2266. case AFE_PORT_I2S_16CHS:
  2267. port_cfg->member_port_channel_mode[idx]
  2268. = AFE_PORT_I2S_16CHS;
  2269. break;
  2270. default:
  2271. goto error_invalid_data;
  2272. };
  2273. break;
  2274. case 13:
  2275. case 14:
  2276. switch (dai_data->channel_mode[idx]) {
  2277. case AFE_PORT_I2S_14CHS:
  2278. case AFE_PORT_I2S_16CHS:
  2279. port_cfg->member_port_channel_mode[idx]
  2280. = AFE_PORT_I2S_14CHS;
  2281. break;
  2282. default:
  2283. goto error_invalid_data;
  2284. };
  2285. break;
  2286. case 11:
  2287. case 12:
  2288. switch (dai_data->channel_mode[idx]) {
  2289. case AFE_PORT_I2S_12CHS:
  2290. case AFE_PORT_I2S_14CHS:
  2291. case AFE_PORT_I2S_16CHS:
  2292. port_cfg->member_port_channel_mode[idx]
  2293. = AFE_PORT_I2S_12CHS;
  2294. break;
  2295. default:
  2296. goto error_invalid_data;
  2297. };
  2298. break;
  2299. case 9:
  2300. case 10:
  2301. switch (dai_data->channel_mode[idx]) {
  2302. case AFE_PORT_I2S_10CHS:
  2303. case AFE_PORT_I2S_12CHS:
  2304. case AFE_PORT_I2S_14CHS:
  2305. case AFE_PORT_I2S_16CHS:
  2306. port_cfg->member_port_channel_mode[idx]
  2307. = AFE_PORT_I2S_10CHS;
  2308. break;
  2309. default:
  2310. goto error_invalid_data;
  2311. };
  2312. break;
  2313. case 8:
  2314. case 7:
  2315. switch (dai_data->channel_mode[idx]) {
  2316. case AFE_PORT_I2S_8CHS:
  2317. case AFE_PORT_I2S_10CHS:
  2318. case AFE_PORT_I2S_12CHS:
  2319. case AFE_PORT_I2S_14CHS:
  2320. case AFE_PORT_I2S_16CHS:
  2321. port_cfg->member_port_channel_mode[idx]
  2322. = AFE_PORT_I2S_8CHS;
  2323. break;
  2324. case AFE_PORT_I2S_8CHS_2:
  2325. port_cfg->member_port_channel_mode[idx]
  2326. = AFE_PORT_I2S_8CHS_2;
  2327. break;
  2328. default:
  2329. goto error_invalid_data;
  2330. };
  2331. break;
  2332. case 6:
  2333. case 5:
  2334. switch (dai_data->channel_mode[idx]) {
  2335. case AFE_PORT_I2S_6CHS:
  2336. case AFE_PORT_I2S_8CHS:
  2337. case AFE_PORT_I2S_10CHS:
  2338. case AFE_PORT_I2S_12CHS:
  2339. case AFE_PORT_I2S_14CHS:
  2340. case AFE_PORT_I2S_16CHS:
  2341. port_cfg->member_port_channel_mode[idx]
  2342. = AFE_PORT_I2S_6CHS;
  2343. break;
  2344. default:
  2345. goto error_invalid_data;
  2346. };
  2347. break;
  2348. case 4:
  2349. case 3:
  2350. switch (dai_data->channel_mode[idx]) {
  2351. case AFE_PORT_I2S_SD0:
  2352. case AFE_PORT_I2S_SD1:
  2353. case AFE_PORT_I2S_SD2:
  2354. case AFE_PORT_I2S_SD3:
  2355. case AFE_PORT_I2S_SD4:
  2356. case AFE_PORT_I2S_SD5:
  2357. case AFE_PORT_I2S_SD6:
  2358. case AFE_PORT_I2S_SD7:
  2359. goto error_invalid_data;
  2360. case AFE_PORT_I2S_QUAD01:
  2361. case AFE_PORT_I2S_QUAD23:
  2362. case AFE_PORT_I2S_QUAD45:
  2363. case AFE_PORT_I2S_QUAD67:
  2364. port_cfg->member_port_channel_mode[idx]
  2365. = dai_data->channel_mode[idx];
  2366. break;
  2367. case AFE_PORT_I2S_8CHS_2:
  2368. port_cfg->member_port_channel_mode[idx]
  2369. = AFE_PORT_I2S_QUAD45;
  2370. break;
  2371. default:
  2372. port_cfg->member_port_channel_mode[idx]
  2373. = AFE_PORT_I2S_QUAD01;
  2374. };
  2375. break;
  2376. case 2:
  2377. case 1:
  2378. if (dai_data->channel_mode[idx] <
  2379. AFE_PORT_I2S_SD0)
  2380. goto error_invalid_data;
  2381. switch (dai_data->channel_mode[idx]) {
  2382. case AFE_PORT_I2S_SD0:
  2383. case AFE_PORT_I2S_SD1:
  2384. case AFE_PORT_I2S_SD2:
  2385. case AFE_PORT_I2S_SD3:
  2386. case AFE_PORT_I2S_SD4:
  2387. case AFE_PORT_I2S_SD5:
  2388. case AFE_PORT_I2S_SD6:
  2389. case AFE_PORT_I2S_SD7:
  2390. port_cfg->member_port_channel_mode[idx]
  2391. = dai_data->channel_mode[idx];
  2392. break;
  2393. case AFE_PORT_I2S_QUAD01:
  2394. case AFE_PORT_I2S_6CHS:
  2395. case AFE_PORT_I2S_8CHS:
  2396. case AFE_PORT_I2S_10CHS:
  2397. case AFE_PORT_I2S_12CHS:
  2398. case AFE_PORT_I2S_14CHS:
  2399. case AFE_PORT_I2S_16CHS:
  2400. port_cfg->member_port_channel_mode[idx]
  2401. = AFE_PORT_I2S_SD0;
  2402. break;
  2403. case AFE_PORT_I2S_QUAD23:
  2404. port_cfg->member_port_channel_mode[idx]
  2405. = AFE_PORT_I2S_SD2;
  2406. break;
  2407. case AFE_PORT_I2S_QUAD45:
  2408. case AFE_PORT_I2S_8CHS_2:
  2409. port_cfg->member_port_channel_mode[idx]
  2410. = AFE_PORT_I2S_SD4;
  2411. break;
  2412. case AFE_PORT_I2S_QUAD67:
  2413. port_cfg->member_port_channel_mode[idx]
  2414. = AFE_PORT_I2S_SD6;
  2415. break;
  2416. }
  2417. break;
  2418. case 0:
  2419. port_cfg->member_port_channel_mode[idx] = 0;
  2420. }
  2421. if (port_cfg->member_port_channel_mode[idx] == 0) {
  2422. port_cfg->member_port_id[idx] =
  2423. AFE_PORT_ID_INVALID;
  2424. } else {
  2425. port_cfg->member_port_id[idx] =
  2426. dai_data->member_port_id[idx];
  2427. channels_left -=
  2428. msm_dai_q6_mi2s_get_num_channels(
  2429. port_cfg->member_port_channel_mode[idx]);
  2430. }
  2431. }
  2432. }
  2433. if (channels_left > 0) {
  2434. pr_err("%s: too many channels %d\n",
  2435. __func__, dai_data->channels);
  2436. return -EINVAL;
  2437. }
  2438. dai_data->rate = params_rate(params);
  2439. port_cfg->sample_rate = dai_data->rate;
  2440. switch (params_format(params)) {
  2441. case SNDRV_PCM_FORMAT_S16_LE:
  2442. case SNDRV_PCM_FORMAT_SPECIAL:
  2443. port_cfg->bit_width = 16;
  2444. dai_data->bitwidth = 16;
  2445. break;
  2446. case SNDRV_PCM_FORMAT_S24_LE:
  2447. case SNDRV_PCM_FORMAT_S24_3LE:
  2448. port_cfg->bit_width = 24;
  2449. dai_data->bitwidth = 24;
  2450. break;
  2451. default:
  2452. pr_err("%s: format %d\n",
  2453. __func__, params_format(params));
  2454. return -EINVAL;
  2455. }
  2456. port_cfg->minor_version = AFE_API_VERSION_META_I2S_CONFIG;
  2457. port_cfg->data_format = AFE_LINEAR_PCM_DATA;
  2458. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  2459. "bit_width = %hu ws_src = 0x%x sample_rate = %u\n"
  2460. "member_ports 0x%x 0x%x 0x%x 0x%x\n"
  2461. "sd_lines 0x%x 0x%x 0x%x 0x%x\n",
  2462. __func__, dai->id, dai_data->channels,
  2463. port_cfg->bit_width, port_cfg->ws_src, port_cfg->sample_rate,
  2464. port_cfg->member_port_id[0],
  2465. port_cfg->member_port_id[1],
  2466. port_cfg->member_port_id[2],
  2467. port_cfg->member_port_id[3],
  2468. port_cfg->member_port_channel_mode[0],
  2469. port_cfg->member_port_channel_mode[1],
  2470. port_cfg->member_port_channel_mode[2],
  2471. port_cfg->member_port_channel_mode[3]);
  2472. return 0;
  2473. error_invalid_data:
  2474. pr_err("%s: error when assigning member port %d channels (channels_left %d)\n",
  2475. __func__, idx, channels_left);
  2476. return -EINVAL;
  2477. }
  2478. static int msm_dai_q6_meta_mi2s_set_fmt(struct snd_soc_dai *dai,
  2479. unsigned int fmt)
  2480. {
  2481. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  2482. dev_get_drvdata(dai->dev);
  2483. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2484. dev_err(dai->dev, "%s: err chg meta i2s mode while dai running",
  2485. __func__);
  2486. return -EPERM;
  2487. }
  2488. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2489. case SND_SOC_DAIFMT_CBS_CFS:
  2490. dai_data->port_config.meta_i2s.ws_src = 1;
  2491. break;
  2492. case SND_SOC_DAIFMT_CBM_CFM:
  2493. dai_data->port_config.meta_i2s.ws_src = 0;
  2494. break;
  2495. default:
  2496. pr_err("%s: fmt %d\n",
  2497. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  2498. return -EINVAL;
  2499. }
  2500. return 0;
  2501. }
  2502. static void msm_dai_q6_meta_mi2s_shutdown(struct snd_pcm_substream *substream,
  2503. struct snd_soc_dai *dai)
  2504. {
  2505. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  2506. dev_get_drvdata(dai->dev);
  2507. u16 port_id = 0;
  2508. int rc = 0;
  2509. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  2510. &port_id) != 0) {
  2511. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  2512. __func__, port_id);
  2513. }
  2514. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  2515. __func__, port_id);
  2516. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2517. rc = afe_close(port_id);
  2518. if (rc < 0)
  2519. dev_err(dai->dev, "fail to close AFE port\n");
  2520. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2521. }
  2522. }
  2523. static struct snd_soc_dai_ops msm_dai_q6_meta_mi2s_ops = {
  2524. .startup = msm_dai_q6_meta_mi2s_startup,
  2525. .prepare = msm_dai_q6_meta_mi2s_prepare,
  2526. .hw_params = msm_dai_q6_meta_mi2s_hw_params,
  2527. .set_fmt = msm_dai_q6_meta_mi2s_set_fmt,
  2528. .shutdown = msm_dai_q6_meta_mi2s_shutdown,
  2529. };
  2530. /* Channel min and max are initialized base on platform data */
  2531. static struct snd_soc_dai_driver msm_dai_q6_meta_mi2s_dai[] = {
  2532. {
  2533. .playback = {
  2534. .stream_name = "Primary META MI2S Playback",
  2535. .aif_name = "PRI_META_MI2S_RX",
  2536. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2537. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2538. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2539. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  2540. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  2541. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  2542. SNDRV_PCM_RATE_384000,
  2543. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2544. SNDRV_PCM_FMTBIT_S24_LE |
  2545. SNDRV_PCM_FMTBIT_S24_3LE,
  2546. .rate_min = 8000,
  2547. .rate_max = 384000,
  2548. },
  2549. .ops = &msm_dai_q6_meta_mi2s_ops,
  2550. .name = "Primary META MI2S",
  2551. .id = AFE_PORT_ID_PRIMARY_META_MI2S_RX,
  2552. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  2553. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  2554. },
  2555. {
  2556. .playback = {
  2557. .stream_name = "Secondary META MI2S Playback",
  2558. .aif_name = "SEC_META_MI2S_RX",
  2559. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2560. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2561. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2562. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  2563. SNDRV_PCM_RATE_192000,
  2564. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2565. .rate_min = 8000,
  2566. .rate_max = 192000,
  2567. },
  2568. .ops = &msm_dai_q6_meta_mi2s_ops,
  2569. .name = "Secondary META MI2S",
  2570. .id = AFE_PORT_ID_SECONDARY_META_MI2S_RX,
  2571. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  2572. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  2573. },
  2574. };
  2575. static int msm_dai_q6_meta_mi2s_platform_data_validation(
  2576. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  2577. {
  2578. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  2579. dev_get_drvdata(&pdev->dev);
  2580. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  2581. (struct msm_meta_mi2s_pdata *) pdev->dev.platform_data;
  2582. int rc = 0;
  2583. int idx = 0;
  2584. u16 channel_mode = 0;
  2585. unsigned int ch_cnt = 0;
  2586. unsigned int ch_cnt_sum = 0;
  2587. struct afe_param_id_meta_i2s_cfg *port_cfg =
  2588. &dai_data->port_config.meta_i2s;
  2589. if (meta_mi2s_pdata == NULL) {
  2590. pr_err("%s: meta_mi2s_pdata NULL", __func__);
  2591. return -EINVAL;
  2592. }
  2593. dai_data->num_member_ports = meta_mi2s_pdata->num_member_ports;
  2594. for (idx = 0; idx < meta_mi2s_pdata->num_member_ports; idx++) {
  2595. rc = msm_dai_q6_mi2s_get_lineconfig(
  2596. meta_mi2s_pdata->sd_lines[idx],
  2597. &channel_mode,
  2598. &ch_cnt);
  2599. if (rc < 0) {
  2600. dev_err(&pdev->dev, "invalid META MI2S RX sd line config\n");
  2601. goto rtn;
  2602. }
  2603. if (ch_cnt) {
  2604. msm_mi2s_get_port_id(meta_mi2s_pdata->member_port[idx],
  2605. SNDRV_PCM_STREAM_PLAYBACK,
  2606. &dai_data->member_port_id[idx]);
  2607. dai_data->channel_mode[idx] = channel_mode;
  2608. port_cfg->member_port_id[idx] =
  2609. dai_data->member_port_id[idx];
  2610. port_cfg->member_port_channel_mode[idx] = channel_mode;
  2611. }
  2612. ch_cnt_sum += ch_cnt;
  2613. }
  2614. if (ch_cnt_sum) {
  2615. dai_driver->playback.channels_min = 1;
  2616. dai_driver->playback.channels_max = ch_cnt_sum << 1;
  2617. } else {
  2618. dai_driver->playback.channels_min = 0;
  2619. dai_driver->playback.channels_max = 0;
  2620. }
  2621. dev_dbg(&pdev->dev, "%s: sdline 0x%x 0x%x 0x%x 0x%x\n", __func__,
  2622. dai_data->channel_mode[0], dai_data->channel_mode[1],
  2623. dai_data->channel_mode[2], dai_data->channel_mode[3]);
  2624. dev_dbg(&pdev->dev, "%s: playback ch_max %d\n",
  2625. __func__, dai_driver->playback.channels_max);
  2626. rtn:
  2627. return rc;
  2628. }
  2629. static const struct snd_soc_component_driver msm_q6_meta_mi2s_dai_component = {
  2630. .name = "msm-dai-q6-meta-mi2s",
  2631. };
  2632. static int msm_dai_q6_meta_mi2s_dev_probe(struct platform_device *pdev)
  2633. {
  2634. struct msm_dai_q6_meta_mi2s_dai_data *dai_data;
  2635. const char *q6_meta_mi2s_dev_id = "qcom,msm-dai-q6-meta-mi2s-dev-id";
  2636. u32 dev_id = 0;
  2637. u32 meta_mi2s_intf = 0;
  2638. struct msm_meta_mi2s_pdata *meta_mi2s_pdata;
  2639. int rc;
  2640. rc = of_property_read_u32(pdev->dev.of_node, q6_meta_mi2s_dev_id,
  2641. &dev_id);
  2642. if (rc) {
  2643. dev_err(&pdev->dev,
  2644. "%s: missing %s in dt node\n", __func__,
  2645. q6_meta_mi2s_dev_id);
  2646. goto rtn;
  2647. }
  2648. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  2649. dev_id);
  2650. switch (dev_id) {
  2651. case AFE_PORT_ID_PRIMARY_META_MI2S_RX:
  2652. meta_mi2s_intf = 0;
  2653. break;
  2654. case AFE_PORT_ID_SECONDARY_META_MI2S_RX:
  2655. meta_mi2s_intf = 1;
  2656. break;
  2657. default:
  2658. dev_err(&pdev->dev,
  2659. "%s: Invalid META MI2S ID 0x%x from Device Tree\n",
  2660. __func__, dev_id);
  2661. rc = -ENXIO;
  2662. goto rtn;
  2663. }
  2664. pdev->id = dev_id;
  2665. meta_mi2s_pdata = kzalloc(sizeof(struct msm_meta_mi2s_pdata),
  2666. GFP_KERNEL);
  2667. if (!meta_mi2s_pdata) {
  2668. rc = -ENOMEM;
  2669. goto rtn;
  2670. }
  2671. rc = of_property_read_u32(pdev->dev.of_node,
  2672. "qcom,msm-mi2s-num-members",
  2673. &meta_mi2s_pdata->num_member_ports);
  2674. if (rc) {
  2675. dev_err(&pdev->dev, "%s: invalid num from DT file %s\n",
  2676. __func__, "qcom,msm-mi2s-num-members");
  2677. goto free_pdata;
  2678. }
  2679. if (meta_mi2s_pdata->num_member_ports >
  2680. MAX_NUM_I2S_META_PORT_MEMBER_PORTS) {
  2681. dev_err(&pdev->dev, "%s: num-members %d too large from DT file\n",
  2682. __func__, meta_mi2s_pdata->num_member_ports);
  2683. goto free_pdata;
  2684. }
  2685. rc = of_property_read_u32_array(pdev->dev.of_node,
  2686. "qcom,msm-mi2s-member-id",
  2687. meta_mi2s_pdata->member_port,
  2688. meta_mi2s_pdata->num_member_ports);
  2689. if (rc) {
  2690. dev_err(&pdev->dev, "%s: member-id from DT file %s\n",
  2691. __func__, "qcom,msm-mi2s-member-id");
  2692. goto free_pdata;
  2693. }
  2694. rc = of_property_read_u32_array(pdev->dev.of_node,
  2695. "qcom,msm-mi2s-rx-lines",
  2696. meta_mi2s_pdata->sd_lines,
  2697. meta_mi2s_pdata->num_member_ports);
  2698. if (rc) {
  2699. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n",
  2700. __func__, "qcom,msm-mi2s-rx-lines");
  2701. goto free_pdata;
  2702. }
  2703. dev_dbg(&pdev->dev, "dev name %s num-members=%d\n",
  2704. dev_name(&pdev->dev), meta_mi2s_pdata->num_member_ports);
  2705. dev_dbg(&pdev->dev, "member array (%d, %d, %d, %d)\n",
  2706. meta_mi2s_pdata->member_port[0],
  2707. meta_mi2s_pdata->member_port[1],
  2708. meta_mi2s_pdata->member_port[2],
  2709. meta_mi2s_pdata->member_port[3]);
  2710. dev_dbg(&pdev->dev, "sd-lines array (0x%x, 0x%x, 0x%x, 0x%x)\n",
  2711. meta_mi2s_pdata->sd_lines[0],
  2712. meta_mi2s_pdata->sd_lines[1],
  2713. meta_mi2s_pdata->sd_lines[2],
  2714. meta_mi2s_pdata->sd_lines[3]);
  2715. meta_mi2s_pdata->intf_id = meta_mi2s_intf;
  2716. dai_data = kzalloc(sizeof(struct msm_dai_q6_meta_mi2s_dai_data),
  2717. GFP_KERNEL);
  2718. if (!dai_data) {
  2719. rc = -ENOMEM;
  2720. goto free_pdata;
  2721. } else
  2722. dev_set_drvdata(&pdev->dev, dai_data);
  2723. pdev->dev.platform_data = meta_mi2s_pdata;
  2724. rc = msm_dai_q6_meta_mi2s_platform_data_validation(pdev,
  2725. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf]);
  2726. if (rc < 0)
  2727. goto free_dai_data;
  2728. rc = snd_soc_register_component(&pdev->dev,
  2729. &msm_q6_meta_mi2s_dai_component,
  2730. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf], 1);
  2731. if (rc < 0)
  2732. goto err_register;
  2733. return 0;
  2734. err_register:
  2735. dev_err(&pdev->dev, "fail to %s\n", __func__);
  2736. free_dai_data:
  2737. kfree(dai_data);
  2738. free_pdata:
  2739. kfree(meta_mi2s_pdata);
  2740. rtn:
  2741. return rc;
  2742. }
  2743. static int msm_dai_q6_meta_mi2s_dev_remove(struct platform_device *pdev)
  2744. {
  2745. snd_soc_unregister_component(&pdev->dev);
  2746. return 0;
  2747. }
  2748. #endif
  2749. static const struct snd_soc_component_driver msm_dai_q6_component = {
  2750. .name = "msm-dai-q6-dev",
  2751. };
  2752. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  2753. {
  2754. int rc, id, i, len;
  2755. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  2756. char stream_name[80];
  2757. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  2758. if (rc) {
  2759. dev_err(&pdev->dev,
  2760. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  2761. return rc;
  2762. }
  2763. pdev->id = id;
  2764. pr_debug("%s: dev name %s, id:%d\n", __func__,
  2765. dev_name(&pdev->dev), pdev->id);
  2766. switch (id) {
  2767. case SLIMBUS_0_RX:
  2768. strlcpy(stream_name, "Slimbus Playback", 80);
  2769. goto register_slim_playback;
  2770. case SLIMBUS_6_RX:
  2771. strlcpy(stream_name, "Slimbus6 Playback", 80);
  2772. goto register_slim_playback;
  2773. register_slim_playback:
  2774. rc = -ENODEV;
  2775. len = strnlen(stream_name, 80);
  2776. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  2777. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  2778. !strcmp(stream_name,
  2779. msm_dai_q6_slimbus_rx_dai[i]
  2780. .playback.stream_name)) {
  2781. rc = snd_soc_register_component(&pdev->dev,
  2782. &msm_dai_q6_component,
  2783. &msm_dai_q6_slimbus_rx_dai[i], 1);
  2784. break;
  2785. }
  2786. }
  2787. if (rc)
  2788. pr_err("%s: Device not found stream name %s\n",
  2789. __func__, stream_name);
  2790. break;
  2791. case SLIMBUS_0_TX:
  2792. strlcpy(stream_name, "Slimbus Capture", 80);
  2793. goto register_slim_capture;
  2794. register_slim_capture:
  2795. rc = -ENODEV;
  2796. len = strnlen(stream_name, 80);
  2797. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  2798. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  2799. !strcmp(stream_name,
  2800. msm_dai_q6_slimbus_tx_dai[i]
  2801. .capture.stream_name)) {
  2802. rc = snd_soc_register_component(&pdev->dev,
  2803. &msm_dai_q6_component,
  2804. &msm_dai_q6_slimbus_tx_dai[i], 1);
  2805. break;
  2806. }
  2807. }
  2808. if (rc)
  2809. pr_err("%s: Device not found stream name %s\n",
  2810. __func__, stream_name);
  2811. break;
  2812. default:
  2813. rc = -ENODEV;
  2814. break;
  2815. }
  2816. return rc;
  2817. }
  2818. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  2819. {
  2820. snd_soc_unregister_component(&pdev->dev);
  2821. return 0;
  2822. }
  2823. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  2824. { .compatible = "qcom,msm-dai-q6-dev", },
  2825. { }
  2826. };
  2827. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  2828. static struct platform_driver msm_dai_q6_dev = {
  2829. .probe = msm_dai_q6_dev_probe,
  2830. .remove = msm_dai_q6_dev_remove,
  2831. .driver = {
  2832. .name = "msm-dai-q6-dev",
  2833. .owner = THIS_MODULE,
  2834. .of_match_table = msm_dai_q6_dev_dt_match,
  2835. .suppress_bind_attrs = true,
  2836. },
  2837. };
  2838. static int msm_dai_q6_probe(struct platform_device *pdev)
  2839. {
  2840. int rc;
  2841. pr_debug("%s: dev name %s, id:%d\n", __func__,
  2842. dev_name(&pdev->dev), pdev->id);
  2843. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  2844. if (rc) {
  2845. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  2846. __func__, rc);
  2847. } else
  2848. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  2849. return rc;
  2850. }
  2851. static int msm_dai_q6_remove(struct platform_device *pdev)
  2852. {
  2853. of_platform_depopulate(&pdev->dev);
  2854. return 0;
  2855. }
  2856. static const struct of_device_id msm_dai_q6_dt_match[] = {
  2857. { .compatible = "qcom,msm-dai-q6", },
  2858. { }
  2859. };
  2860. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  2861. static struct platform_driver msm_dai_q6 = {
  2862. .probe = msm_dai_q6_probe,
  2863. .remove = msm_dai_q6_remove,
  2864. .driver = {
  2865. .name = "msm-dai-q6",
  2866. .owner = THIS_MODULE,
  2867. .of_match_table = msm_dai_q6_dt_match,
  2868. .suppress_bind_attrs = true,
  2869. },
  2870. };
  2871. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  2872. {
  2873. int rc;
  2874. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  2875. if (rc) {
  2876. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  2877. __func__, rc);
  2878. } else
  2879. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  2880. return rc;
  2881. }
  2882. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  2883. {
  2884. return 0;
  2885. }
  2886. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  2887. { .compatible = "qcom,msm-dai-mi2s", },
  2888. { }
  2889. };
  2890. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  2891. static struct platform_driver msm_dai_mi2s_q6 = {
  2892. .probe = msm_dai_mi2s_q6_probe,
  2893. .remove = msm_dai_mi2s_q6_remove,
  2894. .driver = {
  2895. .name = "msm-dai-mi2s",
  2896. .owner = THIS_MODULE,
  2897. .of_match_table = msm_dai_mi2s_dt_match,
  2898. .suppress_bind_attrs = true,
  2899. },
  2900. };
  2901. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  2902. { .compatible = "qcom,msm-dai-q6-mi2s", },
  2903. { }
  2904. };
  2905. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  2906. static struct platform_driver msm_dai_q6_mi2s_driver = {
  2907. .probe = msm_dai_q6_mi2s_dev_probe,
  2908. .remove = msm_dai_q6_mi2s_dev_remove,
  2909. .driver = {
  2910. .name = "msm-dai-q6-mi2s",
  2911. .owner = THIS_MODULE,
  2912. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  2913. .suppress_bind_attrs = true,
  2914. },
  2915. };
  2916. #if 0
  2917. static const struct of_device_id msm_dai_q6_meta_mi2s_dev_dt_match[] = {
  2918. { .compatible = "qcom,msm-dai-q6-meta-mi2s", },
  2919. { }
  2920. };
  2921. MODULE_DEVICE_TABLE(of, msm_dai_q6_meta_mi2s_dev_dt_match);
  2922. static struct platform_driver msm_dai_q6_meta_mi2s_driver = {
  2923. .probe = msm_dai_q6_meta_mi2s_dev_probe,
  2924. .remove = msm_dai_q6_meta_mi2s_dev_remove,
  2925. .driver = {
  2926. .name = "msm-dai-q6-meta-mi2s",
  2927. .owner = THIS_MODULE,
  2928. .of_match_table = msm_dai_q6_meta_mi2s_dev_dt_match,
  2929. .suppress_bind_attrs = true,
  2930. },
  2931. };
  2932. #endif
  2933. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  2934. struct clk_cfg *clk_set, u32 mode)
  2935. {
  2936. switch (group_id) {
  2937. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  2938. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  2939. if (mode)
  2940. clk_set->clk_id = CLOCK_ID_PRI_TDM_IBIT;
  2941. else
  2942. clk_set->clk_id = CLOCK_ID_PRI_TDM_EBIT;
  2943. break;
  2944. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  2945. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  2946. if (mode)
  2947. clk_set->clk_id = CLOCK_ID_SEC_TDM_IBIT;
  2948. else
  2949. clk_set->clk_id = CLOCK_ID_SEC_TDM_EBIT;
  2950. break;
  2951. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  2952. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  2953. if (mode)
  2954. clk_set->clk_id = CLOCK_ID_TER_TDM_IBIT;
  2955. else
  2956. clk_set->clk_id = CLOCK_ID_TER_TDM_EBIT;
  2957. break;
  2958. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  2959. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  2960. if (mode)
  2961. clk_set->clk_id = CLOCK_ID_QUAD_TDM_IBIT;
  2962. else
  2963. clk_set->clk_id = CLOCK_ID_QUAD_TDM_EBIT;
  2964. break;
  2965. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  2966. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  2967. if (mode)
  2968. clk_set->clk_id = CLOCK_ID_QUI_TDM_IBIT;
  2969. else
  2970. clk_set->clk_id = CLOCK_ID_QUI_TDM_EBIT;
  2971. break;
  2972. default:
  2973. return -EINVAL;
  2974. }
  2975. return 0;
  2976. }
  2977. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  2978. {
  2979. int rc = 0;
  2980. const uint32_t *port_id_array = NULL;
  2981. uint32_t array_length = 0;
  2982. int i = 0;
  2983. int group_idx = 0;
  2984. u32 clk_mode = 0;
  2985. /* extract tdm group info into static */
  2986. rc = of_property_read_u32(pdev->dev.of_node,
  2987. "qcom,msm-cpudai-tdm-group-id",
  2988. (u32 *)&tdm_group_cfg.group_id);
  2989. if (rc) {
  2990. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  2991. __func__, "qcom,msm-cpudai-tdm-group-id");
  2992. goto rtn;
  2993. }
  2994. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  2995. __func__, tdm_group_cfg.group_id);
  2996. rc = of_property_read_u32(pdev->dev.of_node,
  2997. "qcom,msm-cpudai-tdm-group-num-ports",
  2998. &num_tdm_group_ports);
  2999. if (rc) {
  3000. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  3001. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  3002. goto rtn;
  3003. }
  3004. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  3005. __func__, num_tdm_group_ports);
  3006. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  3007. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  3008. __func__, num_tdm_group_ports,
  3009. AFE_GROUP_DEVICE_NUM_PORTS);
  3010. rc = -EINVAL;
  3011. goto rtn;
  3012. }
  3013. port_id_array = of_get_property(pdev->dev.of_node,
  3014. "qcom,msm-cpudai-tdm-group-port-id",
  3015. &array_length);
  3016. if (port_id_array == NULL) {
  3017. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  3018. __func__);
  3019. rc = -EINVAL;
  3020. goto rtn;
  3021. }
  3022. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  3023. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  3024. __func__, array_length,
  3025. sizeof(uint32_t) * num_tdm_group_ports);
  3026. rc = -EINVAL;
  3027. goto rtn;
  3028. }
  3029. for (i = 0; i < num_tdm_group_ports; i++)
  3030. tdm_group_cfg.port_id[i] =
  3031. (u16)be32_to_cpu(port_id_array[i]);
  3032. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  3033. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  3034. tdm_group_cfg.port_id[i] =
  3035. AFE_PORT_INVALID;
  3036. /* extract tdm clk info into static */
  3037. rc = of_property_read_u32(pdev->dev.of_node,
  3038. "qcom,msm-cpudai-tdm-clk-rate",
  3039. &tdm_clk_set.clk_freq_in_hz);
  3040. if (rc) {
  3041. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  3042. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  3043. goto rtn;
  3044. }
  3045. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  3046. __func__, tdm_clk_set.clk_freq_in_hz);
  3047. tdm_clk_set.clk_freq_in_hz = 48000*8*32;
  3048. /* initialize static tdm clk attribute to default value */
  3049. tdm_clk_set.clk_attri = CLOCK_ATTRIBUTE_COUPLE_NO;
  3050. /* extract tdm clk attribute into static */
  3051. if (of_find_property(pdev->dev.of_node,
  3052. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  3053. rc = of_property_read_u32(pdev->dev.of_node,
  3054. "qcom,msm-cpudai-tdm-clk-attribute",
  3055. &tdm_clk_set.clk_attri);
  3056. if (rc) {
  3057. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  3058. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  3059. goto rtn;
  3060. }
  3061. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  3062. __func__, tdm_clk_set.clk_attri);
  3063. } else
  3064. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  3065. /* extract tdm lane cfg to static */
  3066. tdm_lane_cfg.port_id = tdm_group_cfg.group_id;
  3067. tdm_lane_cfg.lane_mask = AFE_LANE_MASK_INVALID;
  3068. if (of_find_property(pdev->dev.of_node,
  3069. "qcom,msm-cpudai-tdm-lane-mask", NULL)) {
  3070. rc = of_property_read_u16(pdev->dev.of_node,
  3071. "qcom,msm-cpudai-tdm-lane-mask",
  3072. &tdm_lane_cfg.lane_mask);
  3073. if (rc) {
  3074. dev_err(&pdev->dev, "%s: value for tdm lane mask not found %s\n",
  3075. __func__, "qcom,msm-cpudai-tdm-lane-mask");
  3076. goto rtn;
  3077. }
  3078. dev_dbg(&pdev->dev, "%s: tdm lane mask from DT file %d\n",
  3079. __func__, tdm_lane_cfg.lane_mask);
  3080. } else
  3081. dev_dbg(&pdev->dev, "%s: tdm lane mask not found\n", __func__);
  3082. /* extract tdm clk src master/slave info into static */
  3083. rc = of_property_read_u32(pdev->dev.of_node,
  3084. "qcom,msm-cpudai-tdm-clk-internal",
  3085. &clk_mode);
  3086. if (rc) {
  3087. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  3088. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  3089. goto rtn;
  3090. }
  3091. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  3092. __func__, clk_mode);
  3093. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  3094. &tdm_clk_set, clk_mode);
  3095. if (rc) {
  3096. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  3097. __func__, tdm_group_cfg.group_id);
  3098. goto rtn;
  3099. }
  3100. /* other initializations within device group */
  3101. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  3102. if (group_idx < 0) {
  3103. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  3104. __func__, tdm_group_cfg.group_id);
  3105. rc = -EINVAL;
  3106. goto rtn;
  3107. }
  3108. atomic_set(&tdm_group_ref[group_idx], 0);
  3109. /* probe child node info */
  3110. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  3111. if (rc) {
  3112. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  3113. __func__, rc);
  3114. goto rtn;
  3115. } else
  3116. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  3117. rtn:
  3118. return rc;
  3119. }
  3120. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  3121. {
  3122. return 0;
  3123. }
  3124. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  3125. { .compatible = "qcom,msm-dai-tdm", },
  3126. {}
  3127. };
  3128. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  3129. static struct platform_driver msm_dai_tdm_q6 = {
  3130. .probe = msm_dai_tdm_q6_probe,
  3131. .remove = msm_dai_tdm_q6_remove,
  3132. .driver = {
  3133. .name = "msm-dai-tdm",
  3134. .owner = THIS_MODULE,
  3135. .of_match_table = msm_dai_tdm_dt_match,
  3136. .suppress_bind_attrs = true,
  3137. },
  3138. };
  3139. static int msm_dai_q6_tdm_set_clk(
  3140. struct msm_dai_q6_tdm_dai_data *dai_data,
  3141. u16 port_id, bool enable)
  3142. {
  3143. int rc = 0;
  3144. rc = audio_prm_set_lpass_clk_cfg(&dai_data->clk_set, enable);
  3145. if (rc < 0)
  3146. pr_err("%s: afe lpass clock failed, err:%d port_id:%d freq:%d clk_id:%d\n",
  3147. __func__, rc, port_id, dai_data->clk_set.clk_freq_in_hz, dai_data->clk_set.clk_id);
  3148. return rc;
  3149. }
  3150. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  3151. int clk_id, unsigned int freq, int dir)
  3152. {
  3153. struct msm_dai_q6_tdm_dai_data *dai_data =
  3154. dev_get_drvdata(dai->dev);
  3155. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  3156. (dai->id <= AFE_PORT_ID_SENARY_TDM_TX_7)) {
  3157. dai_data->clk_set.clk_freq_in_hz = freq;
  3158. } else {
  3159. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  3160. __func__, dai->id);
  3161. return -EINVAL;
  3162. }
  3163. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  3164. __func__, dai->id, freq);
  3165. return 0;
  3166. }
  3167. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  3168. struct snd_pcm_hw_params *params,
  3169. struct snd_soc_dai *dai)
  3170. {
  3171. struct msm_dai_q6_tdm_dai_data *dai_data =
  3172. dev_get_drvdata(dai->dev);
  3173. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  3174. &dai_data->group_cfg.tdm_cfg;
  3175. struct afe_param_id_tdm_cfg *tdm =
  3176. &dai_data->port_cfg.tdm;
  3177. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  3178. &dai_data->port_cfg.slot_mapping;
  3179. // struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  3180. // &dai_data->port_cfg.slot_mapping_v2;
  3181. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  3182. &dai_data->port_cfg.custom_tdm_header;
  3183. pr_debug("%s: dev_name: %s\n",
  3184. __func__, dev_name(dai->dev));
  3185. if ((params_channels(params) == 0) ||
  3186. (params_channels(params) > 32)) {
  3187. dev_err(dai->dev, "%s: invalid param channels %d\n",
  3188. __func__, params_channels(params));
  3189. return -EINVAL;
  3190. }
  3191. switch (params_format(params)) {
  3192. case SNDRV_PCM_FORMAT_S16_LE:
  3193. dai_data->bitwidth = 16;
  3194. break;
  3195. case SNDRV_PCM_FORMAT_S24_LE:
  3196. case SNDRV_PCM_FORMAT_S24_3LE:
  3197. dai_data->bitwidth = 24;
  3198. break;
  3199. case SNDRV_PCM_FORMAT_S32_LE:
  3200. dai_data->bitwidth = 32;
  3201. break;
  3202. default:
  3203. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  3204. __func__, params_format(params));
  3205. return -EINVAL;
  3206. }
  3207. dai_data->channels = params_channels(params);
  3208. dai_data->rate = params_rate(params);
  3209. dai_data->bitwidth = 16;
  3210. /*
  3211. * update tdm group config param
  3212. * NOTE: group config is set to the same as slot config.
  3213. */
  3214. tdm_group->bit_width = tdm_group->slot_width;
  3215. /*
  3216. * for multi lane scenario
  3217. * Total number of active channels = number of active lanes * number of active slots.
  3218. */
  3219. if (dai_data->lane_cfg.lane_mask != AFE_LANE_MASK_INVALID)
  3220. tdm_group->num_channels = tdm_group->nslots_per_frame
  3221. * num_of_bits_set(dai_data->lane_cfg.lane_mask);
  3222. else
  3223. tdm_group->num_channels = tdm_group->nslots_per_frame;
  3224. tdm_group->sample_rate = dai_data->rate;
  3225. pr_debug("%s: TDM GROUP:\n"
  3226. "num_channels=%d sample_rate=%d bit_width=%d\n"
  3227. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  3228. __func__,
  3229. tdm_group->num_channels,
  3230. tdm_group->sample_rate,
  3231. tdm_group->bit_width,
  3232. tdm_group->nslots_per_frame,
  3233. tdm_group->slot_width,
  3234. tdm_group->slot_mask);
  3235. pr_debug("%s: TDM GROUP:\n"
  3236. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  3237. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  3238. __func__,
  3239. tdm_group->port_id[0],
  3240. tdm_group->port_id[1],
  3241. tdm_group->port_id[2],
  3242. tdm_group->port_id[3],
  3243. tdm_group->port_id[4],
  3244. tdm_group->port_id[5],
  3245. tdm_group->port_id[6],
  3246. tdm_group->port_id[7]);
  3247. pr_debug("%s: TDM GROUP ID 0x%x lane mask 0x%x:\n",
  3248. __func__,
  3249. tdm_group->group_id,
  3250. dai_data->lane_cfg.lane_mask);
  3251. /*
  3252. * update tdm config param
  3253. * NOTE: channels/rate/bitwidth are per stream property
  3254. */
  3255. tdm->num_channels = dai_data->channels;
  3256. tdm->sample_rate = dai_data->rate;
  3257. tdm->bit_width = dai_data->bitwidth;
  3258. /*
  3259. * port slot config is the same as group slot config
  3260. * port slot mask should be set according to offset
  3261. */
  3262. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  3263. tdm->slot_width = tdm_group->slot_width;
  3264. #if 0
  3265. if (q6core_get_avcs_api_version_per_service(
  3266. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3)
  3267. tdm->slot_mask = tdm_param_set_slot_mask(
  3268. slot_mapping_v2->offset,
  3269. tdm_group->slot_width,
  3270. tdm_group->nslots_per_frame);
  3271. else
  3272. #endif
  3273. tdm->slot_mask = tdm_group->slot_mask;
  3274. pr_debug("%s: TDM:\n"
  3275. "num_channels=%d sample_rate=%d bit_width=%d\n"
  3276. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  3277. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  3278. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  3279. __func__,
  3280. tdm->num_channels,
  3281. tdm->sample_rate,
  3282. tdm->bit_width,
  3283. tdm->nslots_per_frame,
  3284. tdm->slot_width,
  3285. tdm->slot_mask,
  3286. tdm->data_format,
  3287. tdm->sync_mode,
  3288. tdm->sync_src,
  3289. tdm->ctrl_data_out_enable,
  3290. tdm->ctrl_invert_sync_pulse,
  3291. tdm->ctrl_sync_data_delay);
  3292. #if 0
  3293. if (q6core_get_avcs_api_version_per_service(
  3294. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  3295. /*
  3296. * update slot mapping v2 config param
  3297. * NOTE: channels/rate/bitwidth are per stream property
  3298. */
  3299. slot_mapping_v2->bitwidth = dai_data->bitwidth;
  3300. pr_debug("%s: SLOT MAPPING_V2:\n"
  3301. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  3302. __func__,
  3303. slot_mapping_v2->num_channel,
  3304. slot_mapping_v2->bitwidth,
  3305. slot_mapping_v2->data_align_type);
  3306. pr_debug("%s: SLOT MAPPING V2:\n"
  3307. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  3308. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n"
  3309. "offset[8]=0x%x offset[9]=0x%x offset[10]=0x%x offset[11]=0x%x\n"
  3310. "offset[12]=0x%x offset[13]=0x%x offset[14]=0x%x offset[15]=0x%x\n"
  3311. "offset[16]=0x%x offset[17]=0x%x offset[18]=0x%x offset[19]=0x%x\n"
  3312. "offset[20]=0x%x offset[21]=0x%x offset[22]=0x%x offset[23]=0x%x\n"
  3313. "offset[24]=0x%x offset[25]=0x%x offset[26]=0x%x offset[27]=0x%x\n"
  3314. "offset[28]=0x%x offset[29]=0x%x offset[30]=0x%x offset[31]=0x%x\n",
  3315. __func__,
  3316. slot_mapping_v2->offset[0],
  3317. slot_mapping_v2->offset[1],
  3318. slot_mapping_v2->offset[2],
  3319. slot_mapping_v2->offset[3],
  3320. slot_mapping_v2->offset[4],
  3321. slot_mapping_v2->offset[5],
  3322. slot_mapping_v2->offset[6],
  3323. slot_mapping_v2->offset[7],
  3324. slot_mapping_v2->offset[8],
  3325. slot_mapping_v2->offset[9],
  3326. slot_mapping_v2->offset[10],
  3327. slot_mapping_v2->offset[11],
  3328. slot_mapping_v2->offset[12],
  3329. slot_mapping_v2->offset[13],
  3330. slot_mapping_v2->offset[14],
  3331. slot_mapping_v2->offset[15],
  3332. slot_mapping_v2->offset[16],
  3333. slot_mapping_v2->offset[17],
  3334. slot_mapping_v2->offset[18],
  3335. slot_mapping_v2->offset[19],
  3336. slot_mapping_v2->offset[20],
  3337. slot_mapping_v2->offset[21],
  3338. slot_mapping_v2->offset[22],
  3339. slot_mapping_v2->offset[23],
  3340. slot_mapping_v2->offset[24],
  3341. slot_mapping_v2->offset[25],
  3342. slot_mapping_v2->offset[26],
  3343. slot_mapping_v2->offset[27],
  3344. slot_mapping_v2->offset[28],
  3345. slot_mapping_v2->offset[29],
  3346. slot_mapping_v2->offset[30],
  3347. slot_mapping_v2->offset[31]);
  3348. } else {
  3349. #endif
  3350. /*
  3351. * update slot mapping config param
  3352. * NOTE: channels/rate/bitwidth are per stream property
  3353. */
  3354. slot_mapping->bitwidth = dai_data->bitwidth;
  3355. pr_debug("%s: SLOT MAPPING:\n"
  3356. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  3357. __func__,
  3358. slot_mapping->num_channel,
  3359. slot_mapping->bitwidth,
  3360. slot_mapping->data_align_type);
  3361. pr_debug("%s: SLOT MAPPING:\n"
  3362. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  3363. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  3364. __func__,
  3365. slot_mapping->offset[0],
  3366. slot_mapping->offset[1],
  3367. slot_mapping->offset[2],
  3368. slot_mapping->offset[3],
  3369. slot_mapping->offset[4],
  3370. slot_mapping->offset[5],
  3371. slot_mapping->offset[6],
  3372. slot_mapping->offset[7]);
  3373. // }
  3374. /*
  3375. * update custom header config param
  3376. * NOTE: channels/rate/bitwidth are per playback stream property.
  3377. * custom tdm header only applicable to playback stream.
  3378. */
  3379. if (custom_tdm_header->header_type !=
  3380. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  3381. pr_debug("%s: CUSTOM TDM HEADER:\n"
  3382. "start_offset=0x%x header_width=%d\n"
  3383. "num_frame_repeat=%d header_type=0x%x\n",
  3384. __func__,
  3385. custom_tdm_header->start_offset,
  3386. custom_tdm_header->header_width,
  3387. custom_tdm_header->num_frame_repeat,
  3388. custom_tdm_header->header_type);
  3389. pr_debug("%s: CUSTOM TDM HEADER:\n"
  3390. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  3391. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  3392. __func__,
  3393. custom_tdm_header->header[0],
  3394. custom_tdm_header->header[1],
  3395. custom_tdm_header->header[2],
  3396. custom_tdm_header->header[3],
  3397. custom_tdm_header->header[4],
  3398. custom_tdm_header->header[5],
  3399. custom_tdm_header->header[6],
  3400. custom_tdm_header->header[7]);
  3401. }
  3402. return 0;
  3403. }
  3404. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  3405. struct snd_soc_dai *dai)
  3406. {
  3407. int rc = 0;
  3408. struct msm_dai_q6_tdm_dai_data *dai_data =
  3409. dev_get_drvdata(dai->dev);
  3410. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  3411. int group_idx = 0;
  3412. atomic_t *group_ref = NULL;
  3413. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  3414. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  3415. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  3416. dev_dbg(dai->dev,
  3417. "%s: Custom tdm header not supported\n", __func__);
  3418. group_idx = msm_dai_q6_get_group_idx(dai->id);
  3419. if (group_idx < 0) {
  3420. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  3421. __func__, dai->id);
  3422. return -EINVAL;
  3423. }
  3424. mutex_lock(&tdm_mutex);
  3425. group_ref = &tdm_group_ref[group_idx];
  3426. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3427. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  3428. /* TX and RX share the same clk. So enable the clk
  3429. * per TDM interface. */
  3430. rc = msm_dai_q6_tdm_set_clk(dai_data,
  3431. dai->id, true);
  3432. if (rc < 0) {
  3433. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  3434. __func__, dai->id);
  3435. goto rtn;
  3436. }
  3437. }
  3438. set_bit(STATUS_PORT_STARTED,
  3439. dai_data->status_mask);
  3440. atomic_inc(group_ref);
  3441. }
  3442. rtn:
  3443. mutex_unlock(&tdm_mutex);
  3444. return rc;
  3445. }
  3446. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  3447. struct snd_soc_dai *dai)
  3448. {
  3449. int rc = 0;
  3450. struct msm_dai_q6_tdm_dai_data *dai_data =
  3451. dev_get_drvdata(dai->dev);
  3452. int group_idx = 0;
  3453. atomic_t *group_ref = NULL;
  3454. group_idx = msm_dai_q6_get_group_idx(dai->id);
  3455. if (group_idx < 0) {
  3456. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  3457. __func__, dai->id);
  3458. return;
  3459. }
  3460. mutex_lock(&tdm_mutex);
  3461. group_ref = &tdm_group_ref[group_idx];
  3462. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3463. atomic_dec(group_ref);
  3464. clear_bit(STATUS_PORT_STARTED,
  3465. dai_data->status_mask);
  3466. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  3467. rc = msm_dai_q6_tdm_set_clk(dai_data,
  3468. dai->id, false);
  3469. if (rc < 0) {
  3470. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  3471. __func__, dai->id);
  3472. }
  3473. }
  3474. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  3475. /* NOTE: AFE should error out if HW resource contention */
  3476. }
  3477. mutex_unlock(&tdm_mutex);
  3478. }
  3479. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  3480. .prepare = msm_dai_q6_tdm_prepare,
  3481. .hw_params = msm_dai_q6_tdm_hw_params,
  3482. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  3483. .shutdown = msm_dai_q6_tdm_shutdown,
  3484. };
  3485. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  3486. {
  3487. .playback = {
  3488. .stream_name = "Primary TDM0 Playback",
  3489. .aif_name = "PRI_TDM_RX_0",
  3490. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3491. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3492. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3493. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3494. SNDRV_PCM_FMTBIT_S24_LE |
  3495. SNDRV_PCM_FMTBIT_S32_LE,
  3496. .channels_min = 1,
  3497. .channels_max = 16,
  3498. .rate_min = 8000,
  3499. .rate_max = 352800,
  3500. },
  3501. .name = "PRI_TDM_RX_0",
  3502. .ops = &msm_dai_q6_tdm_ops,
  3503. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  3504. },
  3505. {
  3506. .playback = {
  3507. .stream_name = "Primary TDM1 Playback",
  3508. .aif_name = "PRI_TDM_RX_1",
  3509. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3510. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3511. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3512. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3513. SNDRV_PCM_FMTBIT_S24_LE |
  3514. SNDRV_PCM_FMTBIT_S32_LE,
  3515. .channels_min = 1,
  3516. .channels_max = 16,
  3517. .rate_min = 8000,
  3518. .rate_max = 352800,
  3519. },
  3520. .name = "PRI_TDM_RX_1",
  3521. .ops = &msm_dai_q6_tdm_ops,
  3522. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  3523. },
  3524. {
  3525. .playback = {
  3526. .stream_name = "Primary TDM2 Playback",
  3527. .aif_name = "PRI_TDM_RX_2",
  3528. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3529. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3530. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3531. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3532. SNDRV_PCM_FMTBIT_S24_LE |
  3533. SNDRV_PCM_FMTBIT_S32_LE,
  3534. .channels_min = 1,
  3535. .channels_max = 16,
  3536. .rate_min = 8000,
  3537. .rate_max = 352800,
  3538. },
  3539. .name = "PRI_TDM_RX_2",
  3540. .ops = &msm_dai_q6_tdm_ops,
  3541. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  3542. },
  3543. {
  3544. .playback = {
  3545. .stream_name = "Primary TDM3 Playback",
  3546. .aif_name = "PRI_TDM_RX_3",
  3547. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3548. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3549. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3550. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3551. SNDRV_PCM_FMTBIT_S24_LE |
  3552. SNDRV_PCM_FMTBIT_S32_LE,
  3553. .channels_min = 1,
  3554. .channels_max = 16,
  3555. .rate_min = 8000,
  3556. .rate_max = 352800,
  3557. },
  3558. .name = "PRI_TDM_RX_3",
  3559. .ops = &msm_dai_q6_tdm_ops,
  3560. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  3561. },
  3562. {
  3563. .playback = {
  3564. .stream_name = "Primary TDM4 Playback",
  3565. .aif_name = "PRI_TDM_RX_4",
  3566. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3567. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3568. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3569. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3570. SNDRV_PCM_FMTBIT_S24_LE |
  3571. SNDRV_PCM_FMTBIT_S32_LE,
  3572. .channels_min = 1,
  3573. .channels_max = 16,
  3574. .rate_min = 8000,
  3575. .rate_max = 352800,
  3576. },
  3577. .name = "PRI_TDM_RX_4",
  3578. .ops = &msm_dai_q6_tdm_ops,
  3579. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  3580. },
  3581. {
  3582. .playback = {
  3583. .stream_name = "Primary TDM5 Playback",
  3584. .aif_name = "PRI_TDM_RX_5",
  3585. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3586. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3587. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3588. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3589. SNDRV_PCM_FMTBIT_S24_LE |
  3590. SNDRV_PCM_FMTBIT_S32_LE,
  3591. .channels_min = 1,
  3592. .channels_max = 16,
  3593. .rate_min = 8000,
  3594. .rate_max = 352800,
  3595. },
  3596. .name = "PRI_TDM_RX_5",
  3597. .ops = &msm_dai_q6_tdm_ops,
  3598. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  3599. },
  3600. {
  3601. .playback = {
  3602. .stream_name = "Primary TDM6 Playback",
  3603. .aif_name = "PRI_TDM_RX_6",
  3604. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3605. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3606. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3607. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3608. SNDRV_PCM_FMTBIT_S24_LE |
  3609. SNDRV_PCM_FMTBIT_S32_LE,
  3610. .channels_min = 1,
  3611. .channels_max = 16,
  3612. .rate_min = 8000,
  3613. .rate_max = 352800,
  3614. },
  3615. .name = "PRI_TDM_RX_6",
  3616. .ops = &msm_dai_q6_tdm_ops,
  3617. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  3618. },
  3619. {
  3620. .playback = {
  3621. .stream_name = "Primary TDM7 Playback",
  3622. .aif_name = "PRI_TDM_RX_7",
  3623. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3624. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3625. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3626. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3627. SNDRV_PCM_FMTBIT_S24_LE |
  3628. SNDRV_PCM_FMTBIT_S32_LE,
  3629. .channels_min = 1,
  3630. .channels_max = 16,
  3631. .rate_min = 8000,
  3632. .rate_max = 352800,
  3633. },
  3634. .name = "PRI_TDM_RX_7",
  3635. .ops = &msm_dai_q6_tdm_ops,
  3636. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  3637. },
  3638. {
  3639. .capture = {
  3640. .stream_name = "Primary TDM0 Capture",
  3641. .aif_name = "PRI_TDM_TX_0",
  3642. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3643. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3644. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3645. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3646. SNDRV_PCM_FMTBIT_S24_LE |
  3647. SNDRV_PCM_FMTBIT_S32_LE,
  3648. .channels_min = 1,
  3649. .channels_max = 16,
  3650. .rate_min = 8000,
  3651. .rate_max = 352800,
  3652. },
  3653. .name = "PRI_TDM_TX_0",
  3654. .ops = &msm_dai_q6_tdm_ops,
  3655. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  3656. },
  3657. {
  3658. .capture = {
  3659. .stream_name = "Primary TDM1 Capture",
  3660. .aif_name = "PRI_TDM_TX_1",
  3661. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3662. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3663. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3664. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3665. SNDRV_PCM_FMTBIT_S24_LE |
  3666. SNDRV_PCM_FMTBIT_S32_LE,
  3667. .channels_min = 1,
  3668. .channels_max = 16,
  3669. .rate_min = 8000,
  3670. .rate_max = 352800,
  3671. },
  3672. .name = "PRI_TDM_TX_1",
  3673. .ops = &msm_dai_q6_tdm_ops,
  3674. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  3675. },
  3676. {
  3677. .capture = {
  3678. .stream_name = "Primary TDM2 Capture",
  3679. .aif_name = "PRI_TDM_TX_2",
  3680. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3681. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3682. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3683. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3684. SNDRV_PCM_FMTBIT_S24_LE |
  3685. SNDRV_PCM_FMTBIT_S32_LE,
  3686. .channels_min = 1,
  3687. .channels_max = 16,
  3688. .rate_min = 8000,
  3689. .rate_max = 352800,
  3690. },
  3691. .name = "PRI_TDM_TX_2",
  3692. .ops = &msm_dai_q6_tdm_ops,
  3693. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  3694. },
  3695. {
  3696. .capture = {
  3697. .stream_name = "Primary TDM3 Capture",
  3698. .aif_name = "PRI_TDM_TX_3",
  3699. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3700. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3701. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3702. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3703. SNDRV_PCM_FMTBIT_S24_LE |
  3704. SNDRV_PCM_FMTBIT_S32_LE,
  3705. .channels_min = 1,
  3706. .channels_max = 16,
  3707. .rate_min = 8000,
  3708. .rate_max = 352800,
  3709. },
  3710. .name = "PRI_TDM_TX_3",
  3711. .ops = &msm_dai_q6_tdm_ops,
  3712. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  3713. },
  3714. {
  3715. .capture = {
  3716. .stream_name = "Primary TDM4 Capture",
  3717. .aif_name = "PRI_TDM_TX_4",
  3718. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3719. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3720. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3721. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3722. SNDRV_PCM_FMTBIT_S24_LE |
  3723. SNDRV_PCM_FMTBIT_S32_LE,
  3724. .channels_min = 1,
  3725. .channels_max = 16,
  3726. .rate_min = 8000,
  3727. .rate_max = 352800,
  3728. },
  3729. .name = "PRI_TDM_TX_4",
  3730. .ops = &msm_dai_q6_tdm_ops,
  3731. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  3732. },
  3733. {
  3734. .capture = {
  3735. .stream_name = "Primary TDM5 Capture",
  3736. .aif_name = "PRI_TDM_TX_5",
  3737. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3738. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3739. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3740. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3741. SNDRV_PCM_FMTBIT_S24_LE |
  3742. SNDRV_PCM_FMTBIT_S32_LE,
  3743. .channels_min = 1,
  3744. .channels_max = 16,
  3745. .rate_min = 8000,
  3746. .rate_max = 352800,
  3747. },
  3748. .name = "PRI_TDM_TX_5",
  3749. .ops = &msm_dai_q6_tdm_ops,
  3750. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  3751. },
  3752. {
  3753. .capture = {
  3754. .stream_name = "Primary TDM6 Capture",
  3755. .aif_name = "PRI_TDM_TX_6",
  3756. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3757. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3758. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3759. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3760. SNDRV_PCM_FMTBIT_S24_LE |
  3761. SNDRV_PCM_FMTBIT_S32_LE,
  3762. .channels_min = 1,
  3763. .channels_max = 16,
  3764. .rate_min = 8000,
  3765. .rate_max = 352800,
  3766. },
  3767. .name = "PRI_TDM_TX_6",
  3768. .ops = &msm_dai_q6_tdm_ops,
  3769. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  3770. },
  3771. {
  3772. .capture = {
  3773. .stream_name = "Primary TDM7 Capture",
  3774. .aif_name = "PRI_TDM_TX_7",
  3775. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3776. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3777. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3778. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3779. SNDRV_PCM_FMTBIT_S24_LE |
  3780. SNDRV_PCM_FMTBIT_S32_LE,
  3781. .channels_min = 1,
  3782. .channels_max = 16,
  3783. .rate_min = 8000,
  3784. .rate_max = 352800,
  3785. },
  3786. .name = "PRI_TDM_TX_7",
  3787. .ops = &msm_dai_q6_tdm_ops,
  3788. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  3789. },
  3790. {
  3791. .playback = {
  3792. .stream_name = "Secondary TDM0 Playback",
  3793. .aif_name = "SEC_TDM_RX_0",
  3794. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3795. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3796. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3797. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3798. SNDRV_PCM_FMTBIT_S24_LE |
  3799. SNDRV_PCM_FMTBIT_S32_LE,
  3800. .channels_min = 1,
  3801. .channels_max = 16,
  3802. .rate_min = 8000,
  3803. .rate_max = 352800,
  3804. },
  3805. .name = "SEC_TDM_RX_0",
  3806. .ops = &msm_dai_q6_tdm_ops,
  3807. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  3808. },
  3809. {
  3810. .playback = {
  3811. .stream_name = "Secondary TDM1 Playback",
  3812. .aif_name = "SEC_TDM_RX_1",
  3813. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3814. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3815. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3816. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3817. SNDRV_PCM_FMTBIT_S24_LE |
  3818. SNDRV_PCM_FMTBIT_S32_LE,
  3819. .channels_min = 1,
  3820. .channels_max = 16,
  3821. .rate_min = 8000,
  3822. .rate_max = 352800,
  3823. },
  3824. .name = "SEC_TDM_RX_1",
  3825. .ops = &msm_dai_q6_tdm_ops,
  3826. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  3827. },
  3828. {
  3829. .playback = {
  3830. .stream_name = "Secondary TDM2 Playback",
  3831. .aif_name = "SEC_TDM_RX_2",
  3832. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3833. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3834. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3835. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3836. SNDRV_PCM_FMTBIT_S24_LE |
  3837. SNDRV_PCM_FMTBIT_S32_LE,
  3838. .channels_min = 1,
  3839. .channels_max = 16,
  3840. .rate_min = 8000,
  3841. .rate_max = 352800,
  3842. },
  3843. .name = "SEC_TDM_RX_2",
  3844. .ops = &msm_dai_q6_tdm_ops,
  3845. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  3846. },
  3847. {
  3848. .playback = {
  3849. .stream_name = "Secondary TDM3 Playback",
  3850. .aif_name = "SEC_TDM_RX_3",
  3851. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3852. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3853. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3854. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3855. SNDRV_PCM_FMTBIT_S24_LE |
  3856. SNDRV_PCM_FMTBIT_S32_LE,
  3857. .channels_min = 1,
  3858. .channels_max = 16,
  3859. .rate_min = 8000,
  3860. .rate_max = 352800,
  3861. },
  3862. .name = "SEC_TDM_RX_3",
  3863. .ops = &msm_dai_q6_tdm_ops,
  3864. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  3865. },
  3866. {
  3867. .playback = {
  3868. .stream_name = "Secondary TDM4 Playback",
  3869. .aif_name = "SEC_TDM_RX_4",
  3870. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3871. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3872. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3873. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3874. SNDRV_PCM_FMTBIT_S24_LE |
  3875. SNDRV_PCM_FMTBIT_S32_LE,
  3876. .channels_min = 1,
  3877. .channels_max = 16,
  3878. .rate_min = 8000,
  3879. .rate_max = 352800,
  3880. },
  3881. .name = "SEC_TDM_RX_4",
  3882. .ops = &msm_dai_q6_tdm_ops,
  3883. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  3884. },
  3885. {
  3886. .playback = {
  3887. .stream_name = "Secondary TDM5 Playback",
  3888. .aif_name = "SEC_TDM_RX_5",
  3889. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3890. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3891. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3892. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3893. SNDRV_PCM_FMTBIT_S24_LE |
  3894. SNDRV_PCM_FMTBIT_S32_LE,
  3895. .channels_min = 1,
  3896. .channels_max = 16,
  3897. .rate_min = 8000,
  3898. .rate_max = 352800,
  3899. },
  3900. .name = "SEC_TDM_RX_5",
  3901. .ops = &msm_dai_q6_tdm_ops,
  3902. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  3903. },
  3904. {
  3905. .playback = {
  3906. .stream_name = "Secondary TDM6 Playback",
  3907. .aif_name = "SEC_TDM_RX_6",
  3908. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3909. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3910. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3911. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3912. SNDRV_PCM_FMTBIT_S24_LE |
  3913. SNDRV_PCM_FMTBIT_S32_LE,
  3914. .channels_min = 1,
  3915. .channels_max = 16,
  3916. .rate_min = 8000,
  3917. .rate_max = 352800,
  3918. },
  3919. .name = "SEC_TDM_RX_6",
  3920. .ops = &msm_dai_q6_tdm_ops,
  3921. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  3922. },
  3923. {
  3924. .playback = {
  3925. .stream_name = "Secondary TDM7 Playback",
  3926. .aif_name = "SEC_TDM_RX_7",
  3927. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3928. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3929. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3930. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3931. SNDRV_PCM_FMTBIT_S24_LE |
  3932. SNDRV_PCM_FMTBIT_S32_LE,
  3933. .channels_min = 1,
  3934. .channels_max = 16,
  3935. .rate_min = 8000,
  3936. .rate_max = 352800,
  3937. },
  3938. .name = "SEC_TDM_RX_7",
  3939. .ops = &msm_dai_q6_tdm_ops,
  3940. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  3941. },
  3942. {
  3943. .capture = {
  3944. .stream_name = "Secondary TDM0 Capture",
  3945. .aif_name = "SEC_TDM_TX_0",
  3946. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3947. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3948. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3949. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3950. SNDRV_PCM_FMTBIT_S24_LE |
  3951. SNDRV_PCM_FMTBIT_S32_LE,
  3952. .channels_min = 1,
  3953. .channels_max = 16,
  3954. .rate_min = 8000,
  3955. .rate_max = 352800,
  3956. },
  3957. .name = "SEC_TDM_TX_0",
  3958. .ops = &msm_dai_q6_tdm_ops,
  3959. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  3960. },
  3961. {
  3962. .capture = {
  3963. .stream_name = "Secondary TDM1 Capture",
  3964. .aif_name = "SEC_TDM_TX_1",
  3965. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3966. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3967. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3968. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3969. SNDRV_PCM_FMTBIT_S24_LE |
  3970. SNDRV_PCM_FMTBIT_S32_LE,
  3971. .channels_min = 1,
  3972. .channels_max = 16,
  3973. .rate_min = 8000,
  3974. .rate_max = 352800,
  3975. },
  3976. .name = "SEC_TDM_TX_1",
  3977. .ops = &msm_dai_q6_tdm_ops,
  3978. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  3979. },
  3980. {
  3981. .capture = {
  3982. .stream_name = "Secondary TDM2 Capture",
  3983. .aif_name = "SEC_TDM_TX_2",
  3984. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3985. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  3986. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  3987. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3988. SNDRV_PCM_FMTBIT_S24_LE |
  3989. SNDRV_PCM_FMTBIT_S32_LE,
  3990. .channels_min = 1,
  3991. .channels_max = 16,
  3992. .rate_min = 8000,
  3993. .rate_max = 352800,
  3994. },
  3995. .name = "SEC_TDM_TX_2",
  3996. .ops = &msm_dai_q6_tdm_ops,
  3997. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  3998. },
  3999. {
  4000. .capture = {
  4001. .stream_name = "Secondary TDM3 Capture",
  4002. .aif_name = "SEC_TDM_TX_3",
  4003. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4004. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4005. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4006. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4007. SNDRV_PCM_FMTBIT_S24_LE |
  4008. SNDRV_PCM_FMTBIT_S32_LE,
  4009. .channels_min = 1,
  4010. .channels_max = 16,
  4011. .rate_min = 8000,
  4012. .rate_max = 352800,
  4013. },
  4014. .name = "SEC_TDM_TX_3",
  4015. .ops = &msm_dai_q6_tdm_ops,
  4016. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  4017. },
  4018. {
  4019. .capture = {
  4020. .stream_name = "Secondary TDM4 Capture",
  4021. .aif_name = "SEC_TDM_TX_4",
  4022. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4023. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4024. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4025. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4026. SNDRV_PCM_FMTBIT_S24_LE |
  4027. SNDRV_PCM_FMTBIT_S32_LE,
  4028. .channels_min = 1,
  4029. .channels_max = 16,
  4030. .rate_min = 8000,
  4031. .rate_max = 352800,
  4032. },
  4033. .name = "SEC_TDM_TX_4",
  4034. .ops = &msm_dai_q6_tdm_ops,
  4035. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  4036. },
  4037. {
  4038. .capture = {
  4039. .stream_name = "Secondary TDM5 Capture",
  4040. .aif_name = "SEC_TDM_TX_5",
  4041. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4042. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4043. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4044. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4045. SNDRV_PCM_FMTBIT_S24_LE |
  4046. SNDRV_PCM_FMTBIT_S32_LE,
  4047. .channels_min = 1,
  4048. .channels_max = 16,
  4049. .rate_min = 8000,
  4050. .rate_max = 352800,
  4051. },
  4052. .name = "SEC_TDM_TX_5",
  4053. .ops = &msm_dai_q6_tdm_ops,
  4054. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  4055. },
  4056. {
  4057. .capture = {
  4058. .stream_name = "Secondary TDM6 Capture",
  4059. .aif_name = "SEC_TDM_TX_6",
  4060. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4061. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4062. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4063. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4064. SNDRV_PCM_FMTBIT_S24_LE |
  4065. SNDRV_PCM_FMTBIT_S32_LE,
  4066. .channels_min = 1,
  4067. .channels_max = 16,
  4068. .rate_min = 8000,
  4069. .rate_max = 352800,
  4070. },
  4071. .name = "SEC_TDM_TX_6",
  4072. .ops = &msm_dai_q6_tdm_ops,
  4073. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  4074. },
  4075. {
  4076. .capture = {
  4077. .stream_name = "Secondary TDM7 Capture",
  4078. .aif_name = "SEC_TDM_TX_7",
  4079. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4080. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4081. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4082. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4083. SNDRV_PCM_FMTBIT_S24_LE |
  4084. SNDRV_PCM_FMTBIT_S32_LE,
  4085. .channels_min = 1,
  4086. .channels_max = 16,
  4087. .rate_min = 8000,
  4088. .rate_max = 352800,
  4089. },
  4090. .name = "SEC_TDM_TX_7",
  4091. .ops = &msm_dai_q6_tdm_ops,
  4092. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  4093. },
  4094. {
  4095. .playback = {
  4096. .stream_name = "Tertiary TDM0 Playback",
  4097. .aif_name = "TERT_TDM_RX_0",
  4098. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4099. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4100. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4101. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4102. SNDRV_PCM_FMTBIT_S24_LE |
  4103. SNDRV_PCM_FMTBIT_S32_LE,
  4104. .channels_min = 1,
  4105. .channels_max = 16,
  4106. .rate_min = 8000,
  4107. .rate_max = 352800,
  4108. },
  4109. .name = "TERT_TDM_RX_0",
  4110. .ops = &msm_dai_q6_tdm_ops,
  4111. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  4112. },
  4113. {
  4114. .playback = {
  4115. .stream_name = "Tertiary TDM1 Playback",
  4116. .aif_name = "TERT_TDM_RX_1",
  4117. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4118. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4119. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4120. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4121. SNDRV_PCM_FMTBIT_S24_LE |
  4122. SNDRV_PCM_FMTBIT_S32_LE,
  4123. .channels_min = 1,
  4124. .channels_max = 16,
  4125. .rate_min = 8000,
  4126. .rate_max = 352800,
  4127. },
  4128. .name = "TERT_TDM_RX_1",
  4129. .ops = &msm_dai_q6_tdm_ops,
  4130. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  4131. },
  4132. {
  4133. .playback = {
  4134. .stream_name = "Tertiary TDM2 Playback",
  4135. .aif_name = "TERT_TDM_RX_2",
  4136. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4137. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4138. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4139. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4140. SNDRV_PCM_FMTBIT_S24_LE |
  4141. SNDRV_PCM_FMTBIT_S32_LE,
  4142. .channels_min = 1,
  4143. .channels_max = 16,
  4144. .rate_min = 8000,
  4145. .rate_max = 352800,
  4146. },
  4147. .name = "TERT_TDM_RX_2",
  4148. .ops = &msm_dai_q6_tdm_ops,
  4149. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  4150. },
  4151. {
  4152. .playback = {
  4153. .stream_name = "Tertiary TDM3 Playback",
  4154. .aif_name = "TERT_TDM_RX_3",
  4155. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4156. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4157. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4158. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4159. SNDRV_PCM_FMTBIT_S24_LE |
  4160. SNDRV_PCM_FMTBIT_S32_LE,
  4161. .channels_min = 1,
  4162. .channels_max = 16,
  4163. .rate_min = 8000,
  4164. .rate_max = 352800,
  4165. },
  4166. .name = "TERT_TDM_RX_3",
  4167. .ops = &msm_dai_q6_tdm_ops,
  4168. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  4169. },
  4170. {
  4171. .playback = {
  4172. .stream_name = "Tertiary TDM4 Playback",
  4173. .aif_name = "TERT_TDM_RX_4",
  4174. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4175. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4176. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4177. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4178. SNDRV_PCM_FMTBIT_S24_LE |
  4179. SNDRV_PCM_FMTBIT_S32_LE,
  4180. .channels_min = 1,
  4181. .channels_max = 16,
  4182. .rate_min = 8000,
  4183. .rate_max = 352800,
  4184. },
  4185. .name = "TERT_TDM_RX_4",
  4186. .ops = &msm_dai_q6_tdm_ops,
  4187. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  4188. },
  4189. {
  4190. .playback = {
  4191. .stream_name = "Tertiary TDM5 Playback",
  4192. .aif_name = "TERT_TDM_RX_5",
  4193. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4194. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4195. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4196. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4197. SNDRV_PCM_FMTBIT_S24_LE |
  4198. SNDRV_PCM_FMTBIT_S32_LE,
  4199. .channels_min = 1,
  4200. .channels_max = 16,
  4201. .rate_min = 8000,
  4202. .rate_max = 352800,
  4203. },
  4204. .name = "TERT_TDM_RX_5",
  4205. .ops = &msm_dai_q6_tdm_ops,
  4206. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  4207. },
  4208. {
  4209. .playback = {
  4210. .stream_name = "Tertiary TDM6 Playback",
  4211. .aif_name = "TERT_TDM_RX_6",
  4212. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4213. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4214. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4215. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4216. SNDRV_PCM_FMTBIT_S24_LE |
  4217. SNDRV_PCM_FMTBIT_S32_LE,
  4218. .channels_min = 1,
  4219. .channels_max = 16,
  4220. .rate_min = 8000,
  4221. .rate_max = 352800,
  4222. },
  4223. .name = "TERT_TDM_RX_6",
  4224. .ops = &msm_dai_q6_tdm_ops,
  4225. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  4226. },
  4227. {
  4228. .playback = {
  4229. .stream_name = "Tertiary TDM7 Playback",
  4230. .aif_name = "TERT_TDM_RX_7",
  4231. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4232. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4233. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4234. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4235. SNDRV_PCM_FMTBIT_S24_LE |
  4236. SNDRV_PCM_FMTBIT_S32_LE,
  4237. .channels_min = 1,
  4238. .channels_max = 16,
  4239. .rate_min = 8000,
  4240. .rate_max = 352800,
  4241. },
  4242. .name = "TERT_TDM_RX_7",
  4243. .ops = &msm_dai_q6_tdm_ops,
  4244. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  4245. },
  4246. {
  4247. .capture = {
  4248. .stream_name = "Tertiary TDM0 Capture",
  4249. .aif_name = "TERT_TDM_TX_0",
  4250. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4251. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4252. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4253. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4254. SNDRV_PCM_FMTBIT_S24_LE |
  4255. SNDRV_PCM_FMTBIT_S32_LE,
  4256. .channels_min = 1,
  4257. .channels_max = 16,
  4258. .rate_min = 8000,
  4259. .rate_max = 352800,
  4260. },
  4261. .name = "TERT_TDM_TX_0",
  4262. .ops = &msm_dai_q6_tdm_ops,
  4263. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  4264. },
  4265. {
  4266. .capture = {
  4267. .stream_name = "Tertiary TDM1 Capture",
  4268. .aif_name = "TERT_TDM_TX_1",
  4269. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4270. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4271. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4272. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4273. SNDRV_PCM_FMTBIT_S24_LE |
  4274. SNDRV_PCM_FMTBIT_S32_LE,
  4275. .channels_min = 1,
  4276. .channels_max = 16,
  4277. .rate_min = 8000,
  4278. .rate_max = 352800,
  4279. },
  4280. .name = "TERT_TDM_TX_1",
  4281. .ops = &msm_dai_q6_tdm_ops,
  4282. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  4283. },
  4284. {
  4285. .capture = {
  4286. .stream_name = "Tertiary TDM2 Capture",
  4287. .aif_name = "TERT_TDM_TX_2",
  4288. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4289. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4290. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4291. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4292. SNDRV_PCM_FMTBIT_S24_LE |
  4293. SNDRV_PCM_FMTBIT_S32_LE,
  4294. .channels_min = 1,
  4295. .channels_max = 16,
  4296. .rate_min = 8000,
  4297. .rate_max = 352800,
  4298. },
  4299. .name = "TERT_TDM_TX_2",
  4300. .ops = &msm_dai_q6_tdm_ops,
  4301. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  4302. },
  4303. {
  4304. .capture = {
  4305. .stream_name = "Tertiary TDM3 Capture",
  4306. .aif_name = "TERT_TDM_TX_3",
  4307. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4308. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4309. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4310. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4311. SNDRV_PCM_FMTBIT_S24_LE |
  4312. SNDRV_PCM_FMTBIT_S32_LE,
  4313. .channels_min = 1,
  4314. .channels_max = 16,
  4315. .rate_min = 8000,
  4316. .rate_max = 352800,
  4317. },
  4318. .name = "TERT_TDM_TX_3",
  4319. .ops = &msm_dai_q6_tdm_ops,
  4320. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  4321. },
  4322. {
  4323. .capture = {
  4324. .stream_name = "Tertiary TDM4 Capture",
  4325. .aif_name = "TERT_TDM_TX_4",
  4326. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4327. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4328. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4329. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4330. SNDRV_PCM_FMTBIT_S24_LE |
  4331. SNDRV_PCM_FMTBIT_S32_LE,
  4332. .channels_min = 1,
  4333. .channels_max = 16,
  4334. .rate_min = 8000,
  4335. .rate_max = 352800,
  4336. },
  4337. .name = "TERT_TDM_TX_4",
  4338. .ops = &msm_dai_q6_tdm_ops,
  4339. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  4340. },
  4341. {
  4342. .capture = {
  4343. .stream_name = "Tertiary TDM5 Capture",
  4344. .aif_name = "TERT_TDM_TX_5",
  4345. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4346. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4347. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4348. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4349. SNDRV_PCM_FMTBIT_S24_LE |
  4350. SNDRV_PCM_FMTBIT_S32_LE,
  4351. .channels_min = 1,
  4352. .channels_max = 16,
  4353. .rate_min = 8000,
  4354. .rate_max = 352800,
  4355. },
  4356. .name = "TERT_TDM_TX_5",
  4357. .ops = &msm_dai_q6_tdm_ops,
  4358. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  4359. },
  4360. {
  4361. .capture = {
  4362. .stream_name = "Tertiary TDM6 Capture",
  4363. .aif_name = "TERT_TDM_TX_6",
  4364. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4365. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4366. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4367. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4368. SNDRV_PCM_FMTBIT_S24_LE |
  4369. SNDRV_PCM_FMTBIT_S32_LE,
  4370. .channels_min = 1,
  4371. .channels_max = 16,
  4372. .rate_min = 8000,
  4373. .rate_max = 352800,
  4374. },
  4375. .name = "TERT_TDM_TX_6",
  4376. .ops = &msm_dai_q6_tdm_ops,
  4377. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  4378. },
  4379. {
  4380. .capture = {
  4381. .stream_name = "Tertiary TDM7 Capture",
  4382. .aif_name = "TERT_TDM_TX_7",
  4383. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4384. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4385. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4386. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4387. SNDRV_PCM_FMTBIT_S24_LE |
  4388. SNDRV_PCM_FMTBIT_S32_LE,
  4389. .channels_min = 1,
  4390. .channels_max = 16,
  4391. .rate_min = 8000,
  4392. .rate_max = 352800,
  4393. },
  4394. .name = "TERT_TDM_TX_7",
  4395. .ops = &msm_dai_q6_tdm_ops,
  4396. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  4397. },
  4398. {
  4399. .playback = {
  4400. .stream_name = "Quaternary TDM0 Playback",
  4401. .aif_name = "QUAT_TDM_RX_0",
  4402. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4403. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4404. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4405. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4406. SNDRV_PCM_FMTBIT_S24_LE |
  4407. SNDRV_PCM_FMTBIT_S32_LE,
  4408. .channels_min = 1,
  4409. .channels_max = 16,
  4410. .rate_min = 8000,
  4411. .rate_max = 352800,
  4412. },
  4413. .name = "QUAT_TDM_RX_0",
  4414. .ops = &msm_dai_q6_tdm_ops,
  4415. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  4416. },
  4417. {
  4418. .playback = {
  4419. .stream_name = "Quaternary TDM1 Playback",
  4420. .aif_name = "QUAT_TDM_RX_1",
  4421. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4422. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4423. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4424. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4425. SNDRV_PCM_FMTBIT_S24_LE |
  4426. SNDRV_PCM_FMTBIT_S32_LE,
  4427. .channels_min = 1,
  4428. .channels_max = 16,
  4429. .rate_min = 8000,
  4430. .rate_max = 352800,
  4431. },
  4432. .name = "QUAT_TDM_RX_1",
  4433. .ops = &msm_dai_q6_tdm_ops,
  4434. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  4435. },
  4436. {
  4437. .playback = {
  4438. .stream_name = "Quaternary TDM2 Playback",
  4439. .aif_name = "QUAT_TDM_RX_2",
  4440. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4441. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4442. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4443. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4444. SNDRV_PCM_FMTBIT_S24_LE |
  4445. SNDRV_PCM_FMTBIT_S32_LE,
  4446. .channels_min = 1,
  4447. .channels_max = 16,
  4448. .rate_min = 8000,
  4449. .rate_max = 352800,
  4450. },
  4451. .name = "QUAT_TDM_RX_2",
  4452. .ops = &msm_dai_q6_tdm_ops,
  4453. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  4454. },
  4455. {
  4456. .playback = {
  4457. .stream_name = "Quaternary TDM3 Playback",
  4458. .aif_name = "QUAT_TDM_RX_3",
  4459. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4460. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4461. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4462. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4463. SNDRV_PCM_FMTBIT_S24_LE |
  4464. SNDRV_PCM_FMTBIT_S32_LE,
  4465. .channels_min = 1,
  4466. .channels_max = 16,
  4467. .rate_min = 8000,
  4468. .rate_max = 352800,
  4469. },
  4470. .name = "QUAT_TDM_RX_3",
  4471. .ops = &msm_dai_q6_tdm_ops,
  4472. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  4473. },
  4474. {
  4475. .playback = {
  4476. .stream_name = "Quaternary TDM4 Playback",
  4477. .aif_name = "QUAT_TDM_RX_4",
  4478. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4479. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4480. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4481. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4482. SNDRV_PCM_FMTBIT_S24_LE |
  4483. SNDRV_PCM_FMTBIT_S32_LE,
  4484. .channels_min = 1,
  4485. .channels_max = 16,
  4486. .rate_min = 8000,
  4487. .rate_max = 352800,
  4488. },
  4489. .name = "QUAT_TDM_RX_4",
  4490. .ops = &msm_dai_q6_tdm_ops,
  4491. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  4492. },
  4493. {
  4494. .playback = {
  4495. .stream_name = "Quaternary TDM5 Playback",
  4496. .aif_name = "QUAT_TDM_RX_5",
  4497. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4498. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4499. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4500. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4501. SNDRV_PCM_FMTBIT_S24_LE |
  4502. SNDRV_PCM_FMTBIT_S32_LE,
  4503. .channels_min = 1,
  4504. .channels_max = 16,
  4505. .rate_min = 8000,
  4506. .rate_max = 352800,
  4507. },
  4508. .name = "QUAT_TDM_RX_5",
  4509. .ops = &msm_dai_q6_tdm_ops,
  4510. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  4511. },
  4512. {
  4513. .playback = {
  4514. .stream_name = "Quaternary TDM6 Playback",
  4515. .aif_name = "QUAT_TDM_RX_6",
  4516. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4517. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4518. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4519. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4520. SNDRV_PCM_FMTBIT_S24_LE |
  4521. SNDRV_PCM_FMTBIT_S32_LE,
  4522. .channels_min = 1,
  4523. .channels_max = 16,
  4524. .rate_min = 8000,
  4525. .rate_max = 352800,
  4526. },
  4527. .name = "QUAT_TDM_RX_6",
  4528. .ops = &msm_dai_q6_tdm_ops,
  4529. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  4530. },
  4531. {
  4532. .playback = {
  4533. .stream_name = "Quaternary TDM7 Playback",
  4534. .aif_name = "QUAT_TDM_RX_7",
  4535. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4536. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4537. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4538. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4539. SNDRV_PCM_FMTBIT_S24_LE |
  4540. SNDRV_PCM_FMTBIT_S32_LE,
  4541. .channels_min = 1,
  4542. .channels_max = 16,
  4543. .rate_min = 8000,
  4544. .rate_max = 352800,
  4545. },
  4546. .name = "QUAT_TDM_RX_7",
  4547. .ops = &msm_dai_q6_tdm_ops,
  4548. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  4549. },
  4550. {
  4551. .capture = {
  4552. .stream_name = "Quaternary TDM0 Capture",
  4553. .aif_name = "QUAT_TDM_TX_0",
  4554. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4555. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4556. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4557. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4558. SNDRV_PCM_FMTBIT_S24_LE |
  4559. SNDRV_PCM_FMTBIT_S32_LE,
  4560. .channels_min = 1,
  4561. .channels_max = 16,
  4562. .rate_min = 8000,
  4563. .rate_max = 352800,
  4564. },
  4565. .name = "QUAT_TDM_TX_0",
  4566. .ops = &msm_dai_q6_tdm_ops,
  4567. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  4568. },
  4569. {
  4570. .capture = {
  4571. .stream_name = "Quaternary TDM1 Capture",
  4572. .aif_name = "QUAT_TDM_TX_1",
  4573. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4574. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4575. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4576. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4577. SNDRV_PCM_FMTBIT_S24_LE |
  4578. SNDRV_PCM_FMTBIT_S32_LE,
  4579. .channels_min = 1,
  4580. .channels_max = 16,
  4581. .rate_min = 8000,
  4582. .rate_max = 352800,
  4583. },
  4584. .name = "QUAT_TDM_TX_1",
  4585. .ops = &msm_dai_q6_tdm_ops,
  4586. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  4587. },
  4588. {
  4589. .capture = {
  4590. .stream_name = "Quaternary TDM2 Capture",
  4591. .aif_name = "QUAT_TDM_TX_2",
  4592. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4593. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4594. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4595. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4596. SNDRV_PCM_FMTBIT_S24_LE |
  4597. SNDRV_PCM_FMTBIT_S32_LE,
  4598. .channels_min = 1,
  4599. .channels_max = 16,
  4600. .rate_min = 8000,
  4601. .rate_max = 352800,
  4602. },
  4603. .name = "QUAT_TDM_TX_2",
  4604. .ops = &msm_dai_q6_tdm_ops,
  4605. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  4606. },
  4607. {
  4608. .capture = {
  4609. .stream_name = "Quaternary TDM3 Capture",
  4610. .aif_name = "QUAT_TDM_TX_3",
  4611. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4612. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4613. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4614. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4615. SNDRV_PCM_FMTBIT_S24_LE |
  4616. SNDRV_PCM_FMTBIT_S32_LE,
  4617. .channels_min = 1,
  4618. .channels_max = 16,
  4619. .rate_min = 8000,
  4620. .rate_max = 352800,
  4621. },
  4622. .name = "QUAT_TDM_TX_3",
  4623. .ops = &msm_dai_q6_tdm_ops,
  4624. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  4625. },
  4626. {
  4627. .capture = {
  4628. .stream_name = "Quaternary TDM4 Capture",
  4629. .aif_name = "QUAT_TDM_TX_4",
  4630. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4631. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4632. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4633. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4634. SNDRV_PCM_FMTBIT_S24_LE |
  4635. SNDRV_PCM_FMTBIT_S32_LE,
  4636. .channels_min = 1,
  4637. .channels_max = 16,
  4638. .rate_min = 8000,
  4639. .rate_max = 352800,
  4640. },
  4641. .name = "QUAT_TDM_TX_4",
  4642. .ops = &msm_dai_q6_tdm_ops,
  4643. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  4644. },
  4645. {
  4646. .capture = {
  4647. .stream_name = "Quaternary TDM5 Capture",
  4648. .aif_name = "QUAT_TDM_TX_5",
  4649. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4650. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4651. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4652. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4653. SNDRV_PCM_FMTBIT_S24_LE |
  4654. SNDRV_PCM_FMTBIT_S32_LE,
  4655. .channels_min = 1,
  4656. .channels_max = 16,
  4657. .rate_min = 8000,
  4658. .rate_max = 352800,
  4659. },
  4660. .name = "QUAT_TDM_TX_5",
  4661. .ops = &msm_dai_q6_tdm_ops,
  4662. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  4663. },
  4664. {
  4665. .capture = {
  4666. .stream_name = "Quaternary TDM6 Capture",
  4667. .aif_name = "QUAT_TDM_TX_6",
  4668. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4669. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4670. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4671. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4672. SNDRV_PCM_FMTBIT_S24_LE |
  4673. SNDRV_PCM_FMTBIT_S32_LE,
  4674. .channels_min = 1,
  4675. .channels_max = 16,
  4676. .rate_min = 8000,
  4677. .rate_max = 352800,
  4678. },
  4679. .name = "QUAT_TDM_TX_6",
  4680. .ops = &msm_dai_q6_tdm_ops,
  4681. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  4682. },
  4683. {
  4684. .capture = {
  4685. .stream_name = "Quaternary TDM7 Capture",
  4686. .aif_name = "QUAT_TDM_TX_7",
  4687. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4688. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4689. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4690. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4691. SNDRV_PCM_FMTBIT_S24_LE |
  4692. SNDRV_PCM_FMTBIT_S32_LE,
  4693. .channels_min = 1,
  4694. .channels_max = 16,
  4695. .rate_min = 8000,
  4696. .rate_max = 352800,
  4697. },
  4698. .name = "QUAT_TDM_TX_7",
  4699. .ops = &msm_dai_q6_tdm_ops,
  4700. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  4701. },
  4702. {
  4703. .playback = {
  4704. .stream_name = "Quinary TDM0 Playback",
  4705. .aif_name = "QUIN_TDM_RX_0",
  4706. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4707. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4708. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4709. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4710. SNDRV_PCM_FMTBIT_S24_LE |
  4711. SNDRV_PCM_FMTBIT_S32_LE,
  4712. .channels_min = 1,
  4713. .channels_max = 16,
  4714. .rate_min = 8000,
  4715. .rate_max = 352800,
  4716. },
  4717. .name = "QUIN_TDM_RX_0",
  4718. .ops = &msm_dai_q6_tdm_ops,
  4719. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  4720. },
  4721. {
  4722. .playback = {
  4723. .stream_name = "Quinary TDM1 Playback",
  4724. .aif_name = "QUIN_TDM_RX_1",
  4725. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4726. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4727. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4728. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4729. SNDRV_PCM_FMTBIT_S24_LE |
  4730. SNDRV_PCM_FMTBIT_S32_LE,
  4731. .channels_min = 1,
  4732. .channels_max = 16,
  4733. .rate_min = 8000,
  4734. .rate_max = 352800,
  4735. },
  4736. .name = "QUIN_TDM_RX_1",
  4737. .ops = &msm_dai_q6_tdm_ops,
  4738. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  4739. },
  4740. {
  4741. .playback = {
  4742. .stream_name = "Quinary TDM2 Playback",
  4743. .aif_name = "QUIN_TDM_RX_2",
  4744. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4745. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4746. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4747. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4748. SNDRV_PCM_FMTBIT_S24_LE |
  4749. SNDRV_PCM_FMTBIT_S32_LE,
  4750. .channels_min = 1,
  4751. .channels_max = 16,
  4752. .rate_min = 8000,
  4753. .rate_max = 352800,
  4754. },
  4755. .name = "QUIN_TDM_RX_2",
  4756. .ops = &msm_dai_q6_tdm_ops,
  4757. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  4758. },
  4759. {
  4760. .playback = {
  4761. .stream_name = "Quinary TDM3 Playback",
  4762. .aif_name = "QUIN_TDM_RX_3",
  4763. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4764. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4765. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4766. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4767. SNDRV_PCM_FMTBIT_S24_LE |
  4768. SNDRV_PCM_FMTBIT_S32_LE,
  4769. .channels_min = 1,
  4770. .channels_max = 16,
  4771. .rate_min = 8000,
  4772. .rate_max = 352800,
  4773. },
  4774. .name = "QUIN_TDM_RX_3",
  4775. .ops = &msm_dai_q6_tdm_ops,
  4776. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  4777. },
  4778. {
  4779. .playback = {
  4780. .stream_name = "Quinary TDM4 Playback",
  4781. .aif_name = "QUIN_TDM_RX_4",
  4782. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4783. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4784. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4785. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4786. SNDRV_PCM_FMTBIT_S24_LE |
  4787. SNDRV_PCM_FMTBIT_S32_LE,
  4788. .channels_min = 1,
  4789. .channels_max = 16,
  4790. .rate_min = 8000,
  4791. .rate_max = 352800,
  4792. },
  4793. .name = "QUIN_TDM_RX_4",
  4794. .ops = &msm_dai_q6_tdm_ops,
  4795. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  4796. },
  4797. {
  4798. .playback = {
  4799. .stream_name = "Quinary TDM5 Playback",
  4800. .aif_name = "QUIN_TDM_RX_5",
  4801. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4802. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4803. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4804. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4805. SNDRV_PCM_FMTBIT_S24_LE |
  4806. SNDRV_PCM_FMTBIT_S32_LE,
  4807. .channels_min = 1,
  4808. .channels_max = 16,
  4809. .rate_min = 8000,
  4810. .rate_max = 352800,
  4811. },
  4812. .name = "QUIN_TDM_RX_5",
  4813. .ops = &msm_dai_q6_tdm_ops,
  4814. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  4815. },
  4816. {
  4817. .playback = {
  4818. .stream_name = "Quinary TDM6 Playback",
  4819. .aif_name = "QUIN_TDM_RX_6",
  4820. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4821. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4822. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4823. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4824. SNDRV_PCM_FMTBIT_S24_LE |
  4825. SNDRV_PCM_FMTBIT_S32_LE,
  4826. .channels_min = 1,
  4827. .channels_max = 16,
  4828. .rate_min = 8000,
  4829. .rate_max = 352800,
  4830. },
  4831. .name = "QUIN_TDM_RX_6",
  4832. .ops = &msm_dai_q6_tdm_ops,
  4833. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  4834. },
  4835. {
  4836. .playback = {
  4837. .stream_name = "Quinary TDM7 Playback",
  4838. .aif_name = "QUIN_TDM_RX_7",
  4839. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4840. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  4841. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4842. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4843. SNDRV_PCM_FMTBIT_S24_LE |
  4844. SNDRV_PCM_FMTBIT_S32_LE,
  4845. .channels_min = 1,
  4846. .channels_max = 16,
  4847. .rate_min = 8000,
  4848. .rate_max = 352800,
  4849. },
  4850. .name = "QUIN_TDM_RX_7",
  4851. .ops = &msm_dai_q6_tdm_ops,
  4852. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  4853. },
  4854. {
  4855. .capture = {
  4856. .stream_name = "Quinary TDM0 Capture",
  4857. .aif_name = "QUIN_TDM_TX_0",
  4858. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4859. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4860. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4861. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4862. SNDRV_PCM_FMTBIT_S24_LE |
  4863. SNDRV_PCM_FMTBIT_S32_LE,
  4864. .channels_min = 1,
  4865. .channels_max = 16,
  4866. .rate_min = 8000,
  4867. .rate_max = 352800,
  4868. },
  4869. .name = "QUIN_TDM_TX_0",
  4870. .ops = &msm_dai_q6_tdm_ops,
  4871. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  4872. },
  4873. {
  4874. .capture = {
  4875. .stream_name = "Quinary TDM1 Capture",
  4876. .aif_name = "QUIN_TDM_TX_1",
  4877. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4878. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4879. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4880. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4881. SNDRV_PCM_FMTBIT_S24_LE |
  4882. SNDRV_PCM_FMTBIT_S32_LE,
  4883. .channels_min = 1,
  4884. .channels_max = 16,
  4885. .rate_min = 8000,
  4886. .rate_max = 352800,
  4887. },
  4888. .name = "QUIN_TDM_TX_1",
  4889. .ops = &msm_dai_q6_tdm_ops,
  4890. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  4891. },
  4892. {
  4893. .capture = {
  4894. .stream_name = "Quinary TDM2 Capture",
  4895. .aif_name = "QUIN_TDM_TX_2",
  4896. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4897. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4898. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4899. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4900. SNDRV_PCM_FMTBIT_S24_LE |
  4901. SNDRV_PCM_FMTBIT_S32_LE,
  4902. .channels_min = 1,
  4903. .channels_max = 16,
  4904. .rate_min = 8000,
  4905. .rate_max = 352800,
  4906. },
  4907. .name = "QUIN_TDM_TX_2",
  4908. .ops = &msm_dai_q6_tdm_ops,
  4909. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  4910. },
  4911. {
  4912. .capture = {
  4913. .stream_name = "Quinary TDM3 Capture",
  4914. .aif_name = "QUIN_TDM_TX_3",
  4915. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4916. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4917. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4918. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4919. SNDRV_PCM_FMTBIT_S24_LE |
  4920. SNDRV_PCM_FMTBIT_S32_LE,
  4921. .channels_min = 1,
  4922. .channels_max = 16,
  4923. .rate_min = 8000,
  4924. .rate_max = 352800,
  4925. },
  4926. .name = "QUIN_TDM_TX_3",
  4927. .ops = &msm_dai_q6_tdm_ops,
  4928. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  4929. },
  4930. {
  4931. .capture = {
  4932. .stream_name = "Quinary TDM4 Capture",
  4933. .aif_name = "QUIN_TDM_TX_4",
  4934. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4935. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4936. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4937. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4938. SNDRV_PCM_FMTBIT_S24_LE |
  4939. SNDRV_PCM_FMTBIT_S32_LE,
  4940. .channels_min = 1,
  4941. .channels_max = 16,
  4942. .rate_min = 8000,
  4943. .rate_max = 352800,
  4944. },
  4945. .name = "QUIN_TDM_TX_4",
  4946. .ops = &msm_dai_q6_tdm_ops,
  4947. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  4948. },
  4949. {
  4950. .capture = {
  4951. .stream_name = "Quinary TDM5 Capture",
  4952. .aif_name = "QUIN_TDM_TX_5",
  4953. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4954. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4955. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4956. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4957. SNDRV_PCM_FMTBIT_S24_LE |
  4958. SNDRV_PCM_FMTBIT_S32_LE,
  4959. .channels_min = 1,
  4960. .channels_max = 16,
  4961. .rate_min = 8000,
  4962. .rate_max = 352800,
  4963. },
  4964. .name = "QUIN_TDM_TX_5",
  4965. .ops = &msm_dai_q6_tdm_ops,
  4966. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  4967. },
  4968. {
  4969. .capture = {
  4970. .stream_name = "Quinary TDM6 Capture",
  4971. .aif_name = "QUIN_TDM_TX_6",
  4972. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4973. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4974. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4975. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4976. SNDRV_PCM_FMTBIT_S24_LE |
  4977. SNDRV_PCM_FMTBIT_S32_LE,
  4978. .channels_min = 1,
  4979. .channels_max = 16,
  4980. .rate_min = 8000,
  4981. .rate_max = 352800,
  4982. },
  4983. .name = "QUIN_TDM_TX_6",
  4984. .ops = &msm_dai_q6_tdm_ops,
  4985. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  4986. },
  4987. {
  4988. .capture = {
  4989. .stream_name = "Quinary TDM7 Capture",
  4990. .aif_name = "QUIN_TDM_TX_7",
  4991. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4992. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  4993. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  4994. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4995. SNDRV_PCM_FMTBIT_S24_LE |
  4996. SNDRV_PCM_FMTBIT_S32_LE,
  4997. .channels_min = 1,
  4998. .channels_max = 16,
  4999. .rate_min = 8000,
  5000. .rate_max = 352800,
  5001. },
  5002. .name = "QUIN_TDM_TX_7",
  5003. .ops = &msm_dai_q6_tdm_ops,
  5004. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  5005. },
  5006. {
  5007. .playback = {
  5008. .stream_name = "Senary TDM0 Playback",
  5009. .aif_name = "SEN_TDM_RX_0",
  5010. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5011. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5012. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5013. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5014. SNDRV_PCM_FMTBIT_S24_LE |
  5015. SNDRV_PCM_FMTBIT_S32_LE,
  5016. .channels_min = 1,
  5017. .channels_max = 8,
  5018. .rate_min = 8000,
  5019. .rate_max = 352800,
  5020. },
  5021. .name = "SEN_TDM_RX_0",
  5022. .ops = &msm_dai_q6_tdm_ops,
  5023. .id = AFE_PORT_ID_SENARY_TDM_RX,
  5024. },
  5025. {
  5026. .playback = {
  5027. .stream_name = "Senary TDM1 Playback",
  5028. .aif_name = "SEN_TDM_RX_1",
  5029. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5030. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5031. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5032. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5033. SNDRV_PCM_FMTBIT_S24_LE |
  5034. SNDRV_PCM_FMTBIT_S32_LE,
  5035. .channels_min = 1,
  5036. .channels_max = 8,
  5037. .rate_min = 8000,
  5038. .rate_max = 352800,
  5039. },
  5040. .name = "SEN_TDM_RX_1",
  5041. .ops = &msm_dai_q6_tdm_ops,
  5042. .id = AFE_PORT_ID_SENARY_TDM_RX_1,
  5043. },
  5044. {
  5045. .playback = {
  5046. .stream_name = "Senary TDM2 Playback",
  5047. .aif_name = "SEN_TDM_RX_2",
  5048. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5049. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5050. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5051. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5052. SNDRV_PCM_FMTBIT_S24_LE |
  5053. SNDRV_PCM_FMTBIT_S32_LE,
  5054. .channels_min = 1,
  5055. .channels_max = 8,
  5056. .rate_min = 8000,
  5057. .rate_max = 352800,
  5058. },
  5059. .name = "SEN_TDM_RX_2",
  5060. .ops = &msm_dai_q6_tdm_ops,
  5061. .id = AFE_PORT_ID_SENARY_TDM_RX_2,
  5062. },
  5063. {
  5064. .playback = {
  5065. .stream_name = "Senary TDM3 Playback",
  5066. .aif_name = "SEN_TDM_RX_3",
  5067. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5068. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5069. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5070. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5071. SNDRV_PCM_FMTBIT_S24_LE |
  5072. SNDRV_PCM_FMTBIT_S32_LE,
  5073. .channels_min = 1,
  5074. .channels_max = 8,
  5075. .rate_min = 8000,
  5076. .rate_max = 352800,
  5077. },
  5078. .name = "SEN_TDM_RX_3",
  5079. .ops = &msm_dai_q6_tdm_ops,
  5080. .id = AFE_PORT_ID_SENARY_TDM_RX_3,
  5081. },
  5082. {
  5083. .playback = {
  5084. .stream_name = "Senary TDM4 Playback",
  5085. .aif_name = "SEN_TDM_RX_4",
  5086. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5087. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5088. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5089. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5090. SNDRV_PCM_FMTBIT_S24_LE |
  5091. SNDRV_PCM_FMTBIT_S32_LE,
  5092. .channels_min = 1,
  5093. .channels_max = 8,
  5094. .rate_min = 8000,
  5095. .rate_max = 352800,
  5096. },
  5097. .name = "SEN_TDM_RX_4",
  5098. .ops = &msm_dai_q6_tdm_ops,
  5099. .id = AFE_PORT_ID_SENARY_TDM_RX_4,
  5100. },
  5101. {
  5102. .playback = {
  5103. .stream_name = "Senary TDM5 Playback",
  5104. .aif_name = "SEN_TDM_RX_5",
  5105. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5106. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5107. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5108. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5109. SNDRV_PCM_FMTBIT_S24_LE |
  5110. SNDRV_PCM_FMTBIT_S32_LE,
  5111. .channels_min = 1,
  5112. .channels_max = 8,
  5113. .rate_min = 8000,
  5114. .rate_max = 352800,
  5115. },
  5116. .name = "SEN_TDM_RX_5",
  5117. .ops = &msm_dai_q6_tdm_ops,
  5118. .id = AFE_PORT_ID_SENARY_TDM_RX_5,
  5119. },
  5120. {
  5121. .playback = {
  5122. .stream_name = "Senary TDM6 Playback",
  5123. .aif_name = "SEN_TDM_RX_6",
  5124. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5125. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5126. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5127. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5128. SNDRV_PCM_FMTBIT_S24_LE |
  5129. SNDRV_PCM_FMTBIT_S32_LE,
  5130. .channels_min = 1,
  5131. .channels_max = 8,
  5132. .rate_min = 8000,
  5133. .rate_max = 352800,
  5134. },
  5135. .name = "SEN_TDM_RX_6",
  5136. .ops = &msm_dai_q6_tdm_ops,
  5137. .id = AFE_PORT_ID_SENARY_TDM_RX_6,
  5138. },
  5139. {
  5140. .playback = {
  5141. .stream_name = "Senary TDM7 Playback",
  5142. .aif_name = "SEN_TDM_RX_7",
  5143. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5144. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  5145. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5146. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5147. SNDRV_PCM_FMTBIT_S24_LE |
  5148. SNDRV_PCM_FMTBIT_S32_LE,
  5149. .channels_min = 1,
  5150. .channels_max = 8,
  5151. .rate_min = 8000,
  5152. .rate_max = 352800,
  5153. },
  5154. .name = "SEN_TDM_RX_7",
  5155. .ops = &msm_dai_q6_tdm_ops,
  5156. .id = AFE_PORT_ID_SENARY_TDM_RX_7,
  5157. },
  5158. {
  5159. .capture = {
  5160. .stream_name = "Senary TDM0 Capture",
  5161. .aif_name = "SEN_TDM_TX_0",
  5162. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5163. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5164. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5165. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5166. SNDRV_PCM_FMTBIT_S24_LE |
  5167. SNDRV_PCM_FMTBIT_S32_LE,
  5168. .channels_min = 1,
  5169. .channels_max = 8,
  5170. .rate_min = 8000,
  5171. .rate_max = 352800,
  5172. },
  5173. .name = "SEN_TDM_TX_0",
  5174. .ops = &msm_dai_q6_tdm_ops,
  5175. .id = AFE_PORT_ID_SENARY_TDM_TX,
  5176. },
  5177. {
  5178. .capture = {
  5179. .stream_name = "Senary TDM1 Capture",
  5180. .aif_name = "SEN_TDM_TX_1",
  5181. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5182. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5183. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5184. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5185. SNDRV_PCM_FMTBIT_S24_LE |
  5186. SNDRV_PCM_FMTBIT_S32_LE,
  5187. .channels_min = 1,
  5188. .channels_max = 8,
  5189. .rate_min = 8000,
  5190. .rate_max = 352800,
  5191. },
  5192. .name = "SEN_TDM_TX_1",
  5193. .ops = &msm_dai_q6_tdm_ops,
  5194. .id = AFE_PORT_ID_SENARY_TDM_TX_1,
  5195. },
  5196. {
  5197. .capture = {
  5198. .stream_name = "Senary TDM2 Capture",
  5199. .aif_name = "SEN_TDM_TX_2",
  5200. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5201. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5202. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5203. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5204. SNDRV_PCM_FMTBIT_S24_LE |
  5205. SNDRV_PCM_FMTBIT_S32_LE,
  5206. .channels_min = 1,
  5207. .channels_max = 8,
  5208. .rate_min = 8000,
  5209. .rate_max = 352800,
  5210. },
  5211. .name = "SEN_TDM_TX_2",
  5212. .ops = &msm_dai_q6_tdm_ops,
  5213. .id = AFE_PORT_ID_SENARY_TDM_TX_2,
  5214. },
  5215. {
  5216. .capture = {
  5217. .stream_name = "Senary TDM3 Capture",
  5218. .aif_name = "SEN_TDM_TX_3",
  5219. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5220. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5221. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5222. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5223. SNDRV_PCM_FMTBIT_S24_LE |
  5224. SNDRV_PCM_FMTBIT_S32_LE,
  5225. .channels_min = 1,
  5226. .channels_max = 8,
  5227. .rate_min = 8000,
  5228. .rate_max = 352800,
  5229. },
  5230. .name = "SEN_TDM_TX_3",
  5231. .ops = &msm_dai_q6_tdm_ops,
  5232. .id = AFE_PORT_ID_SENARY_TDM_TX_3,
  5233. },
  5234. {
  5235. .capture = {
  5236. .stream_name = "Senary TDM4 Capture",
  5237. .aif_name = "SEN_TDM_TX_4",
  5238. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5239. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5240. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5241. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5242. SNDRV_PCM_FMTBIT_S24_LE |
  5243. SNDRV_PCM_FMTBIT_S32_LE,
  5244. .channels_min = 1,
  5245. .channels_max = 8,
  5246. .rate_min = 8000,
  5247. .rate_max = 352800,
  5248. },
  5249. .name = "SEN_TDM_TX_4",
  5250. .ops = &msm_dai_q6_tdm_ops,
  5251. .id = AFE_PORT_ID_SENARY_TDM_TX_4,
  5252. },
  5253. {
  5254. .capture = {
  5255. .stream_name = "Senary TDM5 Capture",
  5256. .aif_name = "SEN_TDM_TX_5",
  5257. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5258. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5259. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5260. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5261. SNDRV_PCM_FMTBIT_S24_LE |
  5262. SNDRV_PCM_FMTBIT_S32_LE,
  5263. .channels_min = 1,
  5264. .channels_max = 8,
  5265. .rate_min = 8000,
  5266. .rate_max = 352800,
  5267. },
  5268. .name = "SEN_TDM_TX_5",
  5269. .ops = &msm_dai_q6_tdm_ops,
  5270. .id = AFE_PORT_ID_SENARY_TDM_TX_5,
  5271. },
  5272. {
  5273. .capture = {
  5274. .stream_name = "Senary TDM6 Capture",
  5275. .aif_name = "SEN_TDM_TX_6",
  5276. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5277. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5278. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5279. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5280. SNDRV_PCM_FMTBIT_S24_LE |
  5281. SNDRV_PCM_FMTBIT_S32_LE,
  5282. .channels_min = 1,
  5283. .channels_max = 8,
  5284. .rate_min = 8000,
  5285. .rate_max = 352800,
  5286. },
  5287. .name = "SEN_TDM_TX_6",
  5288. .ops = &msm_dai_q6_tdm_ops,
  5289. .id = AFE_PORT_ID_SENARY_TDM_TX_6,
  5290. },
  5291. {
  5292. .capture = {
  5293. .stream_name = "Senary TDM7 Capture",
  5294. .aif_name = "SEN_TDM_TX_7",
  5295. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  5296. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  5297. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  5298. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5299. SNDRV_PCM_FMTBIT_S24_LE |
  5300. SNDRV_PCM_FMTBIT_S32_LE,
  5301. .channels_min = 1,
  5302. .channels_max = 8,
  5303. .rate_min = 8000,
  5304. .rate_max = 352800,
  5305. },
  5306. .name = "SEN_TDM_TX_7",
  5307. .ops = &msm_dai_q6_tdm_ops,
  5308. .id = AFE_PORT_ID_SENARY_TDM_TX_7,
  5309. },
  5310. };
  5311. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  5312. .name = "msm-dai-q6-tdm",
  5313. };
  5314. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  5315. {
  5316. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  5317. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  5318. int rc = 0;
  5319. u32 tdm_dev_id = 0;
  5320. int port_idx = 0;
  5321. struct device_node *tdm_parent_node = NULL;
  5322. /* retrieve device/afe id */
  5323. rc = of_property_read_u32(pdev->dev.of_node,
  5324. "qcom,msm-cpudai-tdm-dev-id",
  5325. &tdm_dev_id);
  5326. if (rc) {
  5327. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  5328. __func__);
  5329. goto rtn;
  5330. }
  5331. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  5332. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  5333. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  5334. __func__, tdm_dev_id);
  5335. rc = -ENXIO;
  5336. goto rtn;
  5337. }
  5338. pdev->id = tdm_dev_id;
  5339. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  5340. GFP_KERNEL);
  5341. if (!dai_data) {
  5342. rc = -ENOMEM;
  5343. dev_err(&pdev->dev,
  5344. "%s Failed to allocate memory for tdm dai_data\n",
  5345. __func__);
  5346. goto rtn;
  5347. }
  5348. memset(dai_data, 0, sizeof(*dai_data));
  5349. rc = of_property_read_u32(pdev->dev.of_node,
  5350. "qcom,msm-dai-is-island-supported",
  5351. &dai_data->is_island_dai);
  5352. if (rc)
  5353. dev_dbg(&pdev->dev, "island supported entry not found\n");
  5354. /* TDM CFG */
  5355. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  5356. rc = of_property_read_u32(tdm_parent_node,
  5357. "qcom,msm-cpudai-tdm-sync-mode",
  5358. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  5359. if (rc) {
  5360. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  5361. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  5362. goto free_dai_data;
  5363. }
  5364. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  5365. __func__, dai_data->port_cfg.tdm.sync_mode);
  5366. rc = of_property_read_u32(tdm_parent_node,
  5367. "qcom,msm-cpudai-tdm-sync-src",
  5368. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  5369. if (rc) {
  5370. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  5371. __func__, "qcom,msm-cpudai-tdm-sync-src");
  5372. goto free_dai_data;
  5373. }
  5374. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  5375. __func__, dai_data->port_cfg.tdm.sync_src);
  5376. rc = of_property_read_u32(tdm_parent_node,
  5377. "qcom,msm-cpudai-tdm-data-out",
  5378. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  5379. if (rc) {
  5380. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  5381. __func__, "qcom,msm-cpudai-tdm-data-out");
  5382. goto free_dai_data;
  5383. }
  5384. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  5385. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  5386. rc = of_property_read_u32(tdm_parent_node,
  5387. "qcom,msm-cpudai-tdm-invert-sync",
  5388. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  5389. if (rc) {
  5390. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  5391. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  5392. goto free_dai_data;
  5393. }
  5394. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  5395. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  5396. rc = of_property_read_u32(tdm_parent_node,
  5397. "qcom,msm-cpudai-tdm-data-delay",
  5398. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  5399. if (rc) {
  5400. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  5401. __func__, "qcom,msm-cpudai-tdm-data-delay");
  5402. goto free_dai_data;
  5403. }
  5404. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  5405. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  5406. /* TDM CFG -- set default */
  5407. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  5408. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  5409. AFE_API_VERSION_TDM_CONFIG;
  5410. /* TDM SLOT MAPPING CFG */
  5411. rc = of_property_read_u32(pdev->dev.of_node,
  5412. "qcom,msm-cpudai-tdm-data-align",
  5413. &dai_data->port_cfg.slot_mapping.data_align_type);
  5414. if (rc) {
  5415. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  5416. __func__,
  5417. "qcom,msm-cpudai-tdm-data-align");
  5418. goto free_dai_data;
  5419. }
  5420. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  5421. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  5422. /* TDM SLOT MAPPING CFG -- set default */
  5423. dai_data->port_cfg.slot_mapping.minor_version =
  5424. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  5425. dai_data->port_cfg.slot_mapping_v2.minor_version =
  5426. AFE_API_VERSION_SLOT_MAPPING_CONFIG_V2;
  5427. /* CUSTOM TDM HEADER CFG */
  5428. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  5429. if (of_find_property(pdev->dev.of_node,
  5430. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  5431. of_find_property(pdev->dev.of_node,
  5432. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  5433. of_find_property(pdev->dev.of_node,
  5434. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  5435. /* if the property exist */
  5436. rc = of_property_read_u32(pdev->dev.of_node,
  5437. "qcom,msm-cpudai-tdm-header-start-offset",
  5438. (u32 *)&custom_tdm_header->start_offset);
  5439. if (rc) {
  5440. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  5441. __func__,
  5442. "qcom,msm-cpudai-tdm-header-start-offset");
  5443. goto free_dai_data;
  5444. }
  5445. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  5446. __func__, custom_tdm_header->start_offset);
  5447. rc = of_property_read_u32(pdev->dev.of_node,
  5448. "qcom,msm-cpudai-tdm-header-width",
  5449. (u32 *)&custom_tdm_header->header_width);
  5450. if (rc) {
  5451. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  5452. __func__, "qcom,msm-cpudai-tdm-header-width");
  5453. goto free_dai_data;
  5454. }
  5455. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  5456. __func__, custom_tdm_header->header_width);
  5457. rc = of_property_read_u32(pdev->dev.of_node,
  5458. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  5459. (u32 *)&custom_tdm_header->num_frame_repeat);
  5460. if (rc) {
  5461. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  5462. __func__,
  5463. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  5464. goto free_dai_data;
  5465. }
  5466. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  5467. __func__, custom_tdm_header->num_frame_repeat);
  5468. /* CUSTOM TDM HEADER CFG -- set default */
  5469. custom_tdm_header->minor_version =
  5470. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  5471. custom_tdm_header->header_type =
  5472. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  5473. } else {
  5474. /* CUSTOM TDM HEADER CFG -- set default */
  5475. custom_tdm_header->header_type =
  5476. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  5477. /* proceed with probe */
  5478. }
  5479. /* copy static clk per parent node */
  5480. dai_data->clk_set = tdm_clk_set;
  5481. /* copy static group cfg per parent node */
  5482. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  5483. /* copy static num group ports per parent node */
  5484. dai_data->num_group_ports = num_tdm_group_ports;
  5485. dai_data->lane_cfg = tdm_lane_cfg;
  5486. dev_set_drvdata(&pdev->dev, dai_data);
  5487. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  5488. if (port_idx < 0) {
  5489. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  5490. __func__, tdm_dev_id);
  5491. rc = -EINVAL;
  5492. goto free_dai_data;
  5493. }
  5494. rc = snd_soc_register_component(&pdev->dev,
  5495. &msm_q6_tdm_dai_component,
  5496. &msm_dai_q6_tdm_dai[port_idx], 1);
  5497. if (rc) {
  5498. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  5499. __func__, tdm_dev_id, rc);
  5500. goto err_register;
  5501. }
  5502. return 0;
  5503. err_register:
  5504. free_dai_data:
  5505. kfree(dai_data);
  5506. rtn:
  5507. return rc;
  5508. }
  5509. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  5510. {
  5511. struct msm_dai_q6_tdm_dai_data *dai_data =
  5512. dev_get_drvdata(&pdev->dev);
  5513. snd_soc_unregister_component(&pdev->dev);
  5514. kfree(dai_data);
  5515. return 0;
  5516. }
  5517. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  5518. { .compatible = "qcom,msm-dai-q6-tdm", },
  5519. {}
  5520. };
  5521. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  5522. static struct platform_driver msm_dai_q6_tdm_driver = {
  5523. .probe = msm_dai_q6_tdm_dev_probe,
  5524. .remove = msm_dai_q6_tdm_dev_remove,
  5525. .driver = {
  5526. .name = "msm-dai-q6-tdm",
  5527. .owner = THIS_MODULE,
  5528. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  5529. .suppress_bind_attrs = true,
  5530. },
  5531. };
  5532. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  5533. {
  5534. .playback = {
  5535. .stream_name = "WSA CDC DMA0 Playback",
  5536. .aif_name = "WSA_CDC_DMA_RX_0",
  5537. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5538. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5539. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5540. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5541. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5542. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5543. SNDRV_PCM_RATE_384000,
  5544. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5545. SNDRV_PCM_FMTBIT_S24_LE |
  5546. SNDRV_PCM_FMTBIT_S24_3LE |
  5547. SNDRV_PCM_FMTBIT_S32_LE,
  5548. .channels_min = 1,
  5549. .channels_max = 4,
  5550. .rate_min = 8000,
  5551. .rate_max = 384000,
  5552. },
  5553. .name = "WSA_CDC_DMA_RX_0",
  5554. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  5555. },
  5556. {
  5557. .capture = {
  5558. .stream_name = "WSA CDC DMA0 Capture",
  5559. .aif_name = "WSA_CDC_DMA_TX_0",
  5560. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5561. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5562. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5563. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5564. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5565. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5566. SNDRV_PCM_RATE_384000,
  5567. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5568. SNDRV_PCM_FMTBIT_S24_LE |
  5569. SNDRV_PCM_FMTBIT_S24_3LE |
  5570. SNDRV_PCM_FMTBIT_S32_LE,
  5571. .channels_min = 1,
  5572. .channels_max = 4,
  5573. .rate_min = 8000,
  5574. .rate_max = 384000,
  5575. },
  5576. .name = "WSA_CDC_DMA_TX_0",
  5577. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  5578. },
  5579. {
  5580. .playback = {
  5581. .stream_name = "WSA CDC DMA1 Playback",
  5582. .aif_name = "WSA_CDC_DMA_RX_1",
  5583. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5584. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5585. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5586. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5587. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5588. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5589. SNDRV_PCM_RATE_384000,
  5590. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5591. SNDRV_PCM_FMTBIT_S24_LE |
  5592. SNDRV_PCM_FMTBIT_S24_3LE |
  5593. SNDRV_PCM_FMTBIT_S32_LE,
  5594. .channels_min = 1,
  5595. .channels_max = 2,
  5596. .rate_min = 8000,
  5597. .rate_max = 384000,
  5598. },
  5599. .name = "WSA_CDC_DMA_RX_1",
  5600. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  5601. },
  5602. {
  5603. .capture = {
  5604. .stream_name = "WSA CDC DMA1 Capture",
  5605. .aif_name = "WSA_CDC_DMA_TX_1",
  5606. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5607. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5608. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5609. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5610. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5611. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5612. SNDRV_PCM_RATE_384000,
  5613. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5614. SNDRV_PCM_FMTBIT_S24_LE |
  5615. SNDRV_PCM_FMTBIT_S24_3LE |
  5616. SNDRV_PCM_FMTBIT_S32_LE,
  5617. .channels_min = 1,
  5618. .channels_max = 2,
  5619. .rate_min = 8000,
  5620. .rate_max = 384000,
  5621. },
  5622. .name = "WSA_CDC_DMA_TX_1",
  5623. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  5624. },
  5625. {
  5626. .capture = {
  5627. .stream_name = "WSA CDC DMA2 Capture",
  5628. .aif_name = "WSA_CDC_DMA_TX_2",
  5629. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5630. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5631. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5632. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5633. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5634. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5635. SNDRV_PCM_RATE_384000,
  5636. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5637. SNDRV_PCM_FMTBIT_S24_LE |
  5638. SNDRV_PCM_FMTBIT_S24_3LE |
  5639. SNDRV_PCM_FMTBIT_S32_LE,
  5640. .channels_min = 1,
  5641. .channels_max = 1,
  5642. .rate_min = 8000,
  5643. .rate_max = 384000,
  5644. },
  5645. .name = "WSA_CDC_DMA_TX_2",
  5646. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  5647. },
  5648. {
  5649. .capture = {
  5650. .stream_name = "VA CDC DMA0 Capture",
  5651. .aif_name = "VA_CDC_DMA_TX_0",
  5652. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5653. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5654. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5655. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5656. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5657. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5658. SNDRV_PCM_RATE_384000,
  5659. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5660. SNDRV_PCM_FMTBIT_S24_LE |
  5661. SNDRV_PCM_FMTBIT_S24_3LE,
  5662. .channels_min = 1,
  5663. .channels_max = 8,
  5664. .rate_min = 8000,
  5665. .rate_max = 384000,
  5666. },
  5667. .name = "VA_CDC_DMA_TX_0",
  5668. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  5669. },
  5670. {
  5671. .capture = {
  5672. .stream_name = "VA CDC DMA1 Capture",
  5673. .aif_name = "VA_CDC_DMA_TX_1",
  5674. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5675. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5676. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5677. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5678. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5679. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5680. SNDRV_PCM_RATE_384000,
  5681. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5682. SNDRV_PCM_FMTBIT_S24_LE |
  5683. SNDRV_PCM_FMTBIT_S24_3LE,
  5684. .channels_min = 1,
  5685. .channels_max = 8,
  5686. .rate_min = 8000,
  5687. .rate_max = 384000,
  5688. },
  5689. .name = "VA_CDC_DMA_TX_1",
  5690. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  5691. },
  5692. {
  5693. .capture = {
  5694. .stream_name = "VA CDC DMA2 Capture",
  5695. .aif_name = "VA_CDC_DMA_TX_2",
  5696. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5697. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5698. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5699. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5700. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5701. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5702. SNDRV_PCM_RATE_384000,
  5703. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5704. SNDRV_PCM_FMTBIT_S24_LE |
  5705. SNDRV_PCM_FMTBIT_S24_3LE,
  5706. .channels_min = 1,
  5707. .channels_max = 8,
  5708. .rate_min = 8000,
  5709. .rate_max = 384000,
  5710. },
  5711. .name = "VA_CDC_DMA_TX_2",
  5712. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  5713. },
  5714. {
  5715. .playback = {
  5716. .stream_name = "RX CDC DMA0 Playback",
  5717. .aif_name = "RX_CDC_DMA_RX_0",
  5718. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5719. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5720. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5721. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5722. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5723. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5724. SNDRV_PCM_RATE_384000,
  5725. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5726. SNDRV_PCM_FMTBIT_S24_LE |
  5727. SNDRV_PCM_FMTBIT_S24_3LE |
  5728. SNDRV_PCM_FMTBIT_S32_LE,
  5729. .channels_min = 1,
  5730. .channels_max = 2,
  5731. .rate_min = 8000,
  5732. .rate_max = 384000,
  5733. },
  5734. .name = "RX_CDC_DMA_RX_0",
  5735. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  5736. },
  5737. {
  5738. .capture = {
  5739. .stream_name = "TX CDC DMA0 Capture",
  5740. .aif_name = "TX_CDC_DMA_TX_0",
  5741. .rates = SNDRV_PCM_RATE_8000 |
  5742. SNDRV_PCM_RATE_16000 |
  5743. SNDRV_PCM_RATE_32000 |
  5744. SNDRV_PCM_RATE_48000 |
  5745. SNDRV_PCM_RATE_96000 |
  5746. SNDRV_PCM_RATE_192000 |
  5747. SNDRV_PCM_RATE_384000,
  5748. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5749. SNDRV_PCM_FMTBIT_S24_LE |
  5750. SNDRV_PCM_FMTBIT_S24_3LE |
  5751. SNDRV_PCM_FMTBIT_S32_LE,
  5752. .channels_min = 1,
  5753. .channels_max = 3,
  5754. .rate_min = 8000,
  5755. .rate_max = 384000,
  5756. },
  5757. .name = "TX_CDC_DMA_TX_0",
  5758. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  5759. },
  5760. {
  5761. .playback = {
  5762. .stream_name = "RX CDC DMA1 Playback",
  5763. .aif_name = "RX_CDC_DMA_RX_1",
  5764. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5765. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5766. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5767. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5768. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5769. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5770. SNDRV_PCM_RATE_384000,
  5771. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5772. SNDRV_PCM_FMTBIT_S24_LE |
  5773. SNDRV_PCM_FMTBIT_S24_3LE |
  5774. SNDRV_PCM_FMTBIT_S32_LE,
  5775. .channels_min = 1,
  5776. .channels_max = 2,
  5777. .rate_min = 8000,
  5778. .rate_max = 384000,
  5779. },
  5780. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  5781. .name = "RX_CDC_DMA_RX_1",
  5782. },
  5783. {
  5784. .capture = {
  5785. .stream_name = "TX CDC DMA1 Capture",
  5786. .aif_name = "TX_CDC_DMA_TX_1",
  5787. .rates = SNDRV_PCM_RATE_8000 |
  5788. SNDRV_PCM_RATE_16000 |
  5789. SNDRV_PCM_RATE_32000 |
  5790. SNDRV_PCM_RATE_48000 |
  5791. SNDRV_PCM_RATE_96000 |
  5792. SNDRV_PCM_RATE_192000 |
  5793. SNDRV_PCM_RATE_384000,
  5794. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5795. SNDRV_PCM_FMTBIT_S24_LE |
  5796. SNDRV_PCM_FMTBIT_S24_3LE |
  5797. SNDRV_PCM_FMTBIT_S32_LE,
  5798. .channels_min = 1,
  5799. .channels_max = 3,
  5800. .rate_min = 8000,
  5801. .rate_max = 384000,
  5802. },
  5803. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  5804. .name = "TX_CDC_DMA_TX_1",
  5805. },
  5806. {
  5807. .playback = {
  5808. .stream_name = "RX CDC DMA2 Playback",
  5809. .aif_name = "RX_CDC_DMA_RX_2",
  5810. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5811. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5812. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5813. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5814. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5815. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5816. SNDRV_PCM_RATE_384000,
  5817. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5818. SNDRV_PCM_FMTBIT_S24_LE |
  5819. SNDRV_PCM_FMTBIT_S24_3LE |
  5820. SNDRV_PCM_FMTBIT_S32_LE,
  5821. .channels_min = 1,
  5822. .channels_max = 1,
  5823. .rate_min = 8000,
  5824. .rate_max = 384000,
  5825. },
  5826. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  5827. .name = "RX_CDC_DMA_RX_2",
  5828. },
  5829. {
  5830. .capture = {
  5831. .stream_name = "TX CDC DMA2 Capture",
  5832. .aif_name = "TX_CDC_DMA_TX_2",
  5833. .rates = SNDRV_PCM_RATE_8000 |
  5834. SNDRV_PCM_RATE_16000 |
  5835. SNDRV_PCM_RATE_32000 |
  5836. SNDRV_PCM_RATE_48000 |
  5837. SNDRV_PCM_RATE_96000 |
  5838. SNDRV_PCM_RATE_192000 |
  5839. SNDRV_PCM_RATE_384000,
  5840. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5841. SNDRV_PCM_FMTBIT_S24_LE |
  5842. SNDRV_PCM_FMTBIT_S24_3LE |
  5843. SNDRV_PCM_FMTBIT_S32_LE,
  5844. .channels_min = 1,
  5845. .channels_max = 4,
  5846. .rate_min = 8000,
  5847. .rate_max = 384000,
  5848. },
  5849. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  5850. .name = "TX_CDC_DMA_TX_2",
  5851. },
  5852. {
  5853. .playback = {
  5854. .stream_name = "RX CDC DMA3 Playback",
  5855. .aif_name = "RX_CDC_DMA_RX_3",
  5856. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5857. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5858. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5859. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5860. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5861. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5862. SNDRV_PCM_RATE_384000,
  5863. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5864. SNDRV_PCM_FMTBIT_S24_LE |
  5865. SNDRV_PCM_FMTBIT_S24_3LE |
  5866. SNDRV_PCM_FMTBIT_S32_LE,
  5867. .channels_min = 1,
  5868. .channels_max = 1,
  5869. .rate_min = 8000,
  5870. .rate_max = 384000,
  5871. },
  5872. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  5873. .name = "RX_CDC_DMA_RX_3",
  5874. },
  5875. {
  5876. .capture = {
  5877. .stream_name = "TX CDC DMA3 Capture",
  5878. .aif_name = "TX_CDC_DMA_TX_3",
  5879. .rates = SNDRV_PCM_RATE_8000 |
  5880. SNDRV_PCM_RATE_16000 |
  5881. SNDRV_PCM_RATE_32000 |
  5882. SNDRV_PCM_RATE_48000 |
  5883. SNDRV_PCM_RATE_96000 |
  5884. SNDRV_PCM_RATE_192000 |
  5885. SNDRV_PCM_RATE_384000,
  5886. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5887. SNDRV_PCM_FMTBIT_S24_LE |
  5888. SNDRV_PCM_FMTBIT_S24_3LE |
  5889. SNDRV_PCM_FMTBIT_S32_LE,
  5890. .channels_min = 1,
  5891. .channels_max = 8,
  5892. .rate_min = 8000,
  5893. .rate_max = 384000,
  5894. },
  5895. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  5896. .name = "TX_CDC_DMA_TX_3",
  5897. },
  5898. {
  5899. .playback = {
  5900. .stream_name = "RX CDC DMA4 Playback",
  5901. .aif_name = "RX_CDC_DMA_RX_4",
  5902. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5903. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5904. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5905. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5906. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5907. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5908. SNDRV_PCM_RATE_384000,
  5909. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5910. SNDRV_PCM_FMTBIT_S24_LE |
  5911. SNDRV_PCM_FMTBIT_S24_3LE |
  5912. SNDRV_PCM_FMTBIT_S32_LE,
  5913. .channels_min = 1,
  5914. .channels_max = 6,
  5915. .rate_min = 8000,
  5916. .rate_max = 384000,
  5917. },
  5918. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  5919. .name = "RX_CDC_DMA_RX_4",
  5920. },
  5921. {
  5922. .capture = {
  5923. .stream_name = "TX CDC DMA4 Capture",
  5924. .aif_name = "TX_CDC_DMA_TX_4",
  5925. .rates = SNDRV_PCM_RATE_8000 |
  5926. SNDRV_PCM_RATE_16000 |
  5927. SNDRV_PCM_RATE_32000 |
  5928. SNDRV_PCM_RATE_48000 |
  5929. SNDRV_PCM_RATE_96000 |
  5930. SNDRV_PCM_RATE_192000 |
  5931. SNDRV_PCM_RATE_384000,
  5932. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5933. SNDRV_PCM_FMTBIT_S24_LE |
  5934. SNDRV_PCM_FMTBIT_S24_3LE |
  5935. SNDRV_PCM_FMTBIT_S32_LE,
  5936. .channels_min = 1,
  5937. .channels_max = 8,
  5938. .rate_min = 8000,
  5939. .rate_max = 384000,
  5940. },
  5941. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  5942. .name = "TX_CDC_DMA_TX_4",
  5943. },
  5944. {
  5945. .playback = {
  5946. .stream_name = "RX CDC DMA5 Playback",
  5947. .aif_name = "RX_CDC_DMA_RX_5",
  5948. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5949. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5950. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5951. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5952. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5953. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5954. SNDRV_PCM_RATE_384000,
  5955. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5956. SNDRV_PCM_FMTBIT_S24_LE |
  5957. SNDRV_PCM_FMTBIT_S24_3LE |
  5958. SNDRV_PCM_FMTBIT_S32_LE,
  5959. .channels_min = 1,
  5960. .channels_max = 1,
  5961. .rate_min = 8000,
  5962. .rate_max = 384000,
  5963. },
  5964. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  5965. .name = "RX_CDC_DMA_RX_5",
  5966. },
  5967. {
  5968. .capture = {
  5969. .stream_name = "TX CDC DMA5 Capture",
  5970. .aif_name = "TX_CDC_DMA_TX_5",
  5971. .rates = SNDRV_PCM_RATE_8000 |
  5972. SNDRV_PCM_RATE_16000 |
  5973. SNDRV_PCM_RATE_32000 |
  5974. SNDRV_PCM_RATE_48000 |
  5975. SNDRV_PCM_RATE_96000 |
  5976. SNDRV_PCM_RATE_192000 |
  5977. SNDRV_PCM_RATE_384000,
  5978. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5979. SNDRV_PCM_FMTBIT_S24_LE |
  5980. SNDRV_PCM_FMTBIT_S24_3LE |
  5981. SNDRV_PCM_FMTBIT_S32_LE,
  5982. .channels_min = 1,
  5983. .channels_max = 4,
  5984. .rate_min = 8000,
  5985. .rate_max = 384000,
  5986. },
  5987. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  5988. .name = "TX_CDC_DMA_TX_5",
  5989. },
  5990. {
  5991. .playback = {
  5992. .stream_name = "RX CDC DMA6 Playback",
  5993. .aif_name = "RX_CDC_DMA_RX_6",
  5994. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5995. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5996. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5997. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5998. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5999. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  6000. SNDRV_PCM_RATE_384000,
  6001. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6002. SNDRV_PCM_FMTBIT_S24_LE |
  6003. SNDRV_PCM_FMTBIT_S24_3LE |
  6004. SNDRV_PCM_FMTBIT_S32_LE,
  6005. .channels_min = 1,
  6006. .channels_max = 4,
  6007. .rate_min = 8000,
  6008. .rate_max = 384000,
  6009. },
  6010. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  6011. .name = "RX_CDC_DMA_RX_6",
  6012. },
  6013. {
  6014. .playback = {
  6015. .stream_name = "RX CDC DMA7 Playback",
  6016. .aif_name = "RX_CDC_DMA_RX_7",
  6017. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6018. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6019. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6020. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  6021. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  6022. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  6023. SNDRV_PCM_RATE_384000,
  6024. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6025. SNDRV_PCM_FMTBIT_S24_LE |
  6026. SNDRV_PCM_FMTBIT_S24_3LE |
  6027. SNDRV_PCM_FMTBIT_S32_LE,
  6028. .channels_min = 1,
  6029. .channels_max = 2,
  6030. .rate_min = 8000,
  6031. .rate_max = 384000,
  6032. },
  6033. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  6034. .name = "RX_CDC_DMA_RX_7",
  6035. },
  6036. };
  6037. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  6038. .name = "msm-dai-cdc-dma-dev",
  6039. };
  6040. /* DT related probe for each codec DMA interface device */
  6041. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  6042. {
  6043. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  6044. u32 cdc_dma_id = 0;
  6045. int i;
  6046. int rc = 0;
  6047. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  6048. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  6049. &cdc_dma_id);
  6050. if (rc) {
  6051. dev_err(&pdev->dev,
  6052. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  6053. return rc;
  6054. }
  6055. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  6056. dev_name(&pdev->dev), cdc_dma_id);
  6057. pdev->id = cdc_dma_id;
  6058. dai_data = devm_kzalloc(&pdev->dev,
  6059. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  6060. GFP_KERNEL);
  6061. if (!dai_data)
  6062. return -ENOMEM;
  6063. rc = of_property_read_u32(pdev->dev.of_node,
  6064. "qcom,msm-dai-is-island-supported",
  6065. &dai_data->is_island_dai);
  6066. if (rc)
  6067. dev_dbg(&pdev->dev, "island supported entry not found\n");
  6068. rc = of_property_read_u32(pdev->dev.of_node,
  6069. "qcom,msm-cdc-dma-data-align",
  6070. &dai_data->cdc_dma_data_align);
  6071. if (rc)
  6072. dev_dbg(&pdev->dev, "cdc dma data align supported entry not found\n");
  6073. dev_set_drvdata(&pdev->dev, dai_data);
  6074. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  6075. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  6076. return snd_soc_register_component(&pdev->dev,
  6077. &msm_q6_cdc_dma_dai_component,
  6078. &msm_dai_q6_cdc_dma_dai[i], 1);
  6079. }
  6080. }
  6081. return -ENODEV;
  6082. }
  6083. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  6084. {
  6085. snd_soc_unregister_component(&pdev->dev);
  6086. return 0;
  6087. }
  6088. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  6089. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  6090. { }
  6091. };
  6092. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  6093. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  6094. .probe = msm_dai_q6_cdc_dma_dev_probe,
  6095. .remove = msm_dai_q6_cdc_dma_dev_remove,
  6096. .driver = {
  6097. .name = "msm-dai-cdc-dma-dev",
  6098. .owner = THIS_MODULE,
  6099. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  6100. .suppress_bind_attrs = true,
  6101. },
  6102. };
  6103. /* DT related probe for codec DMA interface device group */
  6104. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  6105. {
  6106. int rc;
  6107. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6108. if (rc) {
  6109. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6110. __func__, rc);
  6111. } else
  6112. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6113. return rc;
  6114. }
  6115. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  6116. {
  6117. of_platform_depopulate(&pdev->dev);
  6118. return 0;
  6119. }
  6120. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  6121. { .compatible = "qcom,msm-dai-cdc-dma", },
  6122. { }
  6123. };
  6124. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  6125. static struct platform_driver msm_dai_cdc_dma_q6 = {
  6126. .probe = msm_dai_cdc_dma_q6_probe,
  6127. .remove = msm_dai_cdc_dma_q6_remove,
  6128. .driver = {
  6129. .name = "msm-dai-cdc-dma",
  6130. .owner = THIS_MODULE,
  6131. .of_match_table = msm_dai_cdc_dma_dt_match,
  6132. .suppress_bind_attrs = true,
  6133. },
  6134. };
  6135. int __init msm_dai_q6_init(void)
  6136. {
  6137. int rc;
  6138. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  6139. if (rc) {
  6140. pr_err("%s: fail to register auxpcm dev driver", __func__);
  6141. goto fail;
  6142. }
  6143. rc = platform_driver_register(&msm_dai_q6);
  6144. if (rc) {
  6145. pr_err("%s: fail to register dai q6 driver", __func__);
  6146. goto dai_q6_fail;
  6147. }
  6148. rc = platform_driver_register(&msm_dai_q6_dev);
  6149. if (rc) {
  6150. pr_err("%s: fail to register dai q6 dev driver", __func__);
  6151. goto dai_q6_dev_fail;
  6152. }
  6153. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  6154. if (rc) {
  6155. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  6156. goto dai_q6_mi2s_drv_fail;
  6157. }
  6158. #if 0
  6159. rc = platform_driver_register(&msm_dai_q6_meta_mi2s_driver);
  6160. if (rc) {
  6161. pr_err("%s: fail to register dai META MI2S dev drv\n",
  6162. __func__);
  6163. goto dai_q6_meta_mi2s_drv_fail;
  6164. }
  6165. #endif
  6166. rc = platform_driver_register(&msm_dai_mi2s_q6);
  6167. if (rc) {
  6168. pr_err("%s: fail to register dai MI2S\n", __func__);
  6169. goto dai_mi2s_q6_fail;
  6170. }
  6171. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  6172. if (rc) {
  6173. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  6174. goto dai_q6_tdm_drv_fail;
  6175. }
  6176. rc = platform_driver_register(&msm_dai_tdm_q6);
  6177. if (rc) {
  6178. pr_err("%s: fail to register dai TDM\n", __func__);
  6179. goto dai_tdm_q6_fail;
  6180. }
  6181. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  6182. if (rc) {
  6183. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  6184. goto dai_cdc_dma_q6_dev_fail;
  6185. }
  6186. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  6187. if (rc) {
  6188. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  6189. goto dai_cdc_dma_q6_fail;
  6190. }
  6191. return rc;
  6192. #if 0
  6193. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  6194. if (rc) {
  6195. pr_err("%s: fail to register dai SPDIF\n", __func__);
  6196. goto dai_spdif_q6_fail;
  6197. }
  6198. dai_cdc_dma_q6_fail:
  6199. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  6200. dai_cdc_dma_q6_dev_fail:
  6201. platform_driver_unregister(&msm_dai_tdm_q6);
  6202. dai_q6_tdm_drv_fail:
  6203. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  6204. dai_spdif_q6_fail:
  6205. platform_driver_unregister(&msm_auxpcm_dev_driver);
  6206. fail:
  6207. #endif
  6208. dai_cdc_dma_q6_fail:
  6209. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  6210. dai_cdc_dma_q6_dev_fail:
  6211. platform_driver_unregister(&msm_dai_tdm_q6);
  6212. dai_tdm_q6_fail:
  6213. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  6214. dai_q6_tdm_drv_fail:
  6215. platform_driver_unregister(&msm_dai_mi2s_q6);
  6216. dai_mi2s_q6_fail:
  6217. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  6218. dai_q6_mi2s_drv_fail:
  6219. platform_driver_unregister(&msm_dai_q6_dev);
  6220. dai_q6_dev_fail:
  6221. platform_driver_unregister(&msm_dai_q6);
  6222. dai_q6_fail:
  6223. platform_driver_unregister(&msm_auxpcm_dev_driver);
  6224. fail:
  6225. return 0;
  6226. }
  6227. void msm_dai_q6_exit(void)
  6228. {
  6229. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  6230. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  6231. platform_driver_unregister(&msm_dai_tdm_q6);
  6232. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  6233. platform_driver_unregister(&msm_dai_mi2s_q6);
  6234. // platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  6235. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  6236. platform_driver_unregister(&msm_dai_q6_dev);
  6237. platform_driver_unregister(&msm_auxpcm_dev_driver);
  6238. }
  6239. /* Module information */
  6240. MODULE_DESCRIPTION("MSM DSP DAI driver");
  6241. MODULE_LICENSE("GPL v2");