msm-dai-q6-v2.c 310 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605
  1. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/device.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/bitops.h>
  17. #include <linux/slab.h>
  18. #include <linux/clk.h>
  19. #include <linux/of_device.h>
  20. #include <sound/core.h>
  21. #include <sound/pcm.h>
  22. #include <sound/soc.h>
  23. #include <sound/pcm_params.h>
  24. #include <dsp/apr_audio-v2.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include <dsp/q6core.h>
  27. #include "msm-dai-q6-v2.h"
  28. #include "codecs/core.h"
  29. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  30. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  31. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  32. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  33. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  34. #define spdif_clock_value(rate) (2*rate*32*2)
  35. #define CHANNEL_STATUS_SIZE 24
  36. #define CHANNEL_STATUS_MASK_INIT 0x0
  37. #define CHANNEL_STATUS_MASK 0x4
  38. #define AFE_API_VERSION_CLOCK_SET 1
  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. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  48. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  49. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  50. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  51. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  52. ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  53. };
  54. enum {
  55. SPKR_1,
  56. SPKR_2,
  57. };
  58. static const struct afe_clk_set lpass_clk_set_default = {
  59. AFE_API_VERSION_CLOCK_SET,
  60. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  61. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  62. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  63. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  64. 0,
  65. };
  66. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  67. AFE_API_VERSION_I2S_CONFIG,
  68. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  69. 0,
  70. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  71. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  72. Q6AFE_LPASS_MODE_CLK1_VALID,
  73. 0,
  74. };
  75. enum {
  76. STATUS_PORT_STARTED, /* track if AFE port has started */
  77. /* track AFE Tx port status for bi-directional transfers */
  78. STATUS_TX_PORT,
  79. /* track AFE Rx port status for bi-directional transfers */
  80. STATUS_RX_PORT,
  81. STATUS_MAX
  82. };
  83. enum {
  84. RATE_8KHZ,
  85. RATE_16KHZ,
  86. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  87. };
  88. enum {
  89. IDX_PRIMARY_TDM_RX_0,
  90. IDX_PRIMARY_TDM_RX_1,
  91. IDX_PRIMARY_TDM_RX_2,
  92. IDX_PRIMARY_TDM_RX_3,
  93. IDX_PRIMARY_TDM_RX_4,
  94. IDX_PRIMARY_TDM_RX_5,
  95. IDX_PRIMARY_TDM_RX_6,
  96. IDX_PRIMARY_TDM_RX_7,
  97. IDX_PRIMARY_TDM_TX_0,
  98. IDX_PRIMARY_TDM_TX_1,
  99. IDX_PRIMARY_TDM_TX_2,
  100. IDX_PRIMARY_TDM_TX_3,
  101. IDX_PRIMARY_TDM_TX_4,
  102. IDX_PRIMARY_TDM_TX_5,
  103. IDX_PRIMARY_TDM_TX_6,
  104. IDX_PRIMARY_TDM_TX_7,
  105. IDX_SECONDARY_TDM_RX_0,
  106. IDX_SECONDARY_TDM_RX_1,
  107. IDX_SECONDARY_TDM_RX_2,
  108. IDX_SECONDARY_TDM_RX_3,
  109. IDX_SECONDARY_TDM_RX_4,
  110. IDX_SECONDARY_TDM_RX_5,
  111. IDX_SECONDARY_TDM_RX_6,
  112. IDX_SECONDARY_TDM_RX_7,
  113. IDX_SECONDARY_TDM_TX_0,
  114. IDX_SECONDARY_TDM_TX_1,
  115. IDX_SECONDARY_TDM_TX_2,
  116. IDX_SECONDARY_TDM_TX_3,
  117. IDX_SECONDARY_TDM_TX_4,
  118. IDX_SECONDARY_TDM_TX_5,
  119. IDX_SECONDARY_TDM_TX_6,
  120. IDX_SECONDARY_TDM_TX_7,
  121. IDX_TERTIARY_TDM_RX_0,
  122. IDX_TERTIARY_TDM_RX_1,
  123. IDX_TERTIARY_TDM_RX_2,
  124. IDX_TERTIARY_TDM_RX_3,
  125. IDX_TERTIARY_TDM_RX_4,
  126. IDX_TERTIARY_TDM_RX_5,
  127. IDX_TERTIARY_TDM_RX_6,
  128. IDX_TERTIARY_TDM_RX_7,
  129. IDX_TERTIARY_TDM_TX_0,
  130. IDX_TERTIARY_TDM_TX_1,
  131. IDX_TERTIARY_TDM_TX_2,
  132. IDX_TERTIARY_TDM_TX_3,
  133. IDX_TERTIARY_TDM_TX_4,
  134. IDX_TERTIARY_TDM_TX_5,
  135. IDX_TERTIARY_TDM_TX_6,
  136. IDX_TERTIARY_TDM_TX_7,
  137. IDX_QUATERNARY_TDM_RX_0,
  138. IDX_QUATERNARY_TDM_RX_1,
  139. IDX_QUATERNARY_TDM_RX_2,
  140. IDX_QUATERNARY_TDM_RX_3,
  141. IDX_QUATERNARY_TDM_RX_4,
  142. IDX_QUATERNARY_TDM_RX_5,
  143. IDX_QUATERNARY_TDM_RX_6,
  144. IDX_QUATERNARY_TDM_RX_7,
  145. IDX_QUATERNARY_TDM_TX_0,
  146. IDX_QUATERNARY_TDM_TX_1,
  147. IDX_QUATERNARY_TDM_TX_2,
  148. IDX_QUATERNARY_TDM_TX_3,
  149. IDX_QUATERNARY_TDM_TX_4,
  150. IDX_QUATERNARY_TDM_TX_5,
  151. IDX_QUATERNARY_TDM_TX_6,
  152. IDX_QUATERNARY_TDM_TX_7,
  153. IDX_QUINARY_TDM_RX_0,
  154. IDX_QUINARY_TDM_RX_1,
  155. IDX_QUINARY_TDM_RX_2,
  156. IDX_QUINARY_TDM_RX_3,
  157. IDX_QUINARY_TDM_RX_4,
  158. IDX_QUINARY_TDM_RX_5,
  159. IDX_QUINARY_TDM_RX_6,
  160. IDX_QUINARY_TDM_RX_7,
  161. IDX_QUINARY_TDM_TX_0,
  162. IDX_QUINARY_TDM_TX_1,
  163. IDX_QUINARY_TDM_TX_2,
  164. IDX_QUINARY_TDM_TX_3,
  165. IDX_QUINARY_TDM_TX_4,
  166. IDX_QUINARY_TDM_TX_5,
  167. IDX_QUINARY_TDM_TX_6,
  168. IDX_QUINARY_TDM_TX_7,
  169. IDX_TDM_MAX,
  170. };
  171. enum {
  172. IDX_GROUP_PRIMARY_TDM_RX,
  173. IDX_GROUP_PRIMARY_TDM_TX,
  174. IDX_GROUP_SECONDARY_TDM_RX,
  175. IDX_GROUP_SECONDARY_TDM_TX,
  176. IDX_GROUP_TERTIARY_TDM_RX,
  177. IDX_GROUP_TERTIARY_TDM_TX,
  178. IDX_GROUP_QUATERNARY_TDM_RX,
  179. IDX_GROUP_QUATERNARY_TDM_TX,
  180. IDX_GROUP_QUINARY_TDM_RX,
  181. IDX_GROUP_QUINARY_TDM_TX,
  182. IDX_GROUP_TDM_MAX,
  183. };
  184. struct msm_dai_q6_dai_data {
  185. DECLARE_BITMAP(status_mask, STATUS_MAX);
  186. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  187. u32 rate;
  188. u32 channels;
  189. u32 bitwidth;
  190. u32 cal_mode;
  191. u32 afe_in_channels;
  192. u16 afe_in_bitformat;
  193. struct afe_enc_config enc_config;
  194. struct afe_dec_config dec_config;
  195. union afe_port_config port_config;
  196. u16 vi_feed_mono;
  197. };
  198. struct msm_dai_q6_spdif_dai_data {
  199. DECLARE_BITMAP(status_mask, STATUS_MAX);
  200. u32 rate;
  201. u32 channels;
  202. u32 bitwidth;
  203. u16 port_id;
  204. struct afe_spdif_port_config spdif_port;
  205. struct afe_event_fmt_update fmt_event;
  206. };
  207. struct msm_dai_q6_spdif_event_msg {
  208. struct afe_port_mod_evt_rsp_hdr evt_hdr;
  209. struct afe_event_fmt_update fmt_event;
  210. };
  211. struct msm_dai_q6_mi2s_dai_config {
  212. u16 pdata_mi2s_lines;
  213. struct msm_dai_q6_dai_data mi2s_dai_data;
  214. };
  215. struct msm_dai_q6_mi2s_dai_data {
  216. u32 is_island_dai;
  217. struct msm_dai_q6_mi2s_dai_config tx_dai;
  218. struct msm_dai_q6_mi2s_dai_config rx_dai;
  219. };
  220. struct msm_dai_q6_cdc_dma_dai_data {
  221. DECLARE_BITMAP(status_mask, STATUS_MAX);
  222. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  223. u32 rate;
  224. u32 channels;
  225. u32 bitwidth;
  226. u32 is_island_dai;
  227. union afe_port_config port_config;
  228. };
  229. struct msm_dai_q6_auxpcm_dai_data {
  230. /* BITMAP to track Rx and Tx port usage count */
  231. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  232. struct mutex rlock; /* auxpcm dev resource lock */
  233. u16 rx_pid; /* AUXPCM RX AFE port ID */
  234. u16 tx_pid; /* AUXPCM TX AFE port ID */
  235. u16 afe_clk_ver;
  236. u32 is_island_dai;
  237. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  238. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  239. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  240. };
  241. struct msm_dai_q6_tdm_dai_data {
  242. DECLARE_BITMAP(status_mask, STATUS_MAX);
  243. u32 rate;
  244. u32 channels;
  245. u32 bitwidth;
  246. u32 num_group_ports;
  247. u32 is_island_dai;
  248. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  249. union afe_port_group_config group_cfg; /* hold tdm group config */
  250. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  251. };
  252. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  253. * 0: linear PCM
  254. * 1: non-linear PCM
  255. * 2: PCM data in IEC 60968 container
  256. * 3: compressed data in IEC 60958 container
  257. */
  258. static const char *const mi2s_format[] = {
  259. "LPCM",
  260. "Compr",
  261. "LPCM-60958",
  262. "Compr-60958"
  263. };
  264. static const char *const mi2s_vi_feed_mono[] = {
  265. "Left",
  266. "Right",
  267. };
  268. static const struct soc_enum mi2s_config_enum[] = {
  269. SOC_ENUM_SINGLE_EXT(4, mi2s_format),
  270. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  271. };
  272. static const char *const cdc_dma_format[] = {
  273. "UNPACKED",
  274. "PACKED_16B",
  275. };
  276. static const struct soc_enum cdc_dma_config_enum[] = {
  277. SOC_ENUM_SINGLE_EXT(2, cdc_dma_format),
  278. };
  279. static const char *const sb_format[] = {
  280. "UNPACKED",
  281. "PACKED_16B",
  282. "DSD_DOP",
  283. };
  284. static const struct soc_enum sb_config_enum[] = {
  285. SOC_ENUM_SINGLE_EXT(3, sb_format),
  286. };
  287. static const char *const tdm_data_format[] = {
  288. "LPCM",
  289. "Compr",
  290. "Gen Compr"
  291. };
  292. static const char *const tdm_header_type[] = {
  293. "Invalid",
  294. "Default",
  295. "Entertainment",
  296. };
  297. static const struct soc_enum tdm_config_enum[] = {
  298. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  299. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  300. };
  301. static DEFINE_MUTEX(tdm_mutex);
  302. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  303. /* cache of group cfg per parent node */
  304. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  305. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  306. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  307. 0,
  308. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  309. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  310. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  311. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  312. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  313. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  314. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  315. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  316. 8,
  317. 48000,
  318. 32,
  319. 8,
  320. 32,
  321. 0xFF,
  322. };
  323. static u32 num_tdm_group_ports;
  324. static struct afe_clk_set tdm_clk_set = {
  325. AFE_API_VERSION_CLOCK_SET,
  326. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  327. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  328. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  329. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  330. 0,
  331. };
  332. int msm_dai_q6_get_group_idx(u16 id)
  333. {
  334. switch (id) {
  335. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  336. case AFE_PORT_ID_PRIMARY_TDM_RX:
  337. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  338. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  339. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  340. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  341. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  342. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  343. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  344. return IDX_GROUP_PRIMARY_TDM_RX;
  345. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  346. case AFE_PORT_ID_PRIMARY_TDM_TX:
  347. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  348. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  349. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  350. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  351. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  352. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  353. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  354. return IDX_GROUP_PRIMARY_TDM_TX;
  355. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  356. case AFE_PORT_ID_SECONDARY_TDM_RX:
  357. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  358. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  359. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  360. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  361. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  362. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  363. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  364. return IDX_GROUP_SECONDARY_TDM_RX;
  365. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  366. case AFE_PORT_ID_SECONDARY_TDM_TX:
  367. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  368. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  369. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  370. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  371. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  372. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  373. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  374. return IDX_GROUP_SECONDARY_TDM_TX;
  375. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  376. case AFE_PORT_ID_TERTIARY_TDM_RX:
  377. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  378. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  379. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  380. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  381. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  382. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  383. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  384. return IDX_GROUP_TERTIARY_TDM_RX;
  385. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  386. case AFE_PORT_ID_TERTIARY_TDM_TX:
  387. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  388. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  389. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  390. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  391. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  392. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  393. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  394. return IDX_GROUP_TERTIARY_TDM_TX;
  395. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  396. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  397. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  398. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  399. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  400. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  401. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  402. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  403. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  404. return IDX_GROUP_QUATERNARY_TDM_RX;
  405. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  406. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  407. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  408. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  409. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  410. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  411. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  412. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  413. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  414. return IDX_GROUP_QUATERNARY_TDM_TX;
  415. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  416. case AFE_PORT_ID_QUINARY_TDM_RX:
  417. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  418. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  419. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  420. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  421. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  422. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  423. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  424. return IDX_GROUP_QUINARY_TDM_RX;
  425. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  426. case AFE_PORT_ID_QUINARY_TDM_TX:
  427. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  428. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  429. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  430. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  431. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  432. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  433. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  434. return IDX_GROUP_QUINARY_TDM_TX;
  435. default: return -EINVAL;
  436. }
  437. }
  438. int msm_dai_q6_get_port_idx(u16 id)
  439. {
  440. switch (id) {
  441. case AFE_PORT_ID_PRIMARY_TDM_RX:
  442. return IDX_PRIMARY_TDM_RX_0;
  443. case AFE_PORT_ID_PRIMARY_TDM_TX:
  444. return IDX_PRIMARY_TDM_TX_0;
  445. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  446. return IDX_PRIMARY_TDM_RX_1;
  447. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  448. return IDX_PRIMARY_TDM_TX_1;
  449. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  450. return IDX_PRIMARY_TDM_RX_2;
  451. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  452. return IDX_PRIMARY_TDM_TX_2;
  453. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  454. return IDX_PRIMARY_TDM_RX_3;
  455. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  456. return IDX_PRIMARY_TDM_TX_3;
  457. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  458. return IDX_PRIMARY_TDM_RX_4;
  459. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  460. return IDX_PRIMARY_TDM_TX_4;
  461. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  462. return IDX_PRIMARY_TDM_RX_5;
  463. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  464. return IDX_PRIMARY_TDM_TX_5;
  465. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  466. return IDX_PRIMARY_TDM_RX_6;
  467. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  468. return IDX_PRIMARY_TDM_TX_6;
  469. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  470. return IDX_PRIMARY_TDM_RX_7;
  471. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  472. return IDX_PRIMARY_TDM_TX_7;
  473. case AFE_PORT_ID_SECONDARY_TDM_RX:
  474. return IDX_SECONDARY_TDM_RX_0;
  475. case AFE_PORT_ID_SECONDARY_TDM_TX:
  476. return IDX_SECONDARY_TDM_TX_0;
  477. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  478. return IDX_SECONDARY_TDM_RX_1;
  479. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  480. return IDX_SECONDARY_TDM_TX_1;
  481. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  482. return IDX_SECONDARY_TDM_RX_2;
  483. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  484. return IDX_SECONDARY_TDM_TX_2;
  485. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  486. return IDX_SECONDARY_TDM_RX_3;
  487. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  488. return IDX_SECONDARY_TDM_TX_3;
  489. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  490. return IDX_SECONDARY_TDM_RX_4;
  491. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  492. return IDX_SECONDARY_TDM_TX_4;
  493. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  494. return IDX_SECONDARY_TDM_RX_5;
  495. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  496. return IDX_SECONDARY_TDM_TX_5;
  497. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  498. return IDX_SECONDARY_TDM_RX_6;
  499. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  500. return IDX_SECONDARY_TDM_TX_6;
  501. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  502. return IDX_SECONDARY_TDM_RX_7;
  503. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  504. return IDX_SECONDARY_TDM_TX_7;
  505. case AFE_PORT_ID_TERTIARY_TDM_RX:
  506. return IDX_TERTIARY_TDM_RX_0;
  507. case AFE_PORT_ID_TERTIARY_TDM_TX:
  508. return IDX_TERTIARY_TDM_TX_0;
  509. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  510. return IDX_TERTIARY_TDM_RX_1;
  511. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  512. return IDX_TERTIARY_TDM_TX_1;
  513. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  514. return IDX_TERTIARY_TDM_RX_2;
  515. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  516. return IDX_TERTIARY_TDM_TX_2;
  517. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  518. return IDX_TERTIARY_TDM_RX_3;
  519. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  520. return IDX_TERTIARY_TDM_TX_3;
  521. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  522. return IDX_TERTIARY_TDM_RX_4;
  523. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  524. return IDX_TERTIARY_TDM_TX_4;
  525. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  526. return IDX_TERTIARY_TDM_RX_5;
  527. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  528. return IDX_TERTIARY_TDM_TX_5;
  529. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  530. return IDX_TERTIARY_TDM_RX_6;
  531. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  532. return IDX_TERTIARY_TDM_TX_6;
  533. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  534. return IDX_TERTIARY_TDM_RX_7;
  535. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  536. return IDX_TERTIARY_TDM_TX_7;
  537. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  538. return IDX_QUATERNARY_TDM_RX_0;
  539. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  540. return IDX_QUATERNARY_TDM_TX_0;
  541. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  542. return IDX_QUATERNARY_TDM_RX_1;
  543. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  544. return IDX_QUATERNARY_TDM_TX_1;
  545. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  546. return IDX_QUATERNARY_TDM_RX_2;
  547. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  548. return IDX_QUATERNARY_TDM_TX_2;
  549. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  550. return IDX_QUATERNARY_TDM_RX_3;
  551. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  552. return IDX_QUATERNARY_TDM_TX_3;
  553. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  554. return IDX_QUATERNARY_TDM_RX_4;
  555. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  556. return IDX_QUATERNARY_TDM_TX_4;
  557. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  558. return IDX_QUATERNARY_TDM_RX_5;
  559. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  560. return IDX_QUATERNARY_TDM_TX_5;
  561. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  562. return IDX_QUATERNARY_TDM_RX_6;
  563. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  564. return IDX_QUATERNARY_TDM_TX_6;
  565. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  566. return IDX_QUATERNARY_TDM_RX_7;
  567. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  568. return IDX_QUATERNARY_TDM_TX_7;
  569. case AFE_PORT_ID_QUINARY_TDM_RX:
  570. return IDX_QUINARY_TDM_RX_0;
  571. case AFE_PORT_ID_QUINARY_TDM_TX:
  572. return IDX_QUINARY_TDM_TX_0;
  573. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  574. return IDX_QUINARY_TDM_RX_1;
  575. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  576. return IDX_QUINARY_TDM_TX_1;
  577. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  578. return IDX_QUINARY_TDM_RX_2;
  579. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  580. return IDX_QUINARY_TDM_TX_2;
  581. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  582. return IDX_QUINARY_TDM_RX_3;
  583. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  584. return IDX_QUINARY_TDM_TX_3;
  585. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  586. return IDX_QUINARY_TDM_RX_4;
  587. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  588. return IDX_QUINARY_TDM_TX_4;
  589. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  590. return IDX_QUINARY_TDM_RX_5;
  591. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  592. return IDX_QUINARY_TDM_TX_5;
  593. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  594. return IDX_QUINARY_TDM_RX_6;
  595. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  596. return IDX_QUINARY_TDM_TX_6;
  597. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  598. return IDX_QUINARY_TDM_RX_7;
  599. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  600. return IDX_QUINARY_TDM_TX_7;
  601. default: return -EINVAL;
  602. }
  603. }
  604. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  605. {
  606. /* Max num of slots is bits per frame divided
  607. * by bits per sample which is 16
  608. */
  609. switch (frame_rate) {
  610. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  611. return 0;
  612. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  613. return 1;
  614. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  615. return 2;
  616. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  617. return 4;
  618. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  619. return 8;
  620. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  621. return 16;
  622. default:
  623. pr_err("%s Invalid bits per frame %d\n",
  624. __func__, frame_rate);
  625. return 0;
  626. }
  627. }
  628. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  629. {
  630. struct snd_soc_dapm_route intercon;
  631. struct snd_soc_dapm_context *dapm;
  632. if (!dai) {
  633. pr_err("%s: Invalid params dai\n", __func__);
  634. return -EINVAL;
  635. }
  636. if (!dai->driver) {
  637. pr_err("%s: Invalid params dai driver\n", __func__);
  638. return -EINVAL;
  639. }
  640. dapm = snd_soc_component_get_dapm(dai->component);
  641. memset(&intercon, 0, sizeof(intercon));
  642. if (dai->driver->playback.stream_name &&
  643. dai->driver->playback.aif_name) {
  644. dev_dbg(dai->dev, "%s: add route for widget %s",
  645. __func__, dai->driver->playback.stream_name);
  646. intercon.source = dai->driver->playback.aif_name;
  647. intercon.sink = dai->driver->playback.stream_name;
  648. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  649. __func__, intercon.source, intercon.sink);
  650. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  651. }
  652. if (dai->driver->capture.stream_name &&
  653. dai->driver->capture.aif_name) {
  654. dev_dbg(dai->dev, "%s: add route for widget %s",
  655. __func__, dai->driver->capture.stream_name);
  656. intercon.sink = dai->driver->capture.aif_name;
  657. intercon.source = dai->driver->capture.stream_name;
  658. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  659. __func__, intercon.source, intercon.sink);
  660. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  661. }
  662. return 0;
  663. }
  664. static int msm_dai_q6_auxpcm_hw_params(
  665. struct snd_pcm_substream *substream,
  666. struct snd_pcm_hw_params *params,
  667. struct snd_soc_dai *dai)
  668. {
  669. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  670. dev_get_drvdata(dai->dev);
  671. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  672. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  673. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  674. int rc = 0, slot_mapping_copy_len = 0;
  675. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  676. params_rate(params) != 16000)) {
  677. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  678. __func__, params_channels(params), params_rate(params));
  679. return -EINVAL;
  680. }
  681. mutex_lock(&aux_dai_data->rlock);
  682. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  683. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  684. /* AUXPCM DAI in use */
  685. if (dai_data->rate != params_rate(params)) {
  686. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  687. __func__);
  688. rc = -EINVAL;
  689. }
  690. mutex_unlock(&aux_dai_data->rlock);
  691. return rc;
  692. }
  693. dai_data->channels = params_channels(params);
  694. dai_data->rate = params_rate(params);
  695. if (dai_data->rate == 8000) {
  696. dai_data->port_config.pcm.pcm_cfg_minor_version =
  697. AFE_API_VERSION_PCM_CONFIG;
  698. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  699. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  700. dai_data->port_config.pcm.frame_setting =
  701. auxpcm_pdata->mode_8k.frame;
  702. dai_data->port_config.pcm.quantype =
  703. auxpcm_pdata->mode_8k.quant;
  704. dai_data->port_config.pcm.ctrl_data_out_enable =
  705. auxpcm_pdata->mode_8k.data;
  706. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  707. dai_data->port_config.pcm.num_channels = dai_data->channels;
  708. dai_data->port_config.pcm.bit_width = 16;
  709. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  710. auxpcm_pdata->mode_8k.num_slots)
  711. slot_mapping_copy_len =
  712. ARRAY_SIZE(
  713. dai_data->port_config.pcm.slot_number_mapping)
  714. * sizeof(uint16_t);
  715. else
  716. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  717. * sizeof(uint16_t);
  718. if (auxpcm_pdata->mode_8k.slot_mapping) {
  719. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  720. auxpcm_pdata->mode_8k.slot_mapping,
  721. slot_mapping_copy_len);
  722. } else {
  723. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  724. __func__);
  725. mutex_unlock(&aux_dai_data->rlock);
  726. return -EINVAL;
  727. }
  728. } else {
  729. dai_data->port_config.pcm.pcm_cfg_minor_version =
  730. AFE_API_VERSION_PCM_CONFIG;
  731. dai_data->port_config.pcm.aux_mode =
  732. auxpcm_pdata->mode_16k.mode;
  733. dai_data->port_config.pcm.sync_src =
  734. auxpcm_pdata->mode_16k.sync;
  735. dai_data->port_config.pcm.frame_setting =
  736. auxpcm_pdata->mode_16k.frame;
  737. dai_data->port_config.pcm.quantype =
  738. auxpcm_pdata->mode_16k.quant;
  739. dai_data->port_config.pcm.ctrl_data_out_enable =
  740. auxpcm_pdata->mode_16k.data;
  741. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  742. dai_data->port_config.pcm.num_channels = dai_data->channels;
  743. dai_data->port_config.pcm.bit_width = 16;
  744. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  745. auxpcm_pdata->mode_16k.num_slots)
  746. slot_mapping_copy_len =
  747. ARRAY_SIZE(
  748. dai_data->port_config.pcm.slot_number_mapping)
  749. * sizeof(uint16_t);
  750. else
  751. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  752. * sizeof(uint16_t);
  753. if (auxpcm_pdata->mode_16k.slot_mapping) {
  754. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  755. auxpcm_pdata->mode_16k.slot_mapping,
  756. slot_mapping_copy_len);
  757. } else {
  758. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  759. __func__);
  760. mutex_unlock(&aux_dai_data->rlock);
  761. return -EINVAL;
  762. }
  763. }
  764. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  765. __func__, dai_data->port_config.pcm.aux_mode,
  766. dai_data->port_config.pcm.sync_src,
  767. dai_data->port_config.pcm.frame_setting);
  768. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  769. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  770. __func__, dai_data->port_config.pcm.quantype,
  771. dai_data->port_config.pcm.ctrl_data_out_enable,
  772. dai_data->port_config.pcm.slot_number_mapping[0],
  773. dai_data->port_config.pcm.slot_number_mapping[1],
  774. dai_data->port_config.pcm.slot_number_mapping[2],
  775. dai_data->port_config.pcm.slot_number_mapping[3]);
  776. mutex_unlock(&aux_dai_data->rlock);
  777. return rc;
  778. }
  779. static int msm_dai_q6_auxpcm_set_clk(
  780. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  781. u16 port_id, bool enable)
  782. {
  783. int rc;
  784. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  785. aux_dai_data->afe_clk_ver, port_id, enable);
  786. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  787. aux_dai_data->clk_set.enable = enable;
  788. rc = afe_set_lpass_clock_v2(port_id,
  789. &aux_dai_data->clk_set);
  790. } else {
  791. if (!enable)
  792. aux_dai_data->clk_cfg.clk_val1 = 0;
  793. rc = afe_set_lpass_clock(port_id,
  794. &aux_dai_data->clk_cfg);
  795. }
  796. return rc;
  797. }
  798. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  799. struct snd_soc_dai *dai)
  800. {
  801. int rc = 0;
  802. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  803. dev_get_drvdata(dai->dev);
  804. mutex_lock(&aux_dai_data->rlock);
  805. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  806. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  807. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  808. __func__, dai->id);
  809. goto exit;
  810. }
  811. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  812. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  813. clear_bit(STATUS_TX_PORT,
  814. aux_dai_data->auxpcm_port_status);
  815. else {
  816. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  817. __func__);
  818. goto exit;
  819. }
  820. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  821. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  822. clear_bit(STATUS_RX_PORT,
  823. aux_dai_data->auxpcm_port_status);
  824. else {
  825. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  826. __func__);
  827. goto exit;
  828. }
  829. }
  830. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  831. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  832. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  833. __func__);
  834. goto exit;
  835. }
  836. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  837. __func__, dai->id);
  838. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  839. if (rc < 0)
  840. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  841. rc = afe_close(aux_dai_data->tx_pid);
  842. if (rc < 0)
  843. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  844. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  845. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  846. exit:
  847. mutex_unlock(&aux_dai_data->rlock);
  848. }
  849. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  850. struct snd_soc_dai *dai)
  851. {
  852. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  853. dev_get_drvdata(dai->dev);
  854. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  855. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  856. int rc = 0;
  857. u32 pcm_clk_rate;
  858. auxpcm_pdata = dai->dev->platform_data;
  859. mutex_lock(&aux_dai_data->rlock);
  860. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  861. if (test_bit(STATUS_TX_PORT,
  862. aux_dai_data->auxpcm_port_status)) {
  863. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  864. __func__);
  865. goto exit;
  866. } else
  867. set_bit(STATUS_TX_PORT,
  868. aux_dai_data->auxpcm_port_status);
  869. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  870. if (test_bit(STATUS_RX_PORT,
  871. aux_dai_data->auxpcm_port_status)) {
  872. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  873. __func__);
  874. goto exit;
  875. } else
  876. set_bit(STATUS_RX_PORT,
  877. aux_dai_data->auxpcm_port_status);
  878. }
  879. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  880. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  881. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  882. goto exit;
  883. }
  884. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  885. __func__, dai->id);
  886. rc = afe_q6_interface_prepare();
  887. if (rc < 0) {
  888. dev_err(dai->dev, "fail to open AFE APR\n");
  889. goto fail;
  890. }
  891. /*
  892. * For AUX PCM Interface the below sequence of clk
  893. * settings and afe_open is a strict requirement.
  894. *
  895. * Also using afe_open instead of afe_port_start_nowait
  896. * to make sure the port is open before deasserting the
  897. * clock line. This is required because pcm register is
  898. * not written before clock deassert. Hence the hw does
  899. * not get updated with new setting if the below clock
  900. * assert/deasset and afe_open sequence is not followed.
  901. */
  902. if (dai_data->rate == 8000) {
  903. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  904. } else if (dai_data->rate == 16000) {
  905. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  906. } else {
  907. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  908. dai_data->rate);
  909. rc = -EINVAL;
  910. goto fail;
  911. }
  912. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  913. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  914. sizeof(struct afe_clk_set));
  915. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  916. switch (dai->id) {
  917. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  918. if (pcm_clk_rate)
  919. aux_dai_data->clk_set.clk_id =
  920. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  921. else
  922. aux_dai_data->clk_set.clk_id =
  923. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  924. break;
  925. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  926. if (pcm_clk_rate)
  927. aux_dai_data->clk_set.clk_id =
  928. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  929. else
  930. aux_dai_data->clk_set.clk_id =
  931. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  932. break;
  933. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  934. if (pcm_clk_rate)
  935. aux_dai_data->clk_set.clk_id =
  936. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  937. else
  938. aux_dai_data->clk_set.clk_id =
  939. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  940. break;
  941. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  942. if (pcm_clk_rate)
  943. aux_dai_data->clk_set.clk_id =
  944. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  945. else
  946. aux_dai_data->clk_set.clk_id =
  947. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  948. break;
  949. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  950. if (pcm_clk_rate)
  951. aux_dai_data->clk_set.clk_id =
  952. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  953. else
  954. aux_dai_data->clk_set.clk_id =
  955. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  956. break;
  957. default:
  958. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  959. __func__, dai->id);
  960. break;
  961. }
  962. } else {
  963. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  964. sizeof(struct afe_clk_cfg));
  965. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  966. }
  967. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  968. aux_dai_data->rx_pid, true);
  969. if (rc < 0) {
  970. dev_err(dai->dev,
  971. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  972. __func__);
  973. goto fail;
  974. }
  975. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  976. aux_dai_data->tx_pid, true);
  977. if (rc < 0) {
  978. dev_err(dai->dev,
  979. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  980. __func__);
  981. goto fail;
  982. }
  983. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  984. if (q6core_get_avcs_api_version_per_service(
  985. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  986. /*
  987. * send island mode config
  988. * This should be the first configuration
  989. */
  990. rc = afe_send_port_island_mode(aux_dai_data->tx_pid);
  991. if (rc)
  992. dev_err(dai->dev, "%s: afe send island mode failed %d\n",
  993. __func__, rc);
  994. }
  995. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  996. goto exit;
  997. fail:
  998. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  999. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1000. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  1001. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1002. exit:
  1003. mutex_unlock(&aux_dai_data->rlock);
  1004. return rc;
  1005. }
  1006. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  1007. int cmd, struct snd_soc_dai *dai)
  1008. {
  1009. int rc = 0;
  1010. pr_debug("%s:port:%d cmd:%d\n",
  1011. __func__, dai->id, cmd);
  1012. switch (cmd) {
  1013. case SNDRV_PCM_TRIGGER_START:
  1014. case SNDRV_PCM_TRIGGER_RESUME:
  1015. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  1016. /* afe_open will be called from prepare */
  1017. return 0;
  1018. case SNDRV_PCM_TRIGGER_STOP:
  1019. case SNDRV_PCM_TRIGGER_SUSPEND:
  1020. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  1021. return 0;
  1022. default:
  1023. pr_err("%s: cmd %d\n", __func__, cmd);
  1024. rc = -EINVAL;
  1025. }
  1026. return rc;
  1027. }
  1028. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  1029. {
  1030. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  1031. int rc;
  1032. aux_dai_data = dev_get_drvdata(dai->dev);
  1033. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  1034. __func__, dai->id);
  1035. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  1036. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1037. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  1038. if (rc < 0)
  1039. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  1040. rc = afe_close(aux_dai_data->tx_pid);
  1041. if (rc < 0)
  1042. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1043. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1044. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1045. }
  1046. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1047. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1048. return 0;
  1049. }
  1050. static int msm_dai_q6_island_mode_put(struct snd_kcontrol *kcontrol,
  1051. struct snd_ctl_elem_value *ucontrol)
  1052. {
  1053. int value = ucontrol->value.integer.value[0];
  1054. u16 port_id = (u16)kcontrol->private_value;
  1055. pr_debug("%s: island mode = %d\n", __func__, value);
  1056. afe_set_island_mode_cfg(port_id, value);
  1057. return 0;
  1058. }
  1059. static int msm_dai_q6_island_mode_get(struct snd_kcontrol *kcontrol,
  1060. struct snd_ctl_elem_value *ucontrol)
  1061. {
  1062. int value;
  1063. u16 port_id = (u16)kcontrol->private_value;
  1064. afe_get_island_mode_cfg(port_id, &value);
  1065. ucontrol->value.integer.value[0] = value;
  1066. return 0;
  1067. }
  1068. static void island_mx_ctl_private_free(struct snd_kcontrol *kcontrol)
  1069. {
  1070. struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol);
  1071. kfree(knew);
  1072. }
  1073. static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card,
  1074. const char *dai_name,
  1075. int dai_id, void *dai_data)
  1076. {
  1077. const char *mx_ctl_name = "TX island";
  1078. char *mixer_str = NULL;
  1079. int dai_str_len = 0, ctl_len = 0;
  1080. int rc = 0;
  1081. struct snd_kcontrol_new *knew = NULL;
  1082. struct snd_kcontrol *kctl = NULL;
  1083. dai_str_len = strlen(dai_name) + 1;
  1084. /* Add island related mixer controls */
  1085. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1086. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1087. if (!mixer_str)
  1088. return -ENOMEM;
  1089. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1090. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1091. if (!knew) {
  1092. kfree(mixer_str);
  1093. return -ENOMEM;
  1094. }
  1095. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1096. knew->info = snd_ctl_boolean_mono_info;
  1097. knew->get = msm_dai_q6_island_mode_get;
  1098. knew->put = msm_dai_q6_island_mode_put;
  1099. knew->name = mixer_str;
  1100. knew->private_value = dai_id;
  1101. kctl = snd_ctl_new1(knew, knew);
  1102. if (!kctl) {
  1103. kfree(knew);
  1104. kfree(mixer_str);
  1105. return -ENOMEM;
  1106. }
  1107. kctl->private_free = island_mx_ctl_private_free;
  1108. rc = snd_ctl_add(card, kctl);
  1109. if (rc < 0)
  1110. pr_err("%s: err add config ctl, DAI = %s\n",
  1111. __func__, dai_name);
  1112. kfree(mixer_str);
  1113. return rc;
  1114. }
  1115. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1116. {
  1117. int rc = 0;
  1118. struct msm_dai_q6_auxpcm_dai_data *dai_data = NULL;
  1119. if (!dai) {
  1120. pr_err("%s: Invalid params dai\n", __func__);
  1121. return -EINVAL;
  1122. }
  1123. if (!dai->dev) {
  1124. pr_err("%s: Invalid params dai dev\n", __func__);
  1125. return -EINVAL;
  1126. }
  1127. if (!dai->driver->id) {
  1128. dev_warn(dai->dev, "DAI driver id is not set\n");
  1129. return -EINVAL;
  1130. }
  1131. dai->id = dai->driver->id;
  1132. dai_data = dev_get_drvdata(dai->dev);
  1133. if (dai_data->is_island_dai)
  1134. rc = msm_dai_q6_add_island_mx_ctls(
  1135. dai->component->card->snd_card,
  1136. dai->name, dai_data->tx_pid,
  1137. (void *)dai_data);
  1138. rc = msm_dai_q6_dai_add_route(dai);
  1139. return rc;
  1140. }
  1141. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1142. .prepare = msm_dai_q6_auxpcm_prepare,
  1143. .trigger = msm_dai_q6_auxpcm_trigger,
  1144. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1145. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1146. };
  1147. static const struct snd_soc_component_driver
  1148. msm_dai_q6_aux_pcm_dai_component = {
  1149. .name = "msm-auxpcm-dev",
  1150. };
  1151. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1152. {
  1153. .playback = {
  1154. .stream_name = "AUX PCM Playback",
  1155. .aif_name = "AUX_PCM_RX",
  1156. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1157. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1158. .channels_min = 1,
  1159. .channels_max = 1,
  1160. .rate_max = 16000,
  1161. .rate_min = 8000,
  1162. },
  1163. .capture = {
  1164. .stream_name = "AUX PCM Capture",
  1165. .aif_name = "AUX_PCM_TX",
  1166. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1167. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1168. .channels_min = 1,
  1169. .channels_max = 1,
  1170. .rate_max = 16000,
  1171. .rate_min = 8000,
  1172. },
  1173. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1174. .name = "Pri AUX PCM",
  1175. .ops = &msm_dai_q6_auxpcm_ops,
  1176. .probe = msm_dai_q6_aux_pcm_probe,
  1177. .remove = msm_dai_q6_dai_auxpcm_remove,
  1178. },
  1179. {
  1180. .playback = {
  1181. .stream_name = "Sec AUX PCM Playback",
  1182. .aif_name = "SEC_AUX_PCM_RX",
  1183. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1184. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1185. .channels_min = 1,
  1186. .channels_max = 1,
  1187. .rate_max = 16000,
  1188. .rate_min = 8000,
  1189. },
  1190. .capture = {
  1191. .stream_name = "Sec AUX PCM Capture",
  1192. .aif_name = "SEC_AUX_PCM_TX",
  1193. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1194. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1195. .channels_min = 1,
  1196. .channels_max = 1,
  1197. .rate_max = 16000,
  1198. .rate_min = 8000,
  1199. },
  1200. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1201. .name = "Sec AUX PCM",
  1202. .ops = &msm_dai_q6_auxpcm_ops,
  1203. .probe = msm_dai_q6_aux_pcm_probe,
  1204. .remove = msm_dai_q6_dai_auxpcm_remove,
  1205. },
  1206. {
  1207. .playback = {
  1208. .stream_name = "Tert AUX PCM Playback",
  1209. .aif_name = "TERT_AUX_PCM_RX",
  1210. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1211. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1212. .channels_min = 1,
  1213. .channels_max = 1,
  1214. .rate_max = 16000,
  1215. .rate_min = 8000,
  1216. },
  1217. .capture = {
  1218. .stream_name = "Tert AUX PCM Capture",
  1219. .aif_name = "TERT_AUX_PCM_TX",
  1220. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1221. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1222. .channels_min = 1,
  1223. .channels_max = 1,
  1224. .rate_max = 16000,
  1225. .rate_min = 8000,
  1226. },
  1227. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1228. .name = "Tert AUX PCM",
  1229. .ops = &msm_dai_q6_auxpcm_ops,
  1230. .probe = msm_dai_q6_aux_pcm_probe,
  1231. .remove = msm_dai_q6_dai_auxpcm_remove,
  1232. },
  1233. {
  1234. .playback = {
  1235. .stream_name = "Quat AUX PCM Playback",
  1236. .aif_name = "QUAT_AUX_PCM_RX",
  1237. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1238. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1239. .channels_min = 1,
  1240. .channels_max = 1,
  1241. .rate_max = 16000,
  1242. .rate_min = 8000,
  1243. },
  1244. .capture = {
  1245. .stream_name = "Quat AUX PCM Capture",
  1246. .aif_name = "QUAT_AUX_PCM_TX",
  1247. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1248. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1249. .channels_min = 1,
  1250. .channels_max = 1,
  1251. .rate_max = 16000,
  1252. .rate_min = 8000,
  1253. },
  1254. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1255. .name = "Quat AUX PCM",
  1256. .ops = &msm_dai_q6_auxpcm_ops,
  1257. .probe = msm_dai_q6_aux_pcm_probe,
  1258. .remove = msm_dai_q6_dai_auxpcm_remove,
  1259. },
  1260. {
  1261. .playback = {
  1262. .stream_name = "Quin AUX PCM Playback",
  1263. .aif_name = "QUIN_AUX_PCM_RX",
  1264. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1265. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1266. .channels_min = 1,
  1267. .channels_max = 1,
  1268. .rate_max = 16000,
  1269. .rate_min = 8000,
  1270. },
  1271. .capture = {
  1272. .stream_name = "Quin AUX PCM Capture",
  1273. .aif_name = "QUIN_AUX_PCM_TX",
  1274. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1275. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1276. .channels_min = 1,
  1277. .channels_max = 1,
  1278. .rate_max = 16000,
  1279. .rate_min = 8000,
  1280. },
  1281. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1282. .name = "Quin AUX PCM",
  1283. .ops = &msm_dai_q6_auxpcm_ops,
  1284. .probe = msm_dai_q6_aux_pcm_probe,
  1285. .remove = msm_dai_q6_dai_auxpcm_remove,
  1286. },
  1287. };
  1288. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1289. struct snd_ctl_elem_value *ucontrol)
  1290. {
  1291. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1292. int value = ucontrol->value.integer.value[0];
  1293. dai_data->spdif_port.cfg.data_format = value;
  1294. pr_debug("%s: value = %d\n", __func__, value);
  1295. return 0;
  1296. }
  1297. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1298. struct snd_ctl_elem_value *ucontrol)
  1299. {
  1300. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1301. ucontrol->value.integer.value[0] =
  1302. dai_data->spdif_port.cfg.data_format;
  1303. return 0;
  1304. }
  1305. static int msm_dai_q6_spdif_source_put(struct snd_kcontrol *kcontrol,
  1306. struct snd_ctl_elem_value *ucontrol)
  1307. {
  1308. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1309. int value = ucontrol->value.integer.value[0];
  1310. dai_data->spdif_port.cfg.src_sel = value;
  1311. pr_debug("%s: value = %d\n", __func__, value);
  1312. return 0;
  1313. }
  1314. static int msm_dai_q6_spdif_source_get(struct snd_kcontrol *kcontrol,
  1315. struct snd_ctl_elem_value *ucontrol)
  1316. {
  1317. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1318. ucontrol->value.integer.value[0] =
  1319. dai_data->spdif_port.cfg.src_sel;
  1320. return 0;
  1321. }
  1322. static int msm_dai_q6_spdif_ext_state_get(struct snd_kcontrol *kcontrol,
  1323. struct snd_ctl_elem_value *ucontrol)
  1324. {
  1325. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1326. ucontrol->value.integer.value[0] =
  1327. dai_data->fmt_event.status & 0x3;
  1328. return 0;
  1329. }
  1330. static int msm_dai_q6_spdif_ext_format_get(struct snd_kcontrol *kcontrol,
  1331. struct snd_ctl_elem_value *ucontrol)
  1332. {
  1333. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1334. ucontrol->value.integer.value[0] =
  1335. dai_data->fmt_event.data_format & 0x1;
  1336. return 0;
  1337. }
  1338. static int msm_dai_q6_spdif_ext_rate_get(struct snd_kcontrol *kcontrol,
  1339. struct snd_ctl_elem_value *ucontrol)
  1340. {
  1341. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1342. ucontrol->value.integer.value[0] =
  1343. dai_data->fmt_event.sample_rate;
  1344. return 0;
  1345. }
  1346. static const char * const spdif_format[] = {
  1347. "LPCM",
  1348. "Compr"
  1349. };
  1350. static const char * const spdif_source[] = {
  1351. "Optical", "EXT-ARC", "Coaxial", "VT-ARC"
  1352. };
  1353. static const char * const spdif_state[] = {
  1354. "Inactive", "Active", "EOS"
  1355. };
  1356. static const struct soc_enum spdif_rx_config_enum[] = {
  1357. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1358. };
  1359. static const struct soc_enum spdif_tx_config_enum[] = {
  1360. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_source), spdif_source),
  1361. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1362. };
  1363. static const struct soc_enum spdif_tx_status_enum[] = {
  1364. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_state), spdif_state),
  1365. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1366. };
  1367. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1368. struct snd_ctl_elem_value *ucontrol)
  1369. {
  1370. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1371. int ret = 0;
  1372. dai_data->spdif_port.ch_status.status_type =
  1373. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1374. memset(dai_data->spdif_port.ch_status.status_mask,
  1375. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1376. dai_data->spdif_port.ch_status.status_mask[0] =
  1377. CHANNEL_STATUS_MASK;
  1378. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1379. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1380. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1381. pr_debug("%s: Port already started. Dynamic update\n",
  1382. __func__);
  1383. ret = afe_send_spdif_ch_status_cfg(
  1384. &dai_data->spdif_port.ch_status,
  1385. dai_data->port_id);
  1386. }
  1387. return ret;
  1388. }
  1389. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1390. struct snd_ctl_elem_value *ucontrol)
  1391. {
  1392. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1393. memcpy(ucontrol->value.iec958.status,
  1394. dai_data->spdif_port.ch_status.status_bits,
  1395. CHANNEL_STATUS_SIZE);
  1396. return 0;
  1397. }
  1398. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1399. struct snd_ctl_elem_info *uinfo)
  1400. {
  1401. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1402. uinfo->count = 1;
  1403. return 0;
  1404. }
  1405. static const struct snd_kcontrol_new spdif_rx_config_controls[] = {
  1406. /* Primary SPDIF output */
  1407. {
  1408. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1409. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1410. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1411. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1412. .info = msm_dai_q6_spdif_chstatus_info,
  1413. .get = msm_dai_q6_spdif_chstatus_get,
  1414. .put = msm_dai_q6_spdif_chstatus_put,
  1415. },
  1416. SOC_ENUM_EXT("PRI SPDIF RX Format", spdif_rx_config_enum[0],
  1417. msm_dai_q6_spdif_format_get,
  1418. msm_dai_q6_spdif_format_put),
  1419. /* Secondary SPDIF output */
  1420. {
  1421. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1422. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1423. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1424. .name = SNDRV_CTL_NAME_IEC958("SEC", PLAYBACK, PCM_STREAM),
  1425. .info = msm_dai_q6_spdif_chstatus_info,
  1426. .get = msm_dai_q6_spdif_chstatus_get,
  1427. .put = msm_dai_q6_spdif_chstatus_put,
  1428. },
  1429. SOC_ENUM_EXT("SEC SPDIF RX Format", spdif_rx_config_enum[0],
  1430. msm_dai_q6_spdif_format_get,
  1431. msm_dai_q6_spdif_format_put)
  1432. };
  1433. static const struct snd_kcontrol_new spdif_tx_config_controls[] = {
  1434. SOC_ENUM_EXT("PRI SPDIF TX Source", spdif_tx_config_enum[0],
  1435. msm_dai_q6_spdif_source_get,
  1436. msm_dai_q6_spdif_source_put),
  1437. SOC_ENUM_EXT("PRI SPDIF TX Format", spdif_tx_config_enum[1],
  1438. msm_dai_q6_spdif_format_get,
  1439. msm_dai_q6_spdif_format_put),
  1440. SOC_ENUM_EXT("SEC SPDIF TX Source", spdif_tx_config_enum[0],
  1441. msm_dai_q6_spdif_source_get,
  1442. msm_dai_q6_spdif_source_put),
  1443. SOC_ENUM_EXT("SEC SPDIF TX Format", spdif_tx_config_enum[1],
  1444. msm_dai_q6_spdif_format_get,
  1445. msm_dai_q6_spdif_format_put)
  1446. };
  1447. static const struct snd_kcontrol_new spdif_tx_status_controls[] = {
  1448. SOC_ENUM_EXT("PRI SPDIF TX EXT State", spdif_tx_status_enum[0],
  1449. msm_dai_q6_spdif_ext_state_get, NULL),
  1450. SOC_ENUM_EXT("PRI SPDIF TX EXT Format", spdif_tx_status_enum[1],
  1451. msm_dai_q6_spdif_ext_format_get, NULL),
  1452. SOC_SINGLE_EXT("PRI SPDIF TX EXT Rate", 0, 0, 192000, 0,
  1453. msm_dai_q6_spdif_ext_rate_get, NULL),
  1454. SOC_ENUM_EXT("SEC SPDIF TX EXT State", spdif_tx_status_enum[0],
  1455. msm_dai_q6_spdif_ext_state_get, NULL),
  1456. SOC_ENUM_EXT("SEC SPDIF TX EXT Format", spdif_tx_status_enum[1],
  1457. msm_dai_q6_spdif_ext_format_get, NULL),
  1458. SOC_SINGLE_EXT("SEC SPDIF TX EXT Rate", 0, 0, 192000, 0,
  1459. msm_dai_q6_spdif_ext_rate_get, NULL)
  1460. };
  1461. static void msm_dai_q6_spdif_process_event(uint32_t opcode, uint32_t token,
  1462. uint32_t *payload, void *private_data)
  1463. {
  1464. struct msm_dai_q6_spdif_event_msg *evt;
  1465. struct msm_dai_q6_spdif_dai_data *dai_data;
  1466. evt = (struct msm_dai_q6_spdif_event_msg *)payload;
  1467. dai_data = (struct msm_dai_q6_spdif_dai_data *)private_data;
  1468. pr_debug("%s: old state %d, fmt %d, rate %d\n",
  1469. __func__, dai_data->fmt_event.status,
  1470. dai_data->fmt_event.data_format,
  1471. dai_data->fmt_event.sample_rate);
  1472. pr_debug("%s: new state %d, fmt %d, rate %d\n",
  1473. __func__, evt->fmt_event.status,
  1474. evt->fmt_event.data_format,
  1475. evt->fmt_event.sample_rate);
  1476. dai_data->fmt_event.status = evt->fmt_event.status;
  1477. dai_data->fmt_event.data_format = evt->fmt_event.data_format;
  1478. dai_data->fmt_event.sample_rate = evt->fmt_event.sample_rate;
  1479. }
  1480. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1481. struct snd_pcm_hw_params *params,
  1482. struct snd_soc_dai *dai)
  1483. {
  1484. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1485. dai_data->channels = params_channels(params);
  1486. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1487. switch (params_format(params)) {
  1488. case SNDRV_PCM_FORMAT_S16_LE:
  1489. dai_data->spdif_port.cfg.bit_width = 16;
  1490. break;
  1491. case SNDRV_PCM_FORMAT_S24_LE:
  1492. case SNDRV_PCM_FORMAT_S24_3LE:
  1493. dai_data->spdif_port.cfg.bit_width = 24;
  1494. break;
  1495. default:
  1496. pr_err("%s: format %d\n",
  1497. __func__, params_format(params));
  1498. return -EINVAL;
  1499. }
  1500. dai_data->rate = params_rate(params);
  1501. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1502. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1503. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1504. AFE_API_VERSION_SPDIF_CONFIG_V2;
  1505. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1506. dai_data->channels, dai_data->rate,
  1507. dai_data->spdif_port.cfg.bit_width);
  1508. dai_data->spdif_port.cfg.reserved = 0;
  1509. return 0;
  1510. }
  1511. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1512. struct snd_soc_dai *dai)
  1513. {
  1514. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1515. int rc = 0;
  1516. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1517. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1518. __func__, *dai_data->status_mask);
  1519. return;
  1520. }
  1521. rc = afe_close(dai->id);
  1522. if (rc < 0)
  1523. dev_err(dai->dev, "fail to close AFE port\n");
  1524. dai_data->fmt_event.status = 0; /* report invalid line state */
  1525. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1526. *dai_data->status_mask);
  1527. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1528. }
  1529. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1530. struct snd_soc_dai *dai)
  1531. {
  1532. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1533. int rc = 0;
  1534. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1535. rc = afe_spdif_reg_event_cfg(dai->id,
  1536. AFE_MODULE_REGISTER_EVENT_FLAG,
  1537. msm_dai_q6_spdif_process_event,
  1538. dai_data);
  1539. if (rc < 0)
  1540. dev_err(dai->dev,
  1541. "fail to register event for port 0x%x\n",
  1542. dai->id);
  1543. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1544. dai_data->rate);
  1545. if (rc < 0)
  1546. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1547. dai->id);
  1548. else
  1549. set_bit(STATUS_PORT_STARTED,
  1550. dai_data->status_mask);
  1551. }
  1552. return rc;
  1553. }
  1554. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1555. {
  1556. struct msm_dai_q6_spdif_dai_data *dai_data;
  1557. int rc = 0;
  1558. struct snd_soc_dapm_route intercon;
  1559. struct snd_soc_dapm_context *dapm;
  1560. if (!dai) {
  1561. pr_err("%s: dai not found!!\n", __func__);
  1562. return -EINVAL;
  1563. }
  1564. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1565. GFP_KERNEL);
  1566. if (!dai_data) {
  1567. rc = -ENOMEM;
  1568. } else
  1569. dev_set_drvdata(dai->dev, dai_data);
  1570. dai->id = dai->driver->id;
  1571. dai_data->port_id = dai->id;
  1572. switch (dai->id) {
  1573. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  1574. rc = snd_ctl_add(dai->component->card->snd_card,
  1575. snd_ctl_new1(&spdif_rx_config_controls[1],
  1576. dai_data));
  1577. break;
  1578. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  1579. rc = snd_ctl_add(dai->component->card->snd_card,
  1580. snd_ctl_new1(&spdif_rx_config_controls[3],
  1581. dai_data));
  1582. break;
  1583. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  1584. rc = snd_ctl_add(dai->component->card->snd_card,
  1585. snd_ctl_new1(&spdif_tx_config_controls[0],
  1586. dai_data));
  1587. rc = snd_ctl_add(dai->component->card->snd_card,
  1588. snd_ctl_new1(&spdif_tx_config_controls[1],
  1589. dai_data));
  1590. rc = snd_ctl_add(dai->component->card->snd_card,
  1591. snd_ctl_new1(&spdif_tx_status_controls[0],
  1592. dai_data));
  1593. rc = snd_ctl_add(dai->component->card->snd_card,
  1594. snd_ctl_new1(&spdif_tx_status_controls[1],
  1595. dai_data));
  1596. rc = snd_ctl_add(dai->component->card->snd_card,
  1597. snd_ctl_new1(&spdif_tx_status_controls[2],
  1598. dai_data));
  1599. break;
  1600. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  1601. rc = snd_ctl_add(dai->component->card->snd_card,
  1602. snd_ctl_new1(&spdif_tx_config_controls[2],
  1603. dai_data));
  1604. rc = snd_ctl_add(dai->component->card->snd_card,
  1605. snd_ctl_new1(&spdif_tx_config_controls[3],
  1606. dai_data));
  1607. rc = snd_ctl_add(dai->component->card->snd_card,
  1608. snd_ctl_new1(&spdif_tx_status_controls[3],
  1609. dai_data));
  1610. rc = snd_ctl_add(dai->component->card->snd_card,
  1611. snd_ctl_new1(&spdif_tx_status_controls[4],
  1612. dai_data));
  1613. rc = snd_ctl_add(dai->component->card->snd_card,
  1614. snd_ctl_new1(&spdif_tx_status_controls[5],
  1615. dai_data));
  1616. break;
  1617. }
  1618. if (rc < 0)
  1619. dev_err(dai->dev,
  1620. "%s: err add config ctl, DAI = %s\n",
  1621. __func__, dai->name);
  1622. dapm = snd_soc_component_get_dapm(dai->component);
  1623. memset(&intercon, 0, sizeof(intercon));
  1624. if (!rc && dai && dai->driver) {
  1625. if (dai->driver->playback.stream_name &&
  1626. dai->driver->playback.aif_name) {
  1627. dev_dbg(dai->dev, "%s: add route for widget %s",
  1628. __func__, dai->driver->playback.stream_name);
  1629. intercon.source = dai->driver->playback.aif_name;
  1630. intercon.sink = dai->driver->playback.stream_name;
  1631. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1632. __func__, intercon.source, intercon.sink);
  1633. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1634. }
  1635. if (dai->driver->capture.stream_name &&
  1636. dai->driver->capture.aif_name) {
  1637. dev_dbg(dai->dev, "%s: add route for widget %s",
  1638. __func__, dai->driver->capture.stream_name);
  1639. intercon.sink = dai->driver->capture.aif_name;
  1640. intercon.source = dai->driver->capture.stream_name;
  1641. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1642. __func__, intercon.source, intercon.sink);
  1643. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1644. }
  1645. }
  1646. return rc;
  1647. }
  1648. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  1649. {
  1650. struct msm_dai_q6_spdif_dai_data *dai_data;
  1651. int rc;
  1652. dai_data = dev_get_drvdata(dai->dev);
  1653. /* If AFE port is still up, close it */
  1654. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1655. rc = afe_spdif_reg_event_cfg(dai->id,
  1656. AFE_MODULE_DEREGISTER_EVENT_FLAG,
  1657. NULL,
  1658. dai_data);
  1659. if (rc < 0)
  1660. dev_err(dai->dev,
  1661. "fail to deregister event for port 0x%x\n",
  1662. dai->id);
  1663. rc = afe_close(dai->id); /* can block */
  1664. if (rc < 0)
  1665. dev_err(dai->dev, "fail to close AFE port\n");
  1666. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1667. }
  1668. kfree(dai_data);
  1669. return 0;
  1670. }
  1671. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  1672. .prepare = msm_dai_q6_spdif_prepare,
  1673. .hw_params = msm_dai_q6_spdif_hw_params,
  1674. .shutdown = msm_dai_q6_spdif_shutdown,
  1675. };
  1676. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai[] = {
  1677. {
  1678. .playback = {
  1679. .stream_name = "Primary SPDIF Playback",
  1680. .aif_name = "PRI_SPDIF_RX",
  1681. .rates = SNDRV_PCM_RATE_32000 |
  1682. SNDRV_PCM_RATE_44100 |
  1683. SNDRV_PCM_RATE_48000 |
  1684. SNDRV_PCM_RATE_88200 |
  1685. SNDRV_PCM_RATE_96000 |
  1686. SNDRV_PCM_RATE_176400 |
  1687. SNDRV_PCM_RATE_192000,
  1688. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1689. SNDRV_PCM_FMTBIT_S24_LE,
  1690. .channels_min = 1,
  1691. .channels_max = 2,
  1692. .rate_min = 32000,
  1693. .rate_max = 192000,
  1694. },
  1695. .name = "PRI_SPDIF_RX",
  1696. .ops = &msm_dai_q6_spdif_ops,
  1697. .id = AFE_PORT_ID_PRIMARY_SPDIF_RX,
  1698. .probe = msm_dai_q6_spdif_dai_probe,
  1699. .remove = msm_dai_q6_spdif_dai_remove,
  1700. },
  1701. {
  1702. .playback = {
  1703. .stream_name = "Secondary SPDIF Playback",
  1704. .aif_name = "SEC_SPDIF_RX",
  1705. .rates = SNDRV_PCM_RATE_32000 |
  1706. SNDRV_PCM_RATE_44100 |
  1707. SNDRV_PCM_RATE_48000 |
  1708. SNDRV_PCM_RATE_88200 |
  1709. SNDRV_PCM_RATE_96000 |
  1710. SNDRV_PCM_RATE_176400 |
  1711. SNDRV_PCM_RATE_192000,
  1712. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1713. SNDRV_PCM_FMTBIT_S24_LE,
  1714. .channels_min = 1,
  1715. .channels_max = 2,
  1716. .rate_min = 32000,
  1717. .rate_max = 192000,
  1718. },
  1719. .name = "SEC_SPDIF_RX",
  1720. .ops = &msm_dai_q6_spdif_ops,
  1721. .id = AFE_PORT_ID_SECONDARY_SPDIF_RX,
  1722. .probe = msm_dai_q6_spdif_dai_probe,
  1723. .remove = msm_dai_q6_spdif_dai_remove,
  1724. },
  1725. };
  1726. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_tx_dai[] = {
  1727. {
  1728. .capture = {
  1729. .stream_name = "Primary SPDIF Capture",
  1730. .aif_name = "PRI_SPDIF_TX",
  1731. .rates = SNDRV_PCM_RATE_32000 |
  1732. SNDRV_PCM_RATE_44100 |
  1733. SNDRV_PCM_RATE_48000 |
  1734. SNDRV_PCM_RATE_88200 |
  1735. SNDRV_PCM_RATE_96000 |
  1736. SNDRV_PCM_RATE_176400 |
  1737. SNDRV_PCM_RATE_192000,
  1738. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1739. SNDRV_PCM_FMTBIT_S24_LE,
  1740. .channels_min = 1,
  1741. .channels_max = 2,
  1742. .rate_min = 32000,
  1743. .rate_max = 192000,
  1744. },
  1745. .name = "PRI_SPDIF_TX",
  1746. .ops = &msm_dai_q6_spdif_ops,
  1747. .id = AFE_PORT_ID_PRIMARY_SPDIF_TX,
  1748. .probe = msm_dai_q6_spdif_dai_probe,
  1749. .remove = msm_dai_q6_spdif_dai_remove,
  1750. },
  1751. {
  1752. .capture = {
  1753. .stream_name = "Secondary SPDIF Capture",
  1754. .aif_name = "SEC_SPDIF_TX",
  1755. .rates = SNDRV_PCM_RATE_32000 |
  1756. SNDRV_PCM_RATE_44100 |
  1757. SNDRV_PCM_RATE_48000 |
  1758. SNDRV_PCM_RATE_88200 |
  1759. SNDRV_PCM_RATE_96000 |
  1760. SNDRV_PCM_RATE_176400 |
  1761. SNDRV_PCM_RATE_192000,
  1762. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1763. SNDRV_PCM_FMTBIT_S24_LE,
  1764. .channels_min = 1,
  1765. .channels_max = 2,
  1766. .rate_min = 32000,
  1767. .rate_max = 192000,
  1768. },
  1769. .name = "SEC_SPDIF_TX",
  1770. .ops = &msm_dai_q6_spdif_ops,
  1771. .id = AFE_PORT_ID_SECONDARY_SPDIF_TX,
  1772. .probe = msm_dai_q6_spdif_dai_probe,
  1773. .remove = msm_dai_q6_spdif_dai_remove,
  1774. },
  1775. };
  1776. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  1777. .name = "msm-dai-q6-spdif",
  1778. };
  1779. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  1780. struct snd_soc_dai *dai)
  1781. {
  1782. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1783. int rc = 0;
  1784. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1785. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  1786. int bitwidth = 0;
  1787. switch (dai_data->afe_in_bitformat) {
  1788. case SNDRV_PCM_FORMAT_S32_LE:
  1789. bitwidth = 32;
  1790. break;
  1791. case SNDRV_PCM_FORMAT_S24_LE:
  1792. bitwidth = 24;
  1793. break;
  1794. case SNDRV_PCM_FORMAT_S16_LE:
  1795. default:
  1796. bitwidth = 16;
  1797. break;
  1798. }
  1799. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  1800. __func__, dai_data->enc_config.format);
  1801. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  1802. dai_data->rate,
  1803. dai_data->afe_in_channels,
  1804. bitwidth,
  1805. &dai_data->enc_config, NULL);
  1806. if (rc < 0)
  1807. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  1808. __func__, rc);
  1809. } else if (dai_data->dec_config.format != DEC_FMT_NONE) {
  1810. /*
  1811. * A dummy Tx session is established in LPASS to
  1812. * get the link statistics from BTSoC.
  1813. * Depacketizer extracts the bit rate levels and
  1814. * transmits them to the encoder on the Rx path.
  1815. * Since this is a dummy decoder - channels, bit
  1816. * width are sent as 0 and encoder config is NULL.
  1817. * This could be updated in the future if there is
  1818. * a complete Tx path set up that uses this decoder.
  1819. */
  1820. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  1821. dai_data->rate, 0, 0, NULL,
  1822. &dai_data->dec_config);
  1823. if (rc < 0) {
  1824. pr_err("%s: fail to open AFE port 0x%x\n",
  1825. __func__, dai->id);
  1826. }
  1827. } else {
  1828. rc = afe_port_start(dai->id, &dai_data->port_config,
  1829. dai_data->rate);
  1830. }
  1831. if (rc < 0)
  1832. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1833. dai->id);
  1834. else
  1835. set_bit(STATUS_PORT_STARTED,
  1836. dai_data->status_mask);
  1837. }
  1838. return rc;
  1839. }
  1840. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  1841. struct snd_soc_dai *dai, int stream)
  1842. {
  1843. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1844. dai_data->channels = params_channels(params);
  1845. switch (dai_data->channels) {
  1846. case 2:
  1847. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1848. break;
  1849. case 1:
  1850. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1851. break;
  1852. default:
  1853. return -EINVAL;
  1854. pr_err("%s: err channels %d\n",
  1855. __func__, dai_data->channels);
  1856. break;
  1857. }
  1858. switch (params_format(params)) {
  1859. case SNDRV_PCM_FORMAT_S16_LE:
  1860. case SNDRV_PCM_FORMAT_SPECIAL:
  1861. dai_data->port_config.i2s.bit_width = 16;
  1862. break;
  1863. case SNDRV_PCM_FORMAT_S24_LE:
  1864. case SNDRV_PCM_FORMAT_S24_3LE:
  1865. dai_data->port_config.i2s.bit_width = 24;
  1866. break;
  1867. default:
  1868. pr_err("%s: format %d\n",
  1869. __func__, params_format(params));
  1870. return -EINVAL;
  1871. }
  1872. dai_data->rate = params_rate(params);
  1873. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1874. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1875. AFE_API_VERSION_I2S_CONFIG;
  1876. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1877. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  1878. dai_data->channels, dai_data->rate);
  1879. dai_data->port_config.i2s.channel_mode = 1;
  1880. return 0;
  1881. }
  1882. static u8 num_of_bits_set(u8 sd_line_mask)
  1883. {
  1884. u8 num_bits_set = 0;
  1885. while (sd_line_mask) {
  1886. num_bits_set++;
  1887. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  1888. }
  1889. return num_bits_set;
  1890. }
  1891. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  1892. struct snd_soc_dai *dai, int stream)
  1893. {
  1894. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1895. struct msm_i2s_data *i2s_pdata =
  1896. (struct msm_i2s_data *) dai->dev->platform_data;
  1897. dai_data->channels = params_channels(params);
  1898. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  1899. switch (dai_data->channels) {
  1900. case 2:
  1901. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1902. break;
  1903. case 1:
  1904. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1905. break;
  1906. default:
  1907. pr_warn("%s: greater than stereo has not been validated %d",
  1908. __func__, dai_data->channels);
  1909. break;
  1910. }
  1911. }
  1912. dai_data->rate = params_rate(params);
  1913. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1914. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1915. AFE_API_VERSION_I2S_CONFIG;
  1916. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1917. /* Q6 only supports 16 as now */
  1918. dai_data->port_config.i2s.bit_width = 16;
  1919. dai_data->port_config.i2s.channel_mode = 1;
  1920. return 0;
  1921. }
  1922. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  1923. struct snd_soc_dai *dai, int stream)
  1924. {
  1925. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1926. dai_data->channels = params_channels(params);
  1927. dai_data->rate = params_rate(params);
  1928. switch (params_format(params)) {
  1929. case SNDRV_PCM_FORMAT_S16_LE:
  1930. case SNDRV_PCM_FORMAT_SPECIAL:
  1931. dai_data->port_config.slim_sch.bit_width = 16;
  1932. break;
  1933. case SNDRV_PCM_FORMAT_S24_LE:
  1934. case SNDRV_PCM_FORMAT_S24_3LE:
  1935. dai_data->port_config.slim_sch.bit_width = 24;
  1936. break;
  1937. case SNDRV_PCM_FORMAT_S32_LE:
  1938. dai_data->port_config.slim_sch.bit_width = 32;
  1939. break;
  1940. default:
  1941. pr_err("%s: format %d\n",
  1942. __func__, params_format(params));
  1943. return -EINVAL;
  1944. }
  1945. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  1946. AFE_API_VERSION_SLIMBUS_CONFIG;
  1947. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  1948. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  1949. switch (dai->id) {
  1950. case SLIMBUS_7_RX:
  1951. case SLIMBUS_7_TX:
  1952. case SLIMBUS_8_RX:
  1953. case SLIMBUS_8_TX:
  1954. dai_data->port_config.slim_sch.slimbus_dev_id =
  1955. AFE_SLIMBUS_DEVICE_2;
  1956. break;
  1957. default:
  1958. dai_data->port_config.slim_sch.slimbus_dev_id =
  1959. AFE_SLIMBUS_DEVICE_1;
  1960. break;
  1961. }
  1962. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  1963. "num_channel %hu shared_ch_mapping[0] %hu\n"
  1964. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  1965. "sample_rate %d\n", __func__,
  1966. dai_data->port_config.slim_sch.slimbus_dev_id,
  1967. dai_data->port_config.slim_sch.bit_width,
  1968. dai_data->port_config.slim_sch.data_format,
  1969. dai_data->port_config.slim_sch.num_channels,
  1970. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1971. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  1972. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  1973. dai_data->rate);
  1974. return 0;
  1975. }
  1976. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  1977. struct snd_soc_dai *dai, int stream)
  1978. {
  1979. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1980. dai_data->channels = params_channels(params);
  1981. dai_data->rate = params_rate(params);
  1982. switch (params_format(params)) {
  1983. case SNDRV_PCM_FORMAT_S16_LE:
  1984. case SNDRV_PCM_FORMAT_SPECIAL:
  1985. dai_data->port_config.usb_audio.bit_width = 16;
  1986. break;
  1987. case SNDRV_PCM_FORMAT_S24_LE:
  1988. case SNDRV_PCM_FORMAT_S24_3LE:
  1989. dai_data->port_config.usb_audio.bit_width = 24;
  1990. break;
  1991. case SNDRV_PCM_FORMAT_S32_LE:
  1992. dai_data->port_config.usb_audio.bit_width = 32;
  1993. break;
  1994. default:
  1995. dev_err(dai->dev, "%s: invalid format %d\n",
  1996. __func__, params_format(params));
  1997. return -EINVAL;
  1998. }
  1999. dai_data->port_config.usb_audio.cfg_minor_version =
  2000. AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG;
  2001. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  2002. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  2003. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  2004. "num_channel %hu sample_rate %d\n", __func__,
  2005. dai_data->port_config.usb_audio.dev_token,
  2006. dai_data->port_config.usb_audio.bit_width,
  2007. dai_data->port_config.usb_audio.data_format,
  2008. dai_data->port_config.usb_audio.num_channels,
  2009. dai_data->port_config.usb_audio.sample_rate);
  2010. return 0;
  2011. }
  2012. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  2013. struct snd_soc_dai *dai, int stream)
  2014. {
  2015. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2016. dai_data->channels = params_channels(params);
  2017. dai_data->rate = params_rate(params);
  2018. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  2019. dai_data->channels, dai_data->rate);
  2020. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  2021. pr_debug("%s: setting bt_fm parameters\n", __func__);
  2022. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  2023. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  2024. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  2025. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  2026. dai_data->port_config.int_bt_fm.bit_width = 16;
  2027. return 0;
  2028. }
  2029. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  2030. struct snd_soc_dai *dai)
  2031. {
  2032. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2033. dai_data->rate = params_rate(params);
  2034. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  2035. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  2036. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  2037. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  2038. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  2039. AFE_API_VERSION_RT_PROXY_CONFIG;
  2040. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  2041. dai_data->port_config.rtproxy.interleaved = 1;
  2042. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  2043. dai_data->port_config.rtproxy.jitter_allowance =
  2044. dai_data->port_config.rtproxy.frame_size/2;
  2045. dai_data->port_config.rtproxy.low_water_mark = 0;
  2046. dai_data->port_config.rtproxy.high_water_mark = 0;
  2047. return 0;
  2048. }
  2049. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  2050. struct snd_soc_dai *dai, int stream)
  2051. {
  2052. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2053. dai_data->channels = params_channels(params);
  2054. dai_data->rate = params_rate(params);
  2055. /* Q6 only supports 16 as now */
  2056. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  2057. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  2058. dai_data->port_config.pseudo_port.num_channels =
  2059. params_channels(params);
  2060. dai_data->port_config.pseudo_port.bit_width = 16;
  2061. dai_data->port_config.pseudo_port.data_format = 0;
  2062. dai_data->port_config.pseudo_port.timing_mode =
  2063. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  2064. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  2065. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  2066. "timing Mode %hu sample_rate %d\n", __func__,
  2067. dai_data->port_config.pseudo_port.bit_width,
  2068. dai_data->port_config.pseudo_port.num_channels,
  2069. dai_data->port_config.pseudo_port.data_format,
  2070. dai_data->port_config.pseudo_port.timing_mode,
  2071. dai_data->port_config.pseudo_port.sample_rate);
  2072. return 0;
  2073. }
  2074. /* Current implementation assumes hw_param is called once
  2075. * This may not be the case but what to do when ADM and AFE
  2076. * port are already opened and parameter changes
  2077. */
  2078. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  2079. struct snd_pcm_hw_params *params,
  2080. struct snd_soc_dai *dai)
  2081. {
  2082. int rc = 0;
  2083. switch (dai->id) {
  2084. case PRIMARY_I2S_TX:
  2085. case PRIMARY_I2S_RX:
  2086. case SECONDARY_I2S_RX:
  2087. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  2088. break;
  2089. case MI2S_RX:
  2090. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  2091. break;
  2092. case SLIMBUS_0_RX:
  2093. case SLIMBUS_1_RX:
  2094. case SLIMBUS_2_RX:
  2095. case SLIMBUS_3_RX:
  2096. case SLIMBUS_4_RX:
  2097. case SLIMBUS_5_RX:
  2098. case SLIMBUS_6_RX:
  2099. case SLIMBUS_7_RX:
  2100. case SLIMBUS_8_RX:
  2101. case SLIMBUS_0_TX:
  2102. case SLIMBUS_1_TX:
  2103. case SLIMBUS_2_TX:
  2104. case SLIMBUS_3_TX:
  2105. case SLIMBUS_4_TX:
  2106. case SLIMBUS_5_TX:
  2107. case SLIMBUS_6_TX:
  2108. case SLIMBUS_7_TX:
  2109. case SLIMBUS_8_TX:
  2110. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  2111. substream->stream);
  2112. break;
  2113. case INT_BT_SCO_RX:
  2114. case INT_BT_SCO_TX:
  2115. case INT_BT_A2DP_RX:
  2116. case INT_FM_RX:
  2117. case INT_FM_TX:
  2118. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  2119. break;
  2120. case AFE_PORT_ID_USB_RX:
  2121. case AFE_PORT_ID_USB_TX:
  2122. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  2123. substream->stream);
  2124. break;
  2125. case RT_PROXY_DAI_001_TX:
  2126. case RT_PROXY_DAI_001_RX:
  2127. case RT_PROXY_DAI_002_TX:
  2128. case RT_PROXY_DAI_002_RX:
  2129. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  2130. break;
  2131. case VOICE_PLAYBACK_TX:
  2132. case VOICE2_PLAYBACK_TX:
  2133. case VOICE_RECORD_RX:
  2134. case VOICE_RECORD_TX:
  2135. rc = msm_dai_q6_pseudo_port_hw_params(params,
  2136. dai, substream->stream);
  2137. break;
  2138. default:
  2139. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  2140. rc = -EINVAL;
  2141. break;
  2142. }
  2143. return rc;
  2144. }
  2145. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  2146. struct snd_soc_dai *dai)
  2147. {
  2148. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2149. int rc = 0;
  2150. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2151. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2152. rc = afe_close(dai->id); /* can block */
  2153. if (rc < 0)
  2154. dev_err(dai->dev, "fail to close AFE port\n");
  2155. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  2156. *dai_data->status_mask);
  2157. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2158. }
  2159. }
  2160. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2161. {
  2162. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2163. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2164. case SND_SOC_DAIFMT_CBS_CFS:
  2165. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  2166. break;
  2167. case SND_SOC_DAIFMT_CBM_CFM:
  2168. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  2169. break;
  2170. default:
  2171. pr_err("%s: fmt 0x%x\n",
  2172. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  2173. return -EINVAL;
  2174. }
  2175. return 0;
  2176. }
  2177. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2178. {
  2179. int rc = 0;
  2180. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  2181. dai->id, fmt);
  2182. switch (dai->id) {
  2183. case PRIMARY_I2S_TX:
  2184. case PRIMARY_I2S_RX:
  2185. case MI2S_RX:
  2186. case SECONDARY_I2S_RX:
  2187. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  2188. break;
  2189. default:
  2190. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2191. rc = -EINVAL;
  2192. break;
  2193. }
  2194. return rc;
  2195. }
  2196. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  2197. unsigned int tx_num, unsigned int *tx_slot,
  2198. unsigned int rx_num, unsigned int *rx_slot)
  2199. {
  2200. int rc = 0;
  2201. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2202. unsigned int i = 0;
  2203. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  2204. switch (dai->id) {
  2205. case SLIMBUS_0_RX:
  2206. case SLIMBUS_1_RX:
  2207. case SLIMBUS_2_RX:
  2208. case SLIMBUS_3_RX:
  2209. case SLIMBUS_4_RX:
  2210. case SLIMBUS_5_RX:
  2211. case SLIMBUS_6_RX:
  2212. case SLIMBUS_7_RX:
  2213. case SLIMBUS_8_RX:
  2214. /*
  2215. * channel number to be between 128 and 255.
  2216. * For RX port use channel numbers
  2217. * from 138 to 144 for pre-Taiko
  2218. * from 144 to 159 for Taiko
  2219. */
  2220. if (!rx_slot) {
  2221. pr_err("%s: rx slot not found\n", __func__);
  2222. return -EINVAL;
  2223. }
  2224. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2225. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  2226. return -EINVAL;
  2227. }
  2228. for (i = 0; i < rx_num; i++) {
  2229. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2230. rx_slot[i];
  2231. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2232. __func__, i, rx_slot[i]);
  2233. }
  2234. dai_data->port_config.slim_sch.num_channels = rx_num;
  2235. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  2236. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  2237. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2238. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2239. break;
  2240. case SLIMBUS_0_TX:
  2241. case SLIMBUS_1_TX:
  2242. case SLIMBUS_2_TX:
  2243. case SLIMBUS_3_TX:
  2244. case SLIMBUS_4_TX:
  2245. case SLIMBUS_5_TX:
  2246. case SLIMBUS_6_TX:
  2247. case SLIMBUS_7_TX:
  2248. case SLIMBUS_8_TX:
  2249. /*
  2250. * channel number to be between 128 and 255.
  2251. * For TX port use channel numbers
  2252. * from 128 to 137 for pre-Taiko
  2253. * from 128 to 143 for Taiko
  2254. */
  2255. if (!tx_slot) {
  2256. pr_err("%s: tx slot not found\n", __func__);
  2257. return -EINVAL;
  2258. }
  2259. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2260. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  2261. return -EINVAL;
  2262. }
  2263. for (i = 0; i < tx_num; i++) {
  2264. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2265. tx_slot[i];
  2266. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2267. __func__, i, tx_slot[i]);
  2268. }
  2269. dai_data->port_config.slim_sch.num_channels = tx_num;
  2270. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  2271. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  2272. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2273. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2274. break;
  2275. default:
  2276. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2277. rc = -EINVAL;
  2278. break;
  2279. }
  2280. return rc;
  2281. }
  2282. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  2283. .prepare = msm_dai_q6_prepare,
  2284. .hw_params = msm_dai_q6_hw_params,
  2285. .shutdown = msm_dai_q6_shutdown,
  2286. .set_fmt = msm_dai_q6_set_fmt,
  2287. .set_channel_map = msm_dai_q6_set_channel_map,
  2288. };
  2289. /*
  2290. * For single CPU DAI registration, the dai id needs to be
  2291. * set explicitly in the dai probe as ASoC does not read
  2292. * the cpu->driver->id field rather it assigns the dai id
  2293. * from the device name that is in the form %s.%d. This dai
  2294. * id should be assigned to back-end AFE port id and used
  2295. * during dai prepare. For multiple dai registration, it
  2296. * is not required to call this function, however the dai->
  2297. * driver->id field must be defined and set to corresponding
  2298. * AFE Port id.
  2299. */
  2300. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  2301. {
  2302. if (!dai->driver->id) {
  2303. dev_warn(dai->dev, "DAI driver id is not set\n");
  2304. return;
  2305. }
  2306. dai->id = dai->driver->id;
  2307. }
  2308. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  2309. struct snd_ctl_elem_value *ucontrol)
  2310. {
  2311. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2312. u16 port_id = ((struct soc_enum *)
  2313. kcontrol->private_value)->reg;
  2314. dai_data->cal_mode = ucontrol->value.integer.value[0];
  2315. pr_debug("%s: setting cal_mode to %d\n",
  2316. __func__, dai_data->cal_mode);
  2317. afe_set_cal_mode(port_id, dai_data->cal_mode);
  2318. return 0;
  2319. }
  2320. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  2321. struct snd_ctl_elem_value *ucontrol)
  2322. {
  2323. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2324. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  2325. return 0;
  2326. }
  2327. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  2328. struct snd_ctl_elem_value *ucontrol)
  2329. {
  2330. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2331. int value = ucontrol->value.integer.value[0];
  2332. if (dai_data) {
  2333. dai_data->port_config.slim_sch.data_format = value;
  2334. pr_debug("%s: format = %d\n", __func__, value);
  2335. }
  2336. return 0;
  2337. }
  2338. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  2339. struct snd_ctl_elem_value *ucontrol)
  2340. {
  2341. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2342. if (dai_data)
  2343. ucontrol->value.integer.value[0] =
  2344. dai_data->port_config.slim_sch.data_format;
  2345. return 0;
  2346. }
  2347. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  2348. struct snd_ctl_elem_value *ucontrol)
  2349. {
  2350. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2351. u32 val = ucontrol->value.integer.value[0];
  2352. if (dai_data) {
  2353. dai_data->port_config.usb_audio.dev_token = val;
  2354. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2355. dai_data->port_config.usb_audio.dev_token);
  2356. } else {
  2357. pr_err("%s: dai_data is NULL\n", __func__);
  2358. }
  2359. return 0;
  2360. }
  2361. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  2362. struct snd_ctl_elem_value *ucontrol)
  2363. {
  2364. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2365. if (dai_data) {
  2366. ucontrol->value.integer.value[0] =
  2367. dai_data->port_config.usb_audio.dev_token;
  2368. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2369. dai_data->port_config.usb_audio.dev_token);
  2370. } else {
  2371. pr_err("%s: dai_data is NULL\n", __func__);
  2372. }
  2373. return 0;
  2374. }
  2375. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  2376. struct snd_ctl_elem_value *ucontrol)
  2377. {
  2378. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2379. u32 val = ucontrol->value.integer.value[0];
  2380. if (dai_data) {
  2381. dai_data->port_config.usb_audio.endian = val;
  2382. pr_debug("%s: endian = 0x%x\n", __func__,
  2383. dai_data->port_config.usb_audio.endian);
  2384. } else {
  2385. pr_err("%s: dai_data is NULL\n", __func__);
  2386. return -EINVAL;
  2387. }
  2388. return 0;
  2389. }
  2390. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  2391. struct snd_ctl_elem_value *ucontrol)
  2392. {
  2393. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2394. if (dai_data) {
  2395. ucontrol->value.integer.value[0] =
  2396. dai_data->port_config.usb_audio.endian;
  2397. pr_debug("%s: endian = 0x%x\n", __func__,
  2398. dai_data->port_config.usb_audio.endian);
  2399. } else {
  2400. pr_err("%s: dai_data is NULL\n", __func__);
  2401. return -EINVAL;
  2402. }
  2403. return 0;
  2404. }
  2405. static int msm_dai_q6_usb_audio_svc_interval_put(struct snd_kcontrol *kcontrol,
  2406. struct snd_ctl_elem_value *ucontrol)
  2407. {
  2408. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2409. u32 val = ucontrol->value.integer.value[0];
  2410. if (!dai_data) {
  2411. pr_err("%s: dai_data is NULL\n", __func__);
  2412. return -EINVAL;
  2413. }
  2414. dai_data->port_config.usb_audio.service_interval = val;
  2415. pr_debug("%s: new service interval = %u\n", __func__,
  2416. dai_data->port_config.usb_audio.service_interval);
  2417. return 0;
  2418. }
  2419. static int msm_dai_q6_usb_audio_svc_interval_get(struct snd_kcontrol *kcontrol,
  2420. struct snd_ctl_elem_value *ucontrol)
  2421. {
  2422. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2423. if (!dai_data) {
  2424. pr_err("%s: dai_data is NULL\n", __func__);
  2425. return -EINVAL;
  2426. }
  2427. ucontrol->value.integer.value[0] =
  2428. dai_data->port_config.usb_audio.service_interval;
  2429. pr_debug("%s: service interval = %d\n", __func__,
  2430. dai_data->port_config.usb_audio.service_interval);
  2431. return 0;
  2432. }
  2433. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2434. struct snd_ctl_elem_info *uinfo)
  2435. {
  2436. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2437. uinfo->count = sizeof(struct afe_enc_config);
  2438. return 0;
  2439. }
  2440. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2441. struct snd_ctl_elem_value *ucontrol)
  2442. {
  2443. int ret = 0;
  2444. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2445. if (dai_data) {
  2446. int format_size = sizeof(dai_data->enc_config.format);
  2447. pr_debug("%s: encoder config for %d format\n",
  2448. __func__, dai_data->enc_config.format);
  2449. memcpy(ucontrol->value.bytes.data,
  2450. &dai_data->enc_config.format,
  2451. format_size);
  2452. switch (dai_data->enc_config.format) {
  2453. case ENC_FMT_SBC:
  2454. memcpy(ucontrol->value.bytes.data + format_size,
  2455. &dai_data->enc_config.data,
  2456. sizeof(struct asm_sbc_enc_cfg_t));
  2457. break;
  2458. case ENC_FMT_AAC_V2:
  2459. memcpy(ucontrol->value.bytes.data + format_size,
  2460. &dai_data->enc_config.data,
  2461. sizeof(struct asm_aac_enc_cfg_v2_t));
  2462. break;
  2463. case ENC_FMT_APTX:
  2464. memcpy(ucontrol->value.bytes.data + format_size,
  2465. &dai_data->enc_config.data,
  2466. sizeof(struct asm_aptx_enc_cfg_t));
  2467. break;
  2468. case ENC_FMT_APTX_HD:
  2469. memcpy(ucontrol->value.bytes.data + format_size,
  2470. &dai_data->enc_config.data,
  2471. sizeof(struct asm_custom_enc_cfg_t));
  2472. break;
  2473. case ENC_FMT_CELT:
  2474. memcpy(ucontrol->value.bytes.data + format_size,
  2475. &dai_data->enc_config.data,
  2476. sizeof(struct asm_celt_enc_cfg_t));
  2477. break;
  2478. case ENC_FMT_LDAC:
  2479. memcpy(ucontrol->value.bytes.data + format_size,
  2480. &dai_data->enc_config.data,
  2481. sizeof(struct asm_ldac_enc_cfg_t));
  2482. break;
  2483. case ENC_FMT_APTX_ADAPTIVE:
  2484. memcpy(ucontrol->value.bytes.data + format_size,
  2485. &dai_data->enc_config.data,
  2486. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2487. break;
  2488. default:
  2489. pr_debug("%s: unknown format = %d\n",
  2490. __func__, dai_data->enc_config.format);
  2491. ret = -EINVAL;
  2492. break;
  2493. }
  2494. }
  2495. return ret;
  2496. }
  2497. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2498. struct snd_ctl_elem_value *ucontrol)
  2499. {
  2500. int ret = 0;
  2501. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2502. if (dai_data) {
  2503. int format_size = sizeof(dai_data->enc_config.format);
  2504. memset(&dai_data->enc_config, 0x0,
  2505. sizeof(struct afe_enc_config));
  2506. memcpy(&dai_data->enc_config.format,
  2507. ucontrol->value.bytes.data,
  2508. format_size);
  2509. pr_debug("%s: Received encoder config for %d format\n",
  2510. __func__, dai_data->enc_config.format);
  2511. switch (dai_data->enc_config.format) {
  2512. case ENC_FMT_SBC:
  2513. memcpy(&dai_data->enc_config.data,
  2514. ucontrol->value.bytes.data + format_size,
  2515. sizeof(struct asm_sbc_enc_cfg_t));
  2516. break;
  2517. case ENC_FMT_AAC_V2:
  2518. memcpy(&dai_data->enc_config.data,
  2519. ucontrol->value.bytes.data + format_size,
  2520. sizeof(struct asm_aac_enc_cfg_v2_t));
  2521. break;
  2522. case ENC_FMT_APTX:
  2523. memcpy(&dai_data->enc_config.data,
  2524. ucontrol->value.bytes.data + format_size,
  2525. sizeof(struct asm_aptx_enc_cfg_t));
  2526. break;
  2527. case ENC_FMT_APTX_HD:
  2528. memcpy(&dai_data->enc_config.data,
  2529. ucontrol->value.bytes.data + format_size,
  2530. sizeof(struct asm_custom_enc_cfg_t));
  2531. break;
  2532. case ENC_FMT_CELT:
  2533. memcpy(&dai_data->enc_config.data,
  2534. ucontrol->value.bytes.data + format_size,
  2535. sizeof(struct asm_celt_enc_cfg_t));
  2536. break;
  2537. case ENC_FMT_LDAC:
  2538. memcpy(&dai_data->enc_config.data,
  2539. ucontrol->value.bytes.data + format_size,
  2540. sizeof(struct asm_ldac_enc_cfg_t));
  2541. break;
  2542. case ENC_FMT_APTX_ADAPTIVE:
  2543. memcpy(&dai_data->enc_config.data,
  2544. ucontrol->value.bytes.data + format_size,
  2545. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2546. break;
  2547. default:
  2548. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2549. __func__, dai_data->enc_config.format);
  2550. ret = -EINVAL;
  2551. break;
  2552. }
  2553. } else
  2554. ret = -EINVAL;
  2555. return ret;
  2556. }
  2557. static const char *const afe_input_chs_text[] = {"Zero", "One", "Two"};
  2558. static const struct soc_enum afe_input_chs_enum[] = {
  2559. SOC_ENUM_SINGLE_EXT(3, afe_input_chs_text),
  2560. };
  2561. static const char *const afe_input_bit_format_text[] = {"S16_LE", "S24_LE",
  2562. "S32_LE"};
  2563. static const struct soc_enum afe_input_bit_format_enum[] = {
  2564. SOC_ENUM_SINGLE_EXT(3, afe_input_bit_format_text),
  2565. };
  2566. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2567. struct snd_ctl_elem_value *ucontrol)
  2568. {
  2569. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2570. if (dai_data) {
  2571. ucontrol->value.integer.value[0] = dai_data->afe_in_channels;
  2572. pr_debug("%s:afe input channel = %d\n",
  2573. __func__, dai_data->afe_in_channels);
  2574. }
  2575. return 0;
  2576. }
  2577. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2578. struct snd_ctl_elem_value *ucontrol)
  2579. {
  2580. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2581. if (dai_data) {
  2582. dai_data->afe_in_channels = ucontrol->value.integer.value[0];
  2583. pr_debug("%s: updating afe input channel : %d\n",
  2584. __func__, dai_data->afe_in_channels);
  2585. }
  2586. return 0;
  2587. }
  2588. static int msm_dai_q6_afe_input_bit_format_get(
  2589. struct snd_kcontrol *kcontrol,
  2590. struct snd_ctl_elem_value *ucontrol)
  2591. {
  2592. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2593. if (!dai_data) {
  2594. pr_err("%s: Invalid dai data\n", __func__);
  2595. return -EINVAL;
  2596. }
  2597. switch (dai_data->afe_in_bitformat) {
  2598. case SNDRV_PCM_FORMAT_S32_LE:
  2599. ucontrol->value.integer.value[0] = 2;
  2600. break;
  2601. case SNDRV_PCM_FORMAT_S24_LE:
  2602. ucontrol->value.integer.value[0] = 1;
  2603. break;
  2604. case SNDRV_PCM_FORMAT_S16_LE:
  2605. default:
  2606. ucontrol->value.integer.value[0] = 0;
  2607. break;
  2608. }
  2609. pr_debug("%s: afe input bit format : %ld\n",
  2610. __func__, ucontrol->value.integer.value[0]);
  2611. return 0;
  2612. }
  2613. static int msm_dai_q6_afe_input_bit_format_put(
  2614. struct snd_kcontrol *kcontrol,
  2615. struct snd_ctl_elem_value *ucontrol)
  2616. {
  2617. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2618. if (!dai_data) {
  2619. pr_err("%s: Invalid dai data\n", __func__);
  2620. return -EINVAL;
  2621. }
  2622. switch (ucontrol->value.integer.value[0]) {
  2623. case 2:
  2624. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  2625. break;
  2626. case 1:
  2627. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2628. break;
  2629. case 0:
  2630. default:
  2631. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2632. break;
  2633. }
  2634. pr_debug("%s: updating afe input bit format : %d\n",
  2635. __func__, dai_data->afe_in_bitformat);
  2636. return 0;
  2637. }
  2638. static int msm_dai_q6_afe_scrambler_mode_get(
  2639. struct snd_kcontrol *kcontrol,
  2640. struct snd_ctl_elem_value *ucontrol)
  2641. {
  2642. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2643. if (!dai_data) {
  2644. pr_err("%s: Invalid dai data\n", __func__);
  2645. return -EINVAL;
  2646. }
  2647. ucontrol->value.integer.value[0] = dai_data->enc_config.scrambler_mode;
  2648. return 0;
  2649. }
  2650. static int msm_dai_q6_afe_scrambler_mode_put(
  2651. struct snd_kcontrol *kcontrol,
  2652. struct snd_ctl_elem_value *ucontrol)
  2653. {
  2654. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2655. if (!dai_data) {
  2656. pr_err("%s: Invalid dai data\n", __func__);
  2657. return -EINVAL;
  2658. }
  2659. dai_data->enc_config.scrambler_mode = ucontrol->value.integer.value[0];
  2660. pr_debug("%s: afe scrambler mode : %d\n",
  2661. __func__, dai_data->enc_config.scrambler_mode);
  2662. return 0;
  2663. }
  2664. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  2665. {
  2666. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2667. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2668. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2669. .name = "SLIM_7_RX Encoder Config",
  2670. .info = msm_dai_q6_afe_enc_cfg_info,
  2671. .get = msm_dai_q6_afe_enc_cfg_get,
  2672. .put = msm_dai_q6_afe_enc_cfg_put,
  2673. },
  2674. SOC_ENUM_EXT("AFE Input Channels", afe_input_chs_enum[0],
  2675. msm_dai_q6_afe_input_channel_get,
  2676. msm_dai_q6_afe_input_channel_put),
  2677. SOC_ENUM_EXT("AFE Input Bit Format", afe_input_bit_format_enum[0],
  2678. msm_dai_q6_afe_input_bit_format_get,
  2679. msm_dai_q6_afe_input_bit_format_put),
  2680. SOC_SINGLE_EXT("AFE Scrambler Mode",
  2681. 0, 0, 1, 0,
  2682. msm_dai_q6_afe_scrambler_mode_get,
  2683. msm_dai_q6_afe_scrambler_mode_put),
  2684. };
  2685. static int msm_dai_q6_afe_dec_cfg_info(struct snd_kcontrol *kcontrol,
  2686. struct snd_ctl_elem_info *uinfo)
  2687. {
  2688. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2689. uinfo->count = sizeof(struct afe_dec_config);
  2690. return 0;
  2691. }
  2692. static int msm_dai_q6_afe_dec_cfg_get(struct snd_kcontrol *kcontrol,
  2693. struct snd_ctl_elem_value *ucontrol)
  2694. {
  2695. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2696. int format_size = 0;
  2697. if (!dai_data) {
  2698. pr_err("%s: Invalid dai data\n", __func__);
  2699. return -EINVAL;
  2700. }
  2701. format_size = sizeof(dai_data->dec_config.format);
  2702. memcpy(ucontrol->value.bytes.data,
  2703. &dai_data->dec_config.format,
  2704. format_size);
  2705. memcpy(ucontrol->value.bytes.data + format_size,
  2706. &dai_data->dec_config.abr_dec_cfg,
  2707. sizeof(struct afe_abr_dec_cfg_t));
  2708. return 0;
  2709. }
  2710. static int msm_dai_q6_afe_dec_cfg_put(struct snd_kcontrol *kcontrol,
  2711. struct snd_ctl_elem_value *ucontrol)
  2712. {
  2713. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2714. int format_size = 0;
  2715. if (!dai_data) {
  2716. pr_err("%s: Invalid dai data\n", __func__);
  2717. return -EINVAL;
  2718. }
  2719. memset(&dai_data->dec_config, 0x0,
  2720. sizeof(struct afe_dec_config));
  2721. format_size = sizeof(dai_data->dec_config.format);
  2722. memcpy(&dai_data->dec_config.format,
  2723. ucontrol->value.bytes.data,
  2724. format_size);
  2725. memcpy(&dai_data->dec_config.abr_dec_cfg,
  2726. ucontrol->value.bytes.data + format_size,
  2727. sizeof(struct afe_abr_dec_cfg_t));
  2728. return 0;
  2729. }
  2730. static const struct snd_kcontrol_new afe_dec_config_controls[] = {
  2731. {
  2732. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2733. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2734. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2735. .name = "SLIM_7_TX Decoder Config",
  2736. .info = msm_dai_q6_afe_dec_cfg_info,
  2737. .get = msm_dai_q6_afe_dec_cfg_get,
  2738. .put = msm_dai_q6_afe_dec_cfg_put,
  2739. },
  2740. };
  2741. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  2742. struct snd_ctl_elem_info *uinfo)
  2743. {
  2744. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2745. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  2746. return 0;
  2747. }
  2748. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  2749. struct snd_ctl_elem_value *ucontrol)
  2750. {
  2751. int ret = -EINVAL;
  2752. struct afe_param_id_dev_timing_stats timing_stats;
  2753. struct snd_soc_dai *dai = kcontrol->private_data;
  2754. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2755. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2756. pr_err("%s: afe port not started. dai_data->status_mask = %ld\n",
  2757. __func__, *dai_data->status_mask);
  2758. goto done;
  2759. }
  2760. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  2761. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  2762. if (ret) {
  2763. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  2764. __func__, dai->id, ret);
  2765. goto done;
  2766. }
  2767. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  2768. sizeof(struct afe_param_id_dev_timing_stats));
  2769. done:
  2770. return ret;
  2771. }
  2772. static const char * const afe_cal_mode_text[] = {
  2773. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  2774. };
  2775. static const struct soc_enum slim_2_rx_enum =
  2776. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2777. afe_cal_mode_text);
  2778. static const struct soc_enum rt_proxy_1_rx_enum =
  2779. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2780. afe_cal_mode_text);
  2781. static const struct soc_enum rt_proxy_1_tx_enum =
  2782. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2783. afe_cal_mode_text);
  2784. static const struct snd_kcontrol_new sb_config_controls[] = {
  2785. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  2786. msm_dai_q6_sb_format_get,
  2787. msm_dai_q6_sb_format_put),
  2788. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  2789. msm_dai_q6_cal_info_get,
  2790. msm_dai_q6_cal_info_put),
  2791. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  2792. msm_dai_q6_sb_format_get,
  2793. msm_dai_q6_sb_format_put)
  2794. };
  2795. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  2796. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  2797. msm_dai_q6_cal_info_get,
  2798. msm_dai_q6_cal_info_put),
  2799. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  2800. msm_dai_q6_cal_info_get,
  2801. msm_dai_q6_cal_info_put),
  2802. };
  2803. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  2804. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  2805. msm_dai_q6_usb_audio_cfg_get,
  2806. msm_dai_q6_usb_audio_cfg_put),
  2807. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  2808. msm_dai_q6_usb_audio_endian_cfg_get,
  2809. msm_dai_q6_usb_audio_endian_cfg_put),
  2810. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  2811. msm_dai_q6_usb_audio_cfg_get,
  2812. msm_dai_q6_usb_audio_cfg_put),
  2813. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  2814. msm_dai_q6_usb_audio_endian_cfg_get,
  2815. msm_dai_q6_usb_audio_endian_cfg_put),
  2816. SOC_SINGLE_EXT("USB_AUDIO_RX service_interval", SND_SOC_NOPM, 0,
  2817. UINT_MAX, 0,
  2818. msm_dai_q6_usb_audio_svc_interval_get,
  2819. msm_dai_q6_usb_audio_svc_interval_put),
  2820. };
  2821. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  2822. {
  2823. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2824. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2825. .name = "SLIMBUS_0_RX DRIFT",
  2826. .info = msm_dai_q6_slim_rx_drift_info,
  2827. .get = msm_dai_q6_slim_rx_drift_get,
  2828. },
  2829. {
  2830. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2831. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2832. .name = "SLIMBUS_6_RX DRIFT",
  2833. .info = msm_dai_q6_slim_rx_drift_info,
  2834. .get = msm_dai_q6_slim_rx_drift_get,
  2835. },
  2836. {
  2837. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2838. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2839. .name = "SLIMBUS_7_RX DRIFT",
  2840. .info = msm_dai_q6_slim_rx_drift_info,
  2841. .get = msm_dai_q6_slim_rx_drift_get,
  2842. },
  2843. };
  2844. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  2845. {
  2846. struct msm_dai_q6_dai_data *dai_data;
  2847. int rc = 0;
  2848. if (!dai) {
  2849. pr_err("%s: Invalid params dai\n", __func__);
  2850. return -EINVAL;
  2851. }
  2852. if (!dai->dev) {
  2853. pr_err("%s: Invalid params dai dev\n", __func__);
  2854. return -EINVAL;
  2855. }
  2856. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  2857. if (!dai_data)
  2858. rc = -ENOMEM;
  2859. else
  2860. dev_set_drvdata(dai->dev, dai_data);
  2861. msm_dai_q6_set_dai_id(dai);
  2862. switch (dai->id) {
  2863. case SLIMBUS_4_TX:
  2864. rc = snd_ctl_add(dai->component->card->snd_card,
  2865. snd_ctl_new1(&sb_config_controls[0],
  2866. dai_data));
  2867. break;
  2868. case SLIMBUS_2_RX:
  2869. rc = snd_ctl_add(dai->component->card->snd_card,
  2870. snd_ctl_new1(&sb_config_controls[1],
  2871. dai_data));
  2872. rc = snd_ctl_add(dai->component->card->snd_card,
  2873. snd_ctl_new1(&sb_config_controls[2],
  2874. dai_data));
  2875. break;
  2876. case SLIMBUS_7_RX:
  2877. rc = snd_ctl_add(dai->component->card->snd_card,
  2878. snd_ctl_new1(&afe_enc_config_controls[0],
  2879. dai_data));
  2880. rc = snd_ctl_add(dai->component->card->snd_card,
  2881. snd_ctl_new1(&afe_enc_config_controls[1],
  2882. dai_data));
  2883. rc = snd_ctl_add(dai->component->card->snd_card,
  2884. snd_ctl_new1(&afe_enc_config_controls[2],
  2885. dai_data));
  2886. rc = snd_ctl_add(dai->component->card->snd_card,
  2887. snd_ctl_new1(&afe_enc_config_controls[3],
  2888. dai_data));
  2889. rc = snd_ctl_add(dai->component->card->snd_card,
  2890. snd_ctl_new1(&avd_drift_config_controls[2],
  2891. dai));
  2892. break;
  2893. case SLIMBUS_7_TX:
  2894. rc = snd_ctl_add(dai->component->card->snd_card,
  2895. snd_ctl_new1(&afe_dec_config_controls[0],
  2896. dai_data));
  2897. break;
  2898. case RT_PROXY_DAI_001_RX:
  2899. rc = snd_ctl_add(dai->component->card->snd_card,
  2900. snd_ctl_new1(&rt_proxy_config_controls[0],
  2901. dai_data));
  2902. break;
  2903. case RT_PROXY_DAI_001_TX:
  2904. rc = snd_ctl_add(dai->component->card->snd_card,
  2905. snd_ctl_new1(&rt_proxy_config_controls[1],
  2906. dai_data));
  2907. break;
  2908. case AFE_PORT_ID_USB_RX:
  2909. rc = snd_ctl_add(dai->component->card->snd_card,
  2910. snd_ctl_new1(&usb_audio_cfg_controls[0],
  2911. dai_data));
  2912. rc = snd_ctl_add(dai->component->card->snd_card,
  2913. snd_ctl_new1(&usb_audio_cfg_controls[1],
  2914. dai_data));
  2915. rc = snd_ctl_add(dai->component->card->snd_card,
  2916. snd_ctl_new1(&usb_audio_cfg_controls[4],
  2917. dai_data));
  2918. break;
  2919. case AFE_PORT_ID_USB_TX:
  2920. rc = snd_ctl_add(dai->component->card->snd_card,
  2921. snd_ctl_new1(&usb_audio_cfg_controls[2],
  2922. dai_data));
  2923. rc = snd_ctl_add(dai->component->card->snd_card,
  2924. snd_ctl_new1(&usb_audio_cfg_controls[3],
  2925. dai_data));
  2926. break;
  2927. case SLIMBUS_0_RX:
  2928. rc = snd_ctl_add(dai->component->card->snd_card,
  2929. snd_ctl_new1(&avd_drift_config_controls[0],
  2930. dai));
  2931. break;
  2932. case SLIMBUS_6_RX:
  2933. rc = snd_ctl_add(dai->component->card->snd_card,
  2934. snd_ctl_new1(&avd_drift_config_controls[1],
  2935. dai));
  2936. break;
  2937. }
  2938. if (rc < 0)
  2939. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  2940. __func__, dai->name);
  2941. rc = msm_dai_q6_dai_add_route(dai);
  2942. return rc;
  2943. }
  2944. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  2945. {
  2946. struct msm_dai_q6_dai_data *dai_data;
  2947. int rc;
  2948. dai_data = dev_get_drvdata(dai->dev);
  2949. /* If AFE port is still up, close it */
  2950. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2951. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2952. rc = afe_close(dai->id); /* can block */
  2953. if (rc < 0)
  2954. dev_err(dai->dev, "fail to close AFE port\n");
  2955. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2956. }
  2957. kfree(dai_data);
  2958. return 0;
  2959. }
  2960. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  2961. {
  2962. .playback = {
  2963. .stream_name = "AFE Playback",
  2964. .aif_name = "PCM_RX",
  2965. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2966. SNDRV_PCM_RATE_16000,
  2967. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2968. SNDRV_PCM_FMTBIT_S24_LE,
  2969. .channels_min = 1,
  2970. .channels_max = 2,
  2971. .rate_min = 8000,
  2972. .rate_max = 48000,
  2973. },
  2974. .ops = &msm_dai_q6_ops,
  2975. .id = RT_PROXY_DAI_001_RX,
  2976. .probe = msm_dai_q6_dai_probe,
  2977. .remove = msm_dai_q6_dai_remove,
  2978. },
  2979. {
  2980. .playback = {
  2981. .stream_name = "AFE-PROXY RX",
  2982. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2983. SNDRV_PCM_RATE_16000,
  2984. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2985. SNDRV_PCM_FMTBIT_S24_LE,
  2986. .channels_min = 1,
  2987. .channels_max = 2,
  2988. .rate_min = 8000,
  2989. .rate_max = 48000,
  2990. },
  2991. .ops = &msm_dai_q6_ops,
  2992. .id = RT_PROXY_DAI_002_RX,
  2993. .probe = msm_dai_q6_dai_probe,
  2994. .remove = msm_dai_q6_dai_remove,
  2995. },
  2996. };
  2997. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  2998. {
  2999. .capture = {
  3000. .stream_name = "AFE Capture",
  3001. .aif_name = "PCM_TX",
  3002. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3003. SNDRV_PCM_RATE_16000,
  3004. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3005. .channels_min = 1,
  3006. .channels_max = 8,
  3007. .rate_min = 8000,
  3008. .rate_max = 48000,
  3009. },
  3010. .ops = &msm_dai_q6_ops,
  3011. .id = RT_PROXY_DAI_002_TX,
  3012. .probe = msm_dai_q6_dai_probe,
  3013. .remove = msm_dai_q6_dai_remove,
  3014. },
  3015. {
  3016. .capture = {
  3017. .stream_name = "AFE-PROXY TX",
  3018. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3019. SNDRV_PCM_RATE_16000,
  3020. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3021. .channels_min = 1,
  3022. .channels_max = 8,
  3023. .rate_min = 8000,
  3024. .rate_max = 48000,
  3025. },
  3026. .ops = &msm_dai_q6_ops,
  3027. .id = RT_PROXY_DAI_001_TX,
  3028. .probe = msm_dai_q6_dai_probe,
  3029. .remove = msm_dai_q6_dai_remove,
  3030. },
  3031. };
  3032. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  3033. .playback = {
  3034. .stream_name = "Internal BT-SCO Playback",
  3035. .aif_name = "INT_BT_SCO_RX",
  3036. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3037. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3038. .channels_min = 1,
  3039. .channels_max = 1,
  3040. .rate_max = 16000,
  3041. .rate_min = 8000,
  3042. },
  3043. .ops = &msm_dai_q6_ops,
  3044. .id = INT_BT_SCO_RX,
  3045. .probe = msm_dai_q6_dai_probe,
  3046. .remove = msm_dai_q6_dai_remove,
  3047. };
  3048. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  3049. .playback = {
  3050. .stream_name = "Internal BT-A2DP Playback",
  3051. .aif_name = "INT_BT_A2DP_RX",
  3052. .rates = SNDRV_PCM_RATE_48000,
  3053. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3054. .channels_min = 1,
  3055. .channels_max = 2,
  3056. .rate_max = 48000,
  3057. .rate_min = 48000,
  3058. },
  3059. .ops = &msm_dai_q6_ops,
  3060. .id = INT_BT_A2DP_RX,
  3061. .probe = msm_dai_q6_dai_probe,
  3062. .remove = msm_dai_q6_dai_remove,
  3063. };
  3064. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  3065. .capture = {
  3066. .stream_name = "Internal BT-SCO Capture",
  3067. .aif_name = "INT_BT_SCO_TX",
  3068. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3069. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3070. .channels_min = 1,
  3071. .channels_max = 1,
  3072. .rate_max = 16000,
  3073. .rate_min = 8000,
  3074. },
  3075. .ops = &msm_dai_q6_ops,
  3076. .id = INT_BT_SCO_TX,
  3077. .probe = msm_dai_q6_dai_probe,
  3078. .remove = msm_dai_q6_dai_remove,
  3079. };
  3080. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  3081. .playback = {
  3082. .stream_name = "Internal FM Playback",
  3083. .aif_name = "INT_FM_RX",
  3084. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3085. SNDRV_PCM_RATE_16000,
  3086. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3087. .channels_min = 2,
  3088. .channels_max = 2,
  3089. .rate_max = 48000,
  3090. .rate_min = 8000,
  3091. },
  3092. .ops = &msm_dai_q6_ops,
  3093. .id = INT_FM_RX,
  3094. .probe = msm_dai_q6_dai_probe,
  3095. .remove = msm_dai_q6_dai_remove,
  3096. };
  3097. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  3098. .capture = {
  3099. .stream_name = "Internal FM Capture",
  3100. .aif_name = "INT_FM_TX",
  3101. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3102. SNDRV_PCM_RATE_16000,
  3103. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3104. .channels_min = 2,
  3105. .channels_max = 2,
  3106. .rate_max = 48000,
  3107. .rate_min = 8000,
  3108. },
  3109. .ops = &msm_dai_q6_ops,
  3110. .id = INT_FM_TX,
  3111. .probe = msm_dai_q6_dai_probe,
  3112. .remove = msm_dai_q6_dai_remove,
  3113. };
  3114. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  3115. {
  3116. .playback = {
  3117. .stream_name = "Voice Farend Playback",
  3118. .aif_name = "VOICE_PLAYBACK_TX",
  3119. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3120. SNDRV_PCM_RATE_16000,
  3121. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3122. .channels_min = 1,
  3123. .channels_max = 2,
  3124. .rate_min = 8000,
  3125. .rate_max = 48000,
  3126. },
  3127. .ops = &msm_dai_q6_ops,
  3128. .id = VOICE_PLAYBACK_TX,
  3129. .probe = msm_dai_q6_dai_probe,
  3130. .remove = msm_dai_q6_dai_remove,
  3131. },
  3132. {
  3133. .playback = {
  3134. .stream_name = "Voice2 Farend Playback",
  3135. .aif_name = "VOICE2_PLAYBACK_TX",
  3136. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3137. SNDRV_PCM_RATE_16000,
  3138. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3139. .channels_min = 1,
  3140. .channels_max = 2,
  3141. .rate_min = 8000,
  3142. .rate_max = 48000,
  3143. },
  3144. .ops = &msm_dai_q6_ops,
  3145. .id = VOICE2_PLAYBACK_TX,
  3146. .probe = msm_dai_q6_dai_probe,
  3147. .remove = msm_dai_q6_dai_remove,
  3148. },
  3149. };
  3150. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  3151. {
  3152. .capture = {
  3153. .stream_name = "Voice Uplink Capture",
  3154. .aif_name = "INCALL_RECORD_TX",
  3155. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3156. SNDRV_PCM_RATE_16000,
  3157. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3158. .channels_min = 1,
  3159. .channels_max = 2,
  3160. .rate_min = 8000,
  3161. .rate_max = 48000,
  3162. },
  3163. .ops = &msm_dai_q6_ops,
  3164. .id = VOICE_RECORD_TX,
  3165. .probe = msm_dai_q6_dai_probe,
  3166. .remove = msm_dai_q6_dai_remove,
  3167. },
  3168. {
  3169. .capture = {
  3170. .stream_name = "Voice Downlink Capture",
  3171. .aif_name = "INCALL_RECORD_RX",
  3172. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3173. SNDRV_PCM_RATE_16000,
  3174. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3175. .channels_min = 1,
  3176. .channels_max = 2,
  3177. .rate_min = 8000,
  3178. .rate_max = 48000,
  3179. },
  3180. .ops = &msm_dai_q6_ops,
  3181. .id = VOICE_RECORD_RX,
  3182. .probe = msm_dai_q6_dai_probe,
  3183. .remove = msm_dai_q6_dai_remove,
  3184. },
  3185. };
  3186. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  3187. .playback = {
  3188. .stream_name = "USB Audio Playback",
  3189. .aif_name = "USB_AUDIO_RX",
  3190. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3191. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3192. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3193. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3194. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3195. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3196. SNDRV_PCM_RATE_384000,
  3197. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3198. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3199. .channels_min = 1,
  3200. .channels_max = 8,
  3201. .rate_max = 384000,
  3202. .rate_min = 8000,
  3203. },
  3204. .ops = &msm_dai_q6_ops,
  3205. .id = AFE_PORT_ID_USB_RX,
  3206. .probe = msm_dai_q6_dai_probe,
  3207. .remove = msm_dai_q6_dai_remove,
  3208. };
  3209. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  3210. .capture = {
  3211. .stream_name = "USB Audio Capture",
  3212. .aif_name = "USB_AUDIO_TX",
  3213. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3214. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3215. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3216. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3217. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3218. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3219. SNDRV_PCM_RATE_384000,
  3220. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3221. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3222. .channels_min = 1,
  3223. .channels_max = 8,
  3224. .rate_max = 384000,
  3225. .rate_min = 8000,
  3226. },
  3227. .ops = &msm_dai_q6_ops,
  3228. .id = AFE_PORT_ID_USB_TX,
  3229. .probe = msm_dai_q6_dai_probe,
  3230. .remove = msm_dai_q6_dai_remove,
  3231. };
  3232. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  3233. {
  3234. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3235. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  3236. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  3237. uint32_t val = 0;
  3238. const char *intf_name;
  3239. int rc = 0, i = 0, len = 0;
  3240. const uint32_t *slot_mapping_array = NULL;
  3241. u32 array_length = 0;
  3242. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  3243. GFP_KERNEL);
  3244. if (!dai_data)
  3245. return -ENOMEM;
  3246. rc = of_property_read_u32(pdev->dev.of_node,
  3247. "qcom,msm-dai-is-island-supported",
  3248. &dai_data->is_island_dai);
  3249. if (rc)
  3250. dev_dbg(&pdev->dev, "island supported entry not found\n");
  3251. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  3252. GFP_KERNEL);
  3253. if (!auxpcm_pdata) {
  3254. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  3255. goto fail_pdata_nomem;
  3256. }
  3257. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  3258. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  3259. rc = of_property_read_u32_array(pdev->dev.of_node,
  3260. "qcom,msm-cpudai-auxpcm-mode",
  3261. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3262. if (rc) {
  3263. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  3264. __func__);
  3265. goto fail_invalid_dt;
  3266. }
  3267. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  3268. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  3269. rc = of_property_read_u32_array(pdev->dev.of_node,
  3270. "qcom,msm-cpudai-auxpcm-sync",
  3271. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3272. if (rc) {
  3273. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  3274. __func__);
  3275. goto fail_invalid_dt;
  3276. }
  3277. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  3278. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  3279. rc = of_property_read_u32_array(pdev->dev.of_node,
  3280. "qcom,msm-cpudai-auxpcm-frame",
  3281. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3282. if (rc) {
  3283. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  3284. __func__);
  3285. goto fail_invalid_dt;
  3286. }
  3287. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  3288. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  3289. rc = of_property_read_u32_array(pdev->dev.of_node,
  3290. "qcom,msm-cpudai-auxpcm-quant",
  3291. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3292. if (rc) {
  3293. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  3294. __func__);
  3295. goto fail_invalid_dt;
  3296. }
  3297. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  3298. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  3299. rc = of_property_read_u32_array(pdev->dev.of_node,
  3300. "qcom,msm-cpudai-auxpcm-num-slots",
  3301. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3302. if (rc) {
  3303. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  3304. __func__);
  3305. goto fail_invalid_dt;
  3306. }
  3307. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  3308. if (auxpcm_pdata->mode_8k.num_slots >
  3309. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  3310. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3311. __func__,
  3312. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  3313. auxpcm_pdata->mode_8k.num_slots);
  3314. rc = -EINVAL;
  3315. goto fail_invalid_dt;
  3316. }
  3317. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  3318. if (auxpcm_pdata->mode_16k.num_slots >
  3319. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  3320. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3321. __func__,
  3322. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  3323. auxpcm_pdata->mode_16k.num_slots);
  3324. rc = -EINVAL;
  3325. goto fail_invalid_dt;
  3326. }
  3327. slot_mapping_array = of_get_property(pdev->dev.of_node,
  3328. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  3329. if (slot_mapping_array == NULL) {
  3330. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  3331. __func__);
  3332. rc = -EINVAL;
  3333. goto fail_invalid_dt;
  3334. }
  3335. array_length = auxpcm_pdata->mode_8k.num_slots +
  3336. auxpcm_pdata->mode_16k.num_slots;
  3337. if (len != sizeof(uint32_t) * array_length) {
  3338. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  3339. __func__, len, sizeof(uint32_t) * array_length);
  3340. rc = -EINVAL;
  3341. goto fail_invalid_dt;
  3342. }
  3343. auxpcm_pdata->mode_8k.slot_mapping =
  3344. kzalloc(sizeof(uint16_t) *
  3345. auxpcm_pdata->mode_8k.num_slots,
  3346. GFP_KERNEL);
  3347. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  3348. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  3349. __func__);
  3350. rc = -ENOMEM;
  3351. goto fail_invalid_dt;
  3352. }
  3353. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  3354. auxpcm_pdata->mode_8k.slot_mapping[i] =
  3355. (u16)be32_to_cpu(slot_mapping_array[i]);
  3356. auxpcm_pdata->mode_16k.slot_mapping =
  3357. kzalloc(sizeof(uint16_t) *
  3358. auxpcm_pdata->mode_16k.num_slots,
  3359. GFP_KERNEL);
  3360. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  3361. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  3362. __func__);
  3363. rc = -ENOMEM;
  3364. goto fail_invalid_16k_slot_mapping;
  3365. }
  3366. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  3367. auxpcm_pdata->mode_16k.slot_mapping[i] =
  3368. (u16)be32_to_cpu(slot_mapping_array[i +
  3369. auxpcm_pdata->mode_8k.num_slots]);
  3370. rc = of_property_read_u32_array(pdev->dev.of_node,
  3371. "qcom,msm-cpudai-auxpcm-data",
  3372. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3373. if (rc) {
  3374. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  3375. __func__);
  3376. goto fail_invalid_dt1;
  3377. }
  3378. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  3379. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  3380. rc = of_property_read_u32_array(pdev->dev.of_node,
  3381. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  3382. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3383. if (rc) {
  3384. dev_err(&pdev->dev,
  3385. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  3386. __func__);
  3387. goto fail_invalid_dt1;
  3388. }
  3389. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  3390. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  3391. rc = of_property_read_string(pdev->dev.of_node,
  3392. "qcom,msm-auxpcm-interface", &intf_name);
  3393. if (rc) {
  3394. dev_err(&pdev->dev,
  3395. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  3396. __func__);
  3397. goto fail_nodev_intf;
  3398. }
  3399. if (!strcmp(intf_name, "primary")) {
  3400. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  3401. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  3402. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  3403. i = 0;
  3404. } else if (!strcmp(intf_name, "secondary")) {
  3405. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  3406. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  3407. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  3408. i = 1;
  3409. } else if (!strcmp(intf_name, "tertiary")) {
  3410. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  3411. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  3412. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  3413. i = 2;
  3414. } else if (!strcmp(intf_name, "quaternary")) {
  3415. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  3416. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  3417. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  3418. i = 3;
  3419. } else if (!strcmp(intf_name, "quinary")) {
  3420. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  3421. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  3422. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  3423. i = 4;
  3424. } else {
  3425. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  3426. __func__, intf_name);
  3427. goto fail_invalid_intf;
  3428. }
  3429. rc = of_property_read_u32(pdev->dev.of_node,
  3430. "qcom,msm-cpudai-afe-clk-ver", &val);
  3431. if (rc)
  3432. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  3433. else
  3434. dai_data->afe_clk_ver = val;
  3435. mutex_init(&dai_data->rlock);
  3436. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  3437. dev_set_drvdata(&pdev->dev, dai_data);
  3438. pdev->dev.platform_data = (void *) auxpcm_pdata;
  3439. rc = snd_soc_register_component(&pdev->dev,
  3440. &msm_dai_q6_aux_pcm_dai_component,
  3441. &msm_dai_q6_aux_pcm_dai[i], 1);
  3442. if (rc) {
  3443. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  3444. __func__, rc);
  3445. goto fail_reg_dai;
  3446. }
  3447. return rc;
  3448. fail_reg_dai:
  3449. fail_invalid_intf:
  3450. fail_nodev_intf:
  3451. fail_invalid_dt1:
  3452. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  3453. fail_invalid_16k_slot_mapping:
  3454. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  3455. fail_invalid_dt:
  3456. kfree(auxpcm_pdata);
  3457. fail_pdata_nomem:
  3458. kfree(dai_data);
  3459. return rc;
  3460. }
  3461. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  3462. {
  3463. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3464. dai_data = dev_get_drvdata(&pdev->dev);
  3465. snd_soc_unregister_component(&pdev->dev);
  3466. mutex_destroy(&dai_data->rlock);
  3467. kfree(dai_data);
  3468. kfree(pdev->dev.platform_data);
  3469. return 0;
  3470. }
  3471. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  3472. { .compatible = "qcom,msm-auxpcm-dev", },
  3473. {}
  3474. };
  3475. static struct platform_driver msm_auxpcm_dev_driver = {
  3476. .probe = msm_auxpcm_dev_probe,
  3477. .remove = msm_auxpcm_dev_remove,
  3478. .driver = {
  3479. .name = "msm-auxpcm-dev",
  3480. .owner = THIS_MODULE,
  3481. .of_match_table = msm_auxpcm_dev_dt_match,
  3482. },
  3483. };
  3484. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  3485. {
  3486. .playback = {
  3487. .stream_name = "Slimbus Playback",
  3488. .aif_name = "SLIMBUS_0_RX",
  3489. .rates = SNDRV_PCM_RATE_8000_384000,
  3490. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3491. .channels_min = 1,
  3492. .channels_max = 8,
  3493. .rate_min = 8000,
  3494. .rate_max = 384000,
  3495. },
  3496. .ops = &msm_dai_q6_ops,
  3497. .id = SLIMBUS_0_RX,
  3498. .probe = msm_dai_q6_dai_probe,
  3499. .remove = msm_dai_q6_dai_remove,
  3500. },
  3501. {
  3502. .playback = {
  3503. .stream_name = "Slimbus1 Playback",
  3504. .aif_name = "SLIMBUS_1_RX",
  3505. .rates = SNDRV_PCM_RATE_8000_384000,
  3506. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3507. .channels_min = 1,
  3508. .channels_max = 2,
  3509. .rate_min = 8000,
  3510. .rate_max = 384000,
  3511. },
  3512. .ops = &msm_dai_q6_ops,
  3513. .id = SLIMBUS_1_RX,
  3514. .probe = msm_dai_q6_dai_probe,
  3515. .remove = msm_dai_q6_dai_remove,
  3516. },
  3517. {
  3518. .playback = {
  3519. .stream_name = "Slimbus2 Playback",
  3520. .aif_name = "SLIMBUS_2_RX",
  3521. .rates = SNDRV_PCM_RATE_8000_384000,
  3522. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3523. .channels_min = 1,
  3524. .channels_max = 8,
  3525. .rate_min = 8000,
  3526. .rate_max = 384000,
  3527. },
  3528. .ops = &msm_dai_q6_ops,
  3529. .id = SLIMBUS_2_RX,
  3530. .probe = msm_dai_q6_dai_probe,
  3531. .remove = msm_dai_q6_dai_remove,
  3532. },
  3533. {
  3534. .playback = {
  3535. .stream_name = "Slimbus3 Playback",
  3536. .aif_name = "SLIMBUS_3_RX",
  3537. .rates = SNDRV_PCM_RATE_8000_384000,
  3538. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3539. .channels_min = 1,
  3540. .channels_max = 2,
  3541. .rate_min = 8000,
  3542. .rate_max = 384000,
  3543. },
  3544. .ops = &msm_dai_q6_ops,
  3545. .id = SLIMBUS_3_RX,
  3546. .probe = msm_dai_q6_dai_probe,
  3547. .remove = msm_dai_q6_dai_remove,
  3548. },
  3549. {
  3550. .playback = {
  3551. .stream_name = "Slimbus4 Playback",
  3552. .aif_name = "SLIMBUS_4_RX",
  3553. .rates = SNDRV_PCM_RATE_8000_384000,
  3554. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3555. .channels_min = 1,
  3556. .channels_max = 2,
  3557. .rate_min = 8000,
  3558. .rate_max = 384000,
  3559. },
  3560. .ops = &msm_dai_q6_ops,
  3561. .id = SLIMBUS_4_RX,
  3562. .probe = msm_dai_q6_dai_probe,
  3563. .remove = msm_dai_q6_dai_remove,
  3564. },
  3565. {
  3566. .playback = {
  3567. .stream_name = "Slimbus6 Playback",
  3568. .aif_name = "SLIMBUS_6_RX",
  3569. .rates = SNDRV_PCM_RATE_8000_384000,
  3570. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3571. .channels_min = 1,
  3572. .channels_max = 2,
  3573. .rate_min = 8000,
  3574. .rate_max = 384000,
  3575. },
  3576. .ops = &msm_dai_q6_ops,
  3577. .id = SLIMBUS_6_RX,
  3578. .probe = msm_dai_q6_dai_probe,
  3579. .remove = msm_dai_q6_dai_remove,
  3580. },
  3581. {
  3582. .playback = {
  3583. .stream_name = "Slimbus5 Playback",
  3584. .aif_name = "SLIMBUS_5_RX",
  3585. .rates = SNDRV_PCM_RATE_8000_384000,
  3586. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3587. .channels_min = 1,
  3588. .channels_max = 2,
  3589. .rate_min = 8000,
  3590. .rate_max = 384000,
  3591. },
  3592. .ops = &msm_dai_q6_ops,
  3593. .id = SLIMBUS_5_RX,
  3594. .probe = msm_dai_q6_dai_probe,
  3595. .remove = msm_dai_q6_dai_remove,
  3596. },
  3597. {
  3598. .playback = {
  3599. .stream_name = "Slimbus7 Playback",
  3600. .aif_name = "SLIMBUS_7_RX",
  3601. .rates = SNDRV_PCM_RATE_8000_384000,
  3602. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3603. .channels_min = 1,
  3604. .channels_max = 8,
  3605. .rate_min = 8000,
  3606. .rate_max = 384000,
  3607. },
  3608. .ops = &msm_dai_q6_ops,
  3609. .id = SLIMBUS_7_RX,
  3610. .probe = msm_dai_q6_dai_probe,
  3611. .remove = msm_dai_q6_dai_remove,
  3612. },
  3613. {
  3614. .playback = {
  3615. .stream_name = "Slimbus8 Playback",
  3616. .aif_name = "SLIMBUS_8_RX",
  3617. .rates = SNDRV_PCM_RATE_8000_384000,
  3618. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3619. .channels_min = 1,
  3620. .channels_max = 8,
  3621. .rate_min = 8000,
  3622. .rate_max = 384000,
  3623. },
  3624. .ops = &msm_dai_q6_ops,
  3625. .id = SLIMBUS_8_RX,
  3626. .probe = msm_dai_q6_dai_probe,
  3627. .remove = msm_dai_q6_dai_remove,
  3628. },
  3629. };
  3630. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  3631. {
  3632. .capture = {
  3633. .stream_name = "Slimbus Capture",
  3634. .aif_name = "SLIMBUS_0_TX",
  3635. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3636. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3637. SNDRV_PCM_RATE_192000,
  3638. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3639. SNDRV_PCM_FMTBIT_S24_LE |
  3640. SNDRV_PCM_FMTBIT_S24_3LE,
  3641. .channels_min = 1,
  3642. .channels_max = 8,
  3643. .rate_min = 8000,
  3644. .rate_max = 192000,
  3645. },
  3646. .ops = &msm_dai_q6_ops,
  3647. .id = SLIMBUS_0_TX,
  3648. .probe = msm_dai_q6_dai_probe,
  3649. .remove = msm_dai_q6_dai_remove,
  3650. },
  3651. {
  3652. .capture = {
  3653. .stream_name = "Slimbus1 Capture",
  3654. .aif_name = "SLIMBUS_1_TX",
  3655. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3656. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3657. SNDRV_PCM_RATE_192000,
  3658. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3659. SNDRV_PCM_FMTBIT_S24_LE |
  3660. SNDRV_PCM_FMTBIT_S24_3LE,
  3661. .channels_min = 1,
  3662. .channels_max = 2,
  3663. .rate_min = 8000,
  3664. .rate_max = 192000,
  3665. },
  3666. .ops = &msm_dai_q6_ops,
  3667. .id = SLIMBUS_1_TX,
  3668. .probe = msm_dai_q6_dai_probe,
  3669. .remove = msm_dai_q6_dai_remove,
  3670. },
  3671. {
  3672. .capture = {
  3673. .stream_name = "Slimbus2 Capture",
  3674. .aif_name = "SLIMBUS_2_TX",
  3675. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3676. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3677. SNDRV_PCM_RATE_192000,
  3678. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3679. SNDRV_PCM_FMTBIT_S24_LE,
  3680. .channels_min = 1,
  3681. .channels_max = 8,
  3682. .rate_min = 8000,
  3683. .rate_max = 192000,
  3684. },
  3685. .ops = &msm_dai_q6_ops,
  3686. .id = SLIMBUS_2_TX,
  3687. .probe = msm_dai_q6_dai_probe,
  3688. .remove = msm_dai_q6_dai_remove,
  3689. },
  3690. {
  3691. .capture = {
  3692. .stream_name = "Slimbus3 Capture",
  3693. .aif_name = "SLIMBUS_3_TX",
  3694. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3695. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3696. SNDRV_PCM_RATE_192000,
  3697. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3698. SNDRV_PCM_FMTBIT_S24_LE,
  3699. .channels_min = 2,
  3700. .channels_max = 4,
  3701. .rate_min = 8000,
  3702. .rate_max = 192000,
  3703. },
  3704. .ops = &msm_dai_q6_ops,
  3705. .id = SLIMBUS_3_TX,
  3706. .probe = msm_dai_q6_dai_probe,
  3707. .remove = msm_dai_q6_dai_remove,
  3708. },
  3709. {
  3710. .capture = {
  3711. .stream_name = "Slimbus4 Capture",
  3712. .aif_name = "SLIMBUS_4_TX",
  3713. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3714. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3715. SNDRV_PCM_RATE_192000,
  3716. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3717. SNDRV_PCM_FMTBIT_S24_LE |
  3718. SNDRV_PCM_FMTBIT_S32_LE,
  3719. .channels_min = 2,
  3720. .channels_max = 4,
  3721. .rate_min = 8000,
  3722. .rate_max = 192000,
  3723. },
  3724. .ops = &msm_dai_q6_ops,
  3725. .id = SLIMBUS_4_TX,
  3726. .probe = msm_dai_q6_dai_probe,
  3727. .remove = msm_dai_q6_dai_remove,
  3728. },
  3729. {
  3730. .capture = {
  3731. .stream_name = "Slimbus5 Capture",
  3732. .aif_name = "SLIMBUS_5_TX",
  3733. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3734. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3735. SNDRV_PCM_RATE_192000,
  3736. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3737. SNDRV_PCM_FMTBIT_S24_LE,
  3738. .channels_min = 1,
  3739. .channels_max = 8,
  3740. .rate_min = 8000,
  3741. .rate_max = 192000,
  3742. },
  3743. .ops = &msm_dai_q6_ops,
  3744. .id = SLIMBUS_5_TX,
  3745. .probe = msm_dai_q6_dai_probe,
  3746. .remove = msm_dai_q6_dai_remove,
  3747. },
  3748. {
  3749. .capture = {
  3750. .stream_name = "Slimbus6 Capture",
  3751. .aif_name = "SLIMBUS_6_TX",
  3752. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3753. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3754. SNDRV_PCM_RATE_192000,
  3755. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3756. SNDRV_PCM_FMTBIT_S24_LE,
  3757. .channels_min = 1,
  3758. .channels_max = 2,
  3759. .rate_min = 8000,
  3760. .rate_max = 192000,
  3761. },
  3762. .ops = &msm_dai_q6_ops,
  3763. .id = SLIMBUS_6_TX,
  3764. .probe = msm_dai_q6_dai_probe,
  3765. .remove = msm_dai_q6_dai_remove,
  3766. },
  3767. {
  3768. .capture = {
  3769. .stream_name = "Slimbus7 Capture",
  3770. .aif_name = "SLIMBUS_7_TX",
  3771. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3772. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3773. SNDRV_PCM_RATE_192000,
  3774. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3775. SNDRV_PCM_FMTBIT_S24_LE |
  3776. SNDRV_PCM_FMTBIT_S32_LE,
  3777. .channels_min = 1,
  3778. .channels_max = 8,
  3779. .rate_min = 8000,
  3780. .rate_max = 192000,
  3781. },
  3782. .ops = &msm_dai_q6_ops,
  3783. .id = SLIMBUS_7_TX,
  3784. .probe = msm_dai_q6_dai_probe,
  3785. .remove = msm_dai_q6_dai_remove,
  3786. },
  3787. {
  3788. .capture = {
  3789. .stream_name = "Slimbus8 Capture",
  3790. .aif_name = "SLIMBUS_8_TX",
  3791. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3792. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3793. SNDRV_PCM_RATE_192000,
  3794. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3795. SNDRV_PCM_FMTBIT_S24_LE |
  3796. SNDRV_PCM_FMTBIT_S32_LE,
  3797. .channels_min = 1,
  3798. .channels_max = 8,
  3799. .rate_min = 8000,
  3800. .rate_max = 192000,
  3801. },
  3802. .ops = &msm_dai_q6_ops,
  3803. .id = SLIMBUS_8_TX,
  3804. .probe = msm_dai_q6_dai_probe,
  3805. .remove = msm_dai_q6_dai_remove,
  3806. },
  3807. };
  3808. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  3809. struct snd_ctl_elem_value *ucontrol)
  3810. {
  3811. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3812. int value = ucontrol->value.integer.value[0];
  3813. dai_data->port_config.i2s.data_format = value;
  3814. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  3815. __func__, value, dai_data->port_config.i2s.mono_stereo,
  3816. dai_data->port_config.i2s.channel_mode);
  3817. return 0;
  3818. }
  3819. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  3820. struct snd_ctl_elem_value *ucontrol)
  3821. {
  3822. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3823. ucontrol->value.integer.value[0] =
  3824. dai_data->port_config.i2s.data_format;
  3825. return 0;
  3826. }
  3827. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  3828. struct snd_ctl_elem_value *ucontrol)
  3829. {
  3830. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3831. int value = ucontrol->value.integer.value[0];
  3832. dai_data->vi_feed_mono = value;
  3833. pr_debug("%s: value = %d\n", __func__, value);
  3834. return 0;
  3835. }
  3836. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  3837. struct snd_ctl_elem_value *ucontrol)
  3838. {
  3839. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3840. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  3841. return 0;
  3842. }
  3843. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  3844. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  3845. msm_dai_q6_mi2s_format_get,
  3846. msm_dai_q6_mi2s_format_put),
  3847. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  3848. msm_dai_q6_mi2s_format_get,
  3849. msm_dai_q6_mi2s_format_put),
  3850. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  3851. msm_dai_q6_mi2s_format_get,
  3852. msm_dai_q6_mi2s_format_put),
  3853. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  3854. msm_dai_q6_mi2s_format_get,
  3855. msm_dai_q6_mi2s_format_put),
  3856. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  3857. msm_dai_q6_mi2s_format_get,
  3858. msm_dai_q6_mi2s_format_put),
  3859. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  3860. msm_dai_q6_mi2s_format_get,
  3861. msm_dai_q6_mi2s_format_put),
  3862. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  3863. msm_dai_q6_mi2s_format_get,
  3864. msm_dai_q6_mi2s_format_put),
  3865. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  3866. msm_dai_q6_mi2s_format_get,
  3867. msm_dai_q6_mi2s_format_put),
  3868. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  3869. msm_dai_q6_mi2s_format_get,
  3870. msm_dai_q6_mi2s_format_put),
  3871. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  3872. msm_dai_q6_mi2s_format_get,
  3873. msm_dai_q6_mi2s_format_put),
  3874. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  3875. msm_dai_q6_mi2s_format_get,
  3876. msm_dai_q6_mi2s_format_put),
  3877. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  3878. msm_dai_q6_mi2s_format_get,
  3879. msm_dai_q6_mi2s_format_put),
  3880. };
  3881. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  3882. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  3883. msm_dai_q6_mi2s_vi_feed_mono_get,
  3884. msm_dai_q6_mi2s_vi_feed_mono_put),
  3885. };
  3886. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  3887. {
  3888. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3889. dev_get_drvdata(dai->dev);
  3890. struct msm_mi2s_pdata *mi2s_pdata =
  3891. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  3892. struct snd_kcontrol *kcontrol = NULL;
  3893. int rc = 0;
  3894. const struct snd_kcontrol_new *ctrl = NULL;
  3895. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  3896. u16 dai_id = 0;
  3897. dai->id = mi2s_pdata->intf_id;
  3898. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3899. if (dai->id == MSM_PRIM_MI2S)
  3900. ctrl = &mi2s_config_controls[0];
  3901. if (dai->id == MSM_SEC_MI2S)
  3902. ctrl = &mi2s_config_controls[1];
  3903. if (dai->id == MSM_TERT_MI2S)
  3904. ctrl = &mi2s_config_controls[2];
  3905. if (dai->id == MSM_QUAT_MI2S)
  3906. ctrl = &mi2s_config_controls[3];
  3907. if (dai->id == MSM_QUIN_MI2S)
  3908. ctrl = &mi2s_config_controls[4];
  3909. }
  3910. if (ctrl) {
  3911. kcontrol = snd_ctl_new1(ctrl,
  3912. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  3913. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  3914. if (rc < 0) {
  3915. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  3916. __func__, dai->name);
  3917. goto rtn;
  3918. }
  3919. }
  3920. ctrl = NULL;
  3921. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3922. if (dai->id == MSM_PRIM_MI2S)
  3923. ctrl = &mi2s_config_controls[5];
  3924. if (dai->id == MSM_SEC_MI2S)
  3925. ctrl = &mi2s_config_controls[6];
  3926. if (dai->id == MSM_TERT_MI2S)
  3927. ctrl = &mi2s_config_controls[7];
  3928. if (dai->id == MSM_QUAT_MI2S)
  3929. ctrl = &mi2s_config_controls[8];
  3930. if (dai->id == MSM_QUIN_MI2S)
  3931. ctrl = &mi2s_config_controls[9];
  3932. if (dai->id == MSM_SENARY_MI2S)
  3933. ctrl = &mi2s_config_controls[10];
  3934. if (dai->id == MSM_INT5_MI2S)
  3935. ctrl = &mi2s_config_controls[11];
  3936. }
  3937. if (ctrl) {
  3938. rc = snd_ctl_add(dai->component->card->snd_card,
  3939. snd_ctl_new1(ctrl,
  3940. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3941. if (rc < 0) {
  3942. if (kcontrol)
  3943. snd_ctl_remove(dai->component->card->snd_card,
  3944. kcontrol);
  3945. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  3946. __func__, dai->name);
  3947. }
  3948. }
  3949. if (dai->id == MSM_INT5_MI2S)
  3950. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  3951. if (vi_feed_ctrl) {
  3952. rc = snd_ctl_add(dai->component->card->snd_card,
  3953. snd_ctl_new1(vi_feed_ctrl,
  3954. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3955. if (rc < 0) {
  3956. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  3957. __func__, dai->name);
  3958. }
  3959. }
  3960. if (mi2s_dai_data->is_island_dai) {
  3961. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  3962. &dai_id);
  3963. rc = msm_dai_q6_add_island_mx_ctls(
  3964. dai->component->card->snd_card,
  3965. dai->name, dai_id,
  3966. (void *)mi2s_dai_data);
  3967. }
  3968. rc = msm_dai_q6_dai_add_route(dai);
  3969. rtn:
  3970. return rc;
  3971. }
  3972. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  3973. {
  3974. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3975. dev_get_drvdata(dai->dev);
  3976. int rc;
  3977. /* If AFE port is still up, close it */
  3978. if (test_bit(STATUS_PORT_STARTED,
  3979. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  3980. rc = afe_close(MI2S_RX); /* can block */
  3981. if (rc < 0)
  3982. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  3983. clear_bit(STATUS_PORT_STARTED,
  3984. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  3985. }
  3986. if (test_bit(STATUS_PORT_STARTED,
  3987. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  3988. rc = afe_close(MI2S_TX); /* can block */
  3989. if (rc < 0)
  3990. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  3991. clear_bit(STATUS_PORT_STARTED,
  3992. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  3993. }
  3994. return 0;
  3995. }
  3996. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  3997. struct snd_soc_dai *dai)
  3998. {
  3999. return 0;
  4000. }
  4001. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  4002. {
  4003. int ret = 0;
  4004. switch (stream) {
  4005. case SNDRV_PCM_STREAM_PLAYBACK:
  4006. switch (mi2s_id) {
  4007. case MSM_PRIM_MI2S:
  4008. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  4009. break;
  4010. case MSM_SEC_MI2S:
  4011. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  4012. break;
  4013. case MSM_TERT_MI2S:
  4014. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  4015. break;
  4016. case MSM_QUAT_MI2S:
  4017. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  4018. break;
  4019. case MSM_SEC_MI2S_SD1:
  4020. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  4021. break;
  4022. case MSM_QUIN_MI2S:
  4023. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  4024. break;
  4025. case MSM_INT0_MI2S:
  4026. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  4027. break;
  4028. case MSM_INT1_MI2S:
  4029. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  4030. break;
  4031. case MSM_INT2_MI2S:
  4032. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  4033. break;
  4034. case MSM_INT3_MI2S:
  4035. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  4036. break;
  4037. case MSM_INT4_MI2S:
  4038. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  4039. break;
  4040. case MSM_INT5_MI2S:
  4041. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  4042. break;
  4043. case MSM_INT6_MI2S:
  4044. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  4045. break;
  4046. default:
  4047. pr_err("%s: playback err id 0x%x\n",
  4048. __func__, mi2s_id);
  4049. ret = -1;
  4050. break;
  4051. }
  4052. break;
  4053. case SNDRV_PCM_STREAM_CAPTURE:
  4054. switch (mi2s_id) {
  4055. case MSM_PRIM_MI2S:
  4056. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  4057. break;
  4058. case MSM_SEC_MI2S:
  4059. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  4060. break;
  4061. case MSM_TERT_MI2S:
  4062. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  4063. break;
  4064. case MSM_QUAT_MI2S:
  4065. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  4066. break;
  4067. case MSM_QUIN_MI2S:
  4068. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  4069. break;
  4070. case MSM_SENARY_MI2S:
  4071. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  4072. break;
  4073. case MSM_INT0_MI2S:
  4074. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  4075. break;
  4076. case MSM_INT1_MI2S:
  4077. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  4078. break;
  4079. case MSM_INT2_MI2S:
  4080. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  4081. break;
  4082. case MSM_INT3_MI2S:
  4083. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  4084. break;
  4085. case MSM_INT4_MI2S:
  4086. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  4087. break;
  4088. case MSM_INT5_MI2S:
  4089. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  4090. break;
  4091. case MSM_INT6_MI2S:
  4092. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  4093. break;
  4094. default:
  4095. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  4096. ret = -1;
  4097. break;
  4098. }
  4099. break;
  4100. default:
  4101. pr_err("%s: default err %d\n", __func__, stream);
  4102. ret = -1;
  4103. break;
  4104. }
  4105. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  4106. return ret;
  4107. }
  4108. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  4109. struct snd_soc_dai *dai)
  4110. {
  4111. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4112. dev_get_drvdata(dai->dev);
  4113. struct msm_dai_q6_dai_data *dai_data =
  4114. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4115. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4116. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4117. u16 port_id = 0;
  4118. int rc = 0;
  4119. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4120. &port_id) != 0) {
  4121. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4122. __func__, port_id);
  4123. return -EINVAL;
  4124. }
  4125. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  4126. "dai_data->channels = %u sample_rate = %u\n", __func__,
  4127. dai->id, port_id, dai_data->channels, dai_data->rate);
  4128. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4129. if (q6core_get_avcs_api_version_per_service(
  4130. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  4131. /*
  4132. * send island mode config.
  4133. * This should be the first configuration
  4134. */
  4135. rc = afe_send_port_island_mode(port_id);
  4136. if (rc)
  4137. dev_err(dai->dev, "%s: afe send island mode failed %d\n",
  4138. __func__, rc);
  4139. }
  4140. /* PORT START should be set if prepare called
  4141. * in active state.
  4142. */
  4143. rc = afe_port_start(port_id, &dai_data->port_config,
  4144. dai_data->rate);
  4145. if (rc < 0)
  4146. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  4147. dai->id);
  4148. else
  4149. set_bit(STATUS_PORT_STARTED,
  4150. dai_data->status_mask);
  4151. }
  4152. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4153. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4154. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  4155. __func__);
  4156. }
  4157. return rc;
  4158. }
  4159. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  4160. struct snd_pcm_hw_params *params,
  4161. struct snd_soc_dai *dai)
  4162. {
  4163. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4164. dev_get_drvdata(dai->dev);
  4165. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  4166. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4167. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  4168. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  4169. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  4170. dai_data->channels = params_channels(params);
  4171. switch (dai_data->channels) {
  4172. case 8:
  4173. case 7:
  4174. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  4175. goto error_invalid_data;
  4176. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_8CHS;
  4177. break;
  4178. case 6:
  4179. case 5:
  4180. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  4181. goto error_invalid_data;
  4182. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  4183. break;
  4184. case 4:
  4185. case 3:
  4186. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_QUAD01)
  4187. goto error_invalid_data;
  4188. if (mi2s_dai_config->pdata_mi2s_lines == AFE_PORT_I2S_QUAD23)
  4189. dai_data->port_config.i2s.channel_mode =
  4190. mi2s_dai_config->pdata_mi2s_lines;
  4191. else
  4192. dai_data->port_config.i2s.channel_mode =
  4193. AFE_PORT_I2S_QUAD01;
  4194. break;
  4195. case 2:
  4196. case 1:
  4197. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  4198. goto error_invalid_data;
  4199. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4200. case AFE_PORT_I2S_SD0:
  4201. case AFE_PORT_I2S_SD1:
  4202. case AFE_PORT_I2S_SD2:
  4203. case AFE_PORT_I2S_SD3:
  4204. dai_data->port_config.i2s.channel_mode =
  4205. mi2s_dai_config->pdata_mi2s_lines;
  4206. break;
  4207. case AFE_PORT_I2S_QUAD01:
  4208. case AFE_PORT_I2S_6CHS:
  4209. case AFE_PORT_I2S_8CHS:
  4210. if (dai_data->vi_feed_mono == SPKR_1)
  4211. dai_data->port_config.i2s.channel_mode =
  4212. AFE_PORT_I2S_SD0;
  4213. else
  4214. dai_data->port_config.i2s.channel_mode =
  4215. AFE_PORT_I2S_SD1;
  4216. break;
  4217. case AFE_PORT_I2S_QUAD23:
  4218. dai_data->port_config.i2s.channel_mode =
  4219. AFE_PORT_I2S_SD2;
  4220. break;
  4221. }
  4222. if (dai_data->channels == 2)
  4223. dai_data->port_config.i2s.mono_stereo =
  4224. MSM_AFE_CH_STEREO;
  4225. else
  4226. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  4227. break;
  4228. default:
  4229. pr_err("%s: default err channels %d\n",
  4230. __func__, dai_data->channels);
  4231. goto error_invalid_data;
  4232. }
  4233. dai_data->rate = params_rate(params);
  4234. switch (params_format(params)) {
  4235. case SNDRV_PCM_FORMAT_S16_LE:
  4236. case SNDRV_PCM_FORMAT_SPECIAL:
  4237. dai_data->port_config.i2s.bit_width = 16;
  4238. dai_data->bitwidth = 16;
  4239. break;
  4240. case SNDRV_PCM_FORMAT_S24_LE:
  4241. case SNDRV_PCM_FORMAT_S24_3LE:
  4242. dai_data->port_config.i2s.bit_width = 24;
  4243. dai_data->bitwidth = 24;
  4244. break;
  4245. default:
  4246. pr_err("%s: format %d\n",
  4247. __func__, params_format(params));
  4248. return -EINVAL;
  4249. }
  4250. dai_data->port_config.i2s.i2s_cfg_minor_version =
  4251. AFE_API_VERSION_I2S_CONFIG;
  4252. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  4253. if ((test_bit(STATUS_PORT_STARTED,
  4254. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  4255. test_bit(STATUS_PORT_STARTED,
  4256. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  4257. (test_bit(STATUS_PORT_STARTED,
  4258. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  4259. test_bit(STATUS_PORT_STARTED,
  4260. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  4261. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  4262. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  4263. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  4264. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  4265. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  4266. "Tx sample_rate = %u bit_width = %hu\n"
  4267. "Rx sample_rate = %u bit_width = %hu\n"
  4268. , __func__,
  4269. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  4270. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  4271. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  4272. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  4273. return -EINVAL;
  4274. }
  4275. }
  4276. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  4277. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  4278. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  4279. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  4280. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  4281. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  4282. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  4283. i2s->sample_rate, i2s->data_format, i2s->reserved);
  4284. return 0;
  4285. error_invalid_data:
  4286. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  4287. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  4288. return -EINVAL;
  4289. }
  4290. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  4291. {
  4292. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4293. dev_get_drvdata(dai->dev);
  4294. if (test_bit(STATUS_PORT_STARTED,
  4295. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  4296. test_bit(STATUS_PORT_STARTED,
  4297. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4298. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  4299. __func__);
  4300. return -EPERM;
  4301. }
  4302. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  4303. case SND_SOC_DAIFMT_CBS_CFS:
  4304. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4305. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4306. break;
  4307. case SND_SOC_DAIFMT_CBM_CFM:
  4308. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4309. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4310. break;
  4311. default:
  4312. pr_err("%s: fmt %d\n",
  4313. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  4314. return -EINVAL;
  4315. }
  4316. return 0;
  4317. }
  4318. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  4319. struct snd_soc_dai *dai)
  4320. {
  4321. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4322. dev_get_drvdata(dai->dev);
  4323. struct msm_dai_q6_dai_data *dai_data =
  4324. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4325. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4326. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4327. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4328. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4329. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  4330. }
  4331. return 0;
  4332. }
  4333. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  4334. struct snd_soc_dai *dai)
  4335. {
  4336. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4337. dev_get_drvdata(dai->dev);
  4338. struct msm_dai_q6_dai_data *dai_data =
  4339. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4340. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4341. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4342. u16 port_id = 0;
  4343. int rc = 0;
  4344. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4345. &port_id) != 0) {
  4346. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4347. __func__, port_id);
  4348. }
  4349. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  4350. __func__, port_id);
  4351. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4352. rc = afe_close(port_id);
  4353. if (rc < 0)
  4354. dev_err(dai->dev, "fail to close AFE port\n");
  4355. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  4356. }
  4357. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  4358. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4359. }
  4360. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  4361. .startup = msm_dai_q6_mi2s_startup,
  4362. .prepare = msm_dai_q6_mi2s_prepare,
  4363. .hw_params = msm_dai_q6_mi2s_hw_params,
  4364. .hw_free = msm_dai_q6_mi2s_hw_free,
  4365. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  4366. .shutdown = msm_dai_q6_mi2s_shutdown,
  4367. };
  4368. /* Channel min and max are initialized base on platform data */
  4369. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  4370. {
  4371. .playback = {
  4372. .stream_name = "Primary MI2S Playback",
  4373. .aif_name = "PRI_MI2S_RX",
  4374. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4375. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4376. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4377. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4378. SNDRV_PCM_RATE_192000,
  4379. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4380. SNDRV_PCM_FMTBIT_S24_LE |
  4381. SNDRV_PCM_FMTBIT_S24_3LE,
  4382. .rate_min = 8000,
  4383. .rate_max = 192000,
  4384. },
  4385. .capture = {
  4386. .stream_name = "Primary MI2S Capture",
  4387. .aif_name = "PRI_MI2S_TX",
  4388. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4389. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4390. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4391. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4392. SNDRV_PCM_RATE_192000,
  4393. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4394. .rate_min = 8000,
  4395. .rate_max = 192000,
  4396. },
  4397. .ops = &msm_dai_q6_mi2s_ops,
  4398. .name = "Primary MI2S",
  4399. .id = MSM_PRIM_MI2S,
  4400. .probe = msm_dai_q6_dai_mi2s_probe,
  4401. .remove = msm_dai_q6_dai_mi2s_remove,
  4402. },
  4403. {
  4404. .playback = {
  4405. .stream_name = "Secondary MI2S Playback",
  4406. .aif_name = "SEC_MI2S_RX",
  4407. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4408. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4409. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4410. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4411. SNDRV_PCM_RATE_192000,
  4412. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4413. .rate_min = 8000,
  4414. .rate_max = 192000,
  4415. },
  4416. .capture = {
  4417. .stream_name = "Secondary MI2S Capture",
  4418. .aif_name = "SEC_MI2S_TX",
  4419. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4420. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4421. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4422. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4423. SNDRV_PCM_RATE_192000,
  4424. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4425. .rate_min = 8000,
  4426. .rate_max = 192000,
  4427. },
  4428. .ops = &msm_dai_q6_mi2s_ops,
  4429. .name = "Secondary MI2S",
  4430. .id = MSM_SEC_MI2S,
  4431. .probe = msm_dai_q6_dai_mi2s_probe,
  4432. .remove = msm_dai_q6_dai_mi2s_remove,
  4433. },
  4434. {
  4435. .playback = {
  4436. .stream_name = "Tertiary MI2S Playback",
  4437. .aif_name = "TERT_MI2S_RX",
  4438. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4439. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4440. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4441. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4442. SNDRV_PCM_RATE_192000,
  4443. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4444. .rate_min = 8000,
  4445. .rate_max = 192000,
  4446. },
  4447. .capture = {
  4448. .stream_name = "Tertiary MI2S Capture",
  4449. .aif_name = "TERT_MI2S_TX",
  4450. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4451. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4452. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4453. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4454. SNDRV_PCM_RATE_192000,
  4455. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4456. .rate_min = 8000,
  4457. .rate_max = 192000,
  4458. },
  4459. .ops = &msm_dai_q6_mi2s_ops,
  4460. .name = "Tertiary MI2S",
  4461. .id = MSM_TERT_MI2S,
  4462. .probe = msm_dai_q6_dai_mi2s_probe,
  4463. .remove = msm_dai_q6_dai_mi2s_remove,
  4464. },
  4465. {
  4466. .playback = {
  4467. .stream_name = "Quaternary MI2S Playback",
  4468. .aif_name = "QUAT_MI2S_RX",
  4469. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4470. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4471. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4472. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4473. SNDRV_PCM_RATE_192000,
  4474. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4475. .rate_min = 8000,
  4476. .rate_max = 192000,
  4477. },
  4478. .capture = {
  4479. .stream_name = "Quaternary MI2S Capture",
  4480. .aif_name = "QUAT_MI2S_TX",
  4481. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4482. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4483. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4484. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4485. SNDRV_PCM_RATE_192000,
  4486. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4487. .rate_min = 8000,
  4488. .rate_max = 192000,
  4489. },
  4490. .ops = &msm_dai_q6_mi2s_ops,
  4491. .name = "Quaternary MI2S",
  4492. .id = MSM_QUAT_MI2S,
  4493. .probe = msm_dai_q6_dai_mi2s_probe,
  4494. .remove = msm_dai_q6_dai_mi2s_remove,
  4495. },
  4496. {
  4497. .playback = {
  4498. .stream_name = "Quinary MI2S Playback",
  4499. .aif_name = "QUIN_MI2S_RX",
  4500. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4501. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4502. SNDRV_PCM_RATE_192000,
  4503. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4504. .rate_min = 8000,
  4505. .rate_max = 192000,
  4506. },
  4507. .capture = {
  4508. .stream_name = "Quinary MI2S Capture",
  4509. .aif_name = "QUIN_MI2S_TX",
  4510. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4511. SNDRV_PCM_RATE_16000,
  4512. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4513. .rate_min = 8000,
  4514. .rate_max = 48000,
  4515. },
  4516. .ops = &msm_dai_q6_mi2s_ops,
  4517. .name = "Quinary MI2S",
  4518. .id = MSM_QUIN_MI2S,
  4519. .probe = msm_dai_q6_dai_mi2s_probe,
  4520. .remove = msm_dai_q6_dai_mi2s_remove,
  4521. },
  4522. {
  4523. .playback = {
  4524. .stream_name = "Secondary MI2S Playback SD1",
  4525. .aif_name = "SEC_MI2S_RX_SD1",
  4526. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4527. SNDRV_PCM_RATE_16000,
  4528. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4529. .rate_min = 8000,
  4530. .rate_max = 48000,
  4531. },
  4532. .id = MSM_SEC_MI2S_SD1,
  4533. },
  4534. {
  4535. .capture = {
  4536. .stream_name = "Senary_mi2s Capture",
  4537. .aif_name = "SENARY_TX",
  4538. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4539. SNDRV_PCM_RATE_16000,
  4540. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4541. .rate_min = 8000,
  4542. .rate_max = 48000,
  4543. },
  4544. .ops = &msm_dai_q6_mi2s_ops,
  4545. .name = "Senary MI2S",
  4546. .id = MSM_SENARY_MI2S,
  4547. .probe = msm_dai_q6_dai_mi2s_probe,
  4548. .remove = msm_dai_q6_dai_mi2s_remove,
  4549. },
  4550. {
  4551. .playback = {
  4552. .stream_name = "INT0 MI2S Playback",
  4553. .aif_name = "INT0_MI2S_RX",
  4554. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4555. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  4556. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  4557. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4558. SNDRV_PCM_FMTBIT_S24_LE |
  4559. SNDRV_PCM_FMTBIT_S24_3LE,
  4560. .rate_min = 8000,
  4561. .rate_max = 192000,
  4562. },
  4563. .capture = {
  4564. .stream_name = "INT0 MI2S Capture",
  4565. .aif_name = "INT0_MI2S_TX",
  4566. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4567. SNDRV_PCM_RATE_16000,
  4568. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4569. .rate_min = 8000,
  4570. .rate_max = 48000,
  4571. },
  4572. .ops = &msm_dai_q6_mi2s_ops,
  4573. .name = "INT0 MI2S",
  4574. .id = MSM_INT0_MI2S,
  4575. .probe = msm_dai_q6_dai_mi2s_probe,
  4576. .remove = msm_dai_q6_dai_mi2s_remove,
  4577. },
  4578. {
  4579. .playback = {
  4580. .stream_name = "INT1 MI2S Playback",
  4581. .aif_name = "INT1_MI2S_RX",
  4582. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4583. SNDRV_PCM_RATE_16000,
  4584. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4585. SNDRV_PCM_FMTBIT_S24_LE |
  4586. SNDRV_PCM_FMTBIT_S24_3LE,
  4587. .rate_min = 8000,
  4588. .rate_max = 48000,
  4589. },
  4590. .capture = {
  4591. .stream_name = "INT1 MI2S Capture",
  4592. .aif_name = "INT1_MI2S_TX",
  4593. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4594. SNDRV_PCM_RATE_16000,
  4595. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4596. .rate_min = 8000,
  4597. .rate_max = 48000,
  4598. },
  4599. .ops = &msm_dai_q6_mi2s_ops,
  4600. .name = "INT1 MI2S",
  4601. .id = MSM_INT1_MI2S,
  4602. .probe = msm_dai_q6_dai_mi2s_probe,
  4603. .remove = msm_dai_q6_dai_mi2s_remove,
  4604. },
  4605. {
  4606. .playback = {
  4607. .stream_name = "INT2 MI2S Playback",
  4608. .aif_name = "INT2_MI2S_RX",
  4609. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4610. SNDRV_PCM_RATE_16000,
  4611. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4612. SNDRV_PCM_FMTBIT_S24_LE |
  4613. SNDRV_PCM_FMTBIT_S24_3LE,
  4614. .rate_min = 8000,
  4615. .rate_max = 48000,
  4616. },
  4617. .capture = {
  4618. .stream_name = "INT2 MI2S Capture",
  4619. .aif_name = "INT2_MI2S_TX",
  4620. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4621. SNDRV_PCM_RATE_16000,
  4622. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4623. .rate_min = 8000,
  4624. .rate_max = 48000,
  4625. },
  4626. .ops = &msm_dai_q6_mi2s_ops,
  4627. .name = "INT2 MI2S",
  4628. .id = MSM_INT2_MI2S,
  4629. .probe = msm_dai_q6_dai_mi2s_probe,
  4630. .remove = msm_dai_q6_dai_mi2s_remove,
  4631. },
  4632. {
  4633. .playback = {
  4634. .stream_name = "INT3 MI2S Playback",
  4635. .aif_name = "INT3_MI2S_RX",
  4636. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4637. SNDRV_PCM_RATE_16000,
  4638. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4639. SNDRV_PCM_FMTBIT_S24_LE |
  4640. SNDRV_PCM_FMTBIT_S24_3LE,
  4641. .rate_min = 8000,
  4642. .rate_max = 48000,
  4643. },
  4644. .capture = {
  4645. .stream_name = "INT3 MI2S Capture",
  4646. .aif_name = "INT3_MI2S_TX",
  4647. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4648. SNDRV_PCM_RATE_16000,
  4649. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4650. .rate_min = 8000,
  4651. .rate_max = 48000,
  4652. },
  4653. .ops = &msm_dai_q6_mi2s_ops,
  4654. .name = "INT3 MI2S",
  4655. .id = MSM_INT3_MI2S,
  4656. .probe = msm_dai_q6_dai_mi2s_probe,
  4657. .remove = msm_dai_q6_dai_mi2s_remove,
  4658. },
  4659. {
  4660. .playback = {
  4661. .stream_name = "INT4 MI2S Playback",
  4662. .aif_name = "INT4_MI2S_RX",
  4663. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4664. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4665. SNDRV_PCM_RATE_192000,
  4666. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4667. SNDRV_PCM_FMTBIT_S24_LE |
  4668. SNDRV_PCM_FMTBIT_S24_3LE,
  4669. .rate_min = 8000,
  4670. .rate_max = 192000,
  4671. },
  4672. .capture = {
  4673. .stream_name = "INT4 MI2S Capture",
  4674. .aif_name = "INT4_MI2S_TX",
  4675. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4676. SNDRV_PCM_RATE_16000,
  4677. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4678. .rate_min = 8000,
  4679. .rate_max = 48000,
  4680. },
  4681. .ops = &msm_dai_q6_mi2s_ops,
  4682. .name = "INT4 MI2S",
  4683. .id = MSM_INT4_MI2S,
  4684. .probe = msm_dai_q6_dai_mi2s_probe,
  4685. .remove = msm_dai_q6_dai_mi2s_remove,
  4686. },
  4687. {
  4688. .playback = {
  4689. .stream_name = "INT5 MI2S Playback",
  4690. .aif_name = "INT5_MI2S_RX",
  4691. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4692. SNDRV_PCM_RATE_16000,
  4693. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4694. SNDRV_PCM_FMTBIT_S24_LE |
  4695. SNDRV_PCM_FMTBIT_S24_3LE,
  4696. .rate_min = 8000,
  4697. .rate_max = 48000,
  4698. },
  4699. .capture = {
  4700. .stream_name = "INT5 MI2S Capture",
  4701. .aif_name = "INT5_MI2S_TX",
  4702. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4703. SNDRV_PCM_RATE_16000,
  4704. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4705. .rate_min = 8000,
  4706. .rate_max = 48000,
  4707. },
  4708. .ops = &msm_dai_q6_mi2s_ops,
  4709. .name = "INT5 MI2S",
  4710. .id = MSM_INT5_MI2S,
  4711. .probe = msm_dai_q6_dai_mi2s_probe,
  4712. .remove = msm_dai_q6_dai_mi2s_remove,
  4713. },
  4714. {
  4715. .playback = {
  4716. .stream_name = "INT6 MI2S Playback",
  4717. .aif_name = "INT6_MI2S_RX",
  4718. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4719. SNDRV_PCM_RATE_16000,
  4720. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4721. SNDRV_PCM_FMTBIT_S24_LE |
  4722. SNDRV_PCM_FMTBIT_S24_3LE,
  4723. .rate_min = 8000,
  4724. .rate_max = 48000,
  4725. },
  4726. .capture = {
  4727. .stream_name = "INT6 MI2S Capture",
  4728. .aif_name = "INT6_MI2S_TX",
  4729. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4730. SNDRV_PCM_RATE_16000,
  4731. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4732. .rate_min = 8000,
  4733. .rate_max = 48000,
  4734. },
  4735. .ops = &msm_dai_q6_mi2s_ops,
  4736. .name = "INT6 MI2S",
  4737. .id = MSM_INT6_MI2S,
  4738. .probe = msm_dai_q6_dai_mi2s_probe,
  4739. .remove = msm_dai_q6_dai_mi2s_remove,
  4740. },
  4741. };
  4742. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  4743. unsigned int *ch_cnt)
  4744. {
  4745. u8 num_of_sd_lines;
  4746. num_of_sd_lines = num_of_bits_set(sd_lines);
  4747. switch (num_of_sd_lines) {
  4748. case 0:
  4749. pr_debug("%s: no line is assigned\n", __func__);
  4750. break;
  4751. case 1:
  4752. switch (sd_lines) {
  4753. case MSM_MI2S_SD0:
  4754. *config_ptr = AFE_PORT_I2S_SD0;
  4755. break;
  4756. case MSM_MI2S_SD1:
  4757. *config_ptr = AFE_PORT_I2S_SD1;
  4758. break;
  4759. case MSM_MI2S_SD2:
  4760. *config_ptr = AFE_PORT_I2S_SD2;
  4761. break;
  4762. case MSM_MI2S_SD3:
  4763. *config_ptr = AFE_PORT_I2S_SD3;
  4764. break;
  4765. default:
  4766. pr_err("%s: invalid SD lines %d\n",
  4767. __func__, sd_lines);
  4768. goto error_invalid_data;
  4769. }
  4770. break;
  4771. case 2:
  4772. switch (sd_lines) {
  4773. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  4774. *config_ptr = AFE_PORT_I2S_QUAD01;
  4775. break;
  4776. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4777. *config_ptr = AFE_PORT_I2S_QUAD23;
  4778. break;
  4779. default:
  4780. pr_err("%s: invalid SD lines %d\n",
  4781. __func__, sd_lines);
  4782. goto error_invalid_data;
  4783. }
  4784. break;
  4785. case 3:
  4786. switch (sd_lines) {
  4787. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  4788. *config_ptr = AFE_PORT_I2S_6CHS;
  4789. break;
  4790. default:
  4791. pr_err("%s: invalid SD lines %d\n",
  4792. __func__, sd_lines);
  4793. goto error_invalid_data;
  4794. }
  4795. break;
  4796. case 4:
  4797. switch (sd_lines) {
  4798. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4799. *config_ptr = AFE_PORT_I2S_8CHS;
  4800. break;
  4801. default:
  4802. pr_err("%s: invalid SD lines %d\n",
  4803. __func__, sd_lines);
  4804. goto error_invalid_data;
  4805. }
  4806. break;
  4807. default:
  4808. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  4809. goto error_invalid_data;
  4810. }
  4811. *ch_cnt = num_of_sd_lines;
  4812. return 0;
  4813. error_invalid_data:
  4814. pr_err("%s: invalid data\n", __func__);
  4815. return -EINVAL;
  4816. }
  4817. static int msm_dai_q6_mi2s_platform_data_validation(
  4818. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  4819. {
  4820. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  4821. struct msm_mi2s_pdata *mi2s_pdata =
  4822. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  4823. unsigned int ch_cnt;
  4824. int rc = 0;
  4825. u16 sd_line;
  4826. if (mi2s_pdata == NULL) {
  4827. pr_err("%s: mi2s_pdata NULL", __func__);
  4828. return -EINVAL;
  4829. }
  4830. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  4831. &sd_line, &ch_cnt);
  4832. if (rc < 0) {
  4833. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  4834. goto rtn;
  4835. }
  4836. if (ch_cnt) {
  4837. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4838. sd_line;
  4839. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  4840. dai_driver->playback.channels_min = 1;
  4841. dai_driver->playback.channels_max = ch_cnt << 1;
  4842. } else {
  4843. dai_driver->playback.channels_min = 0;
  4844. dai_driver->playback.channels_max = 0;
  4845. }
  4846. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  4847. &sd_line, &ch_cnt);
  4848. if (rc < 0) {
  4849. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  4850. goto rtn;
  4851. }
  4852. if (ch_cnt) {
  4853. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4854. sd_line;
  4855. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  4856. dai_driver->capture.channels_min = 1;
  4857. dai_driver->capture.channels_max = ch_cnt << 1;
  4858. } else {
  4859. dai_driver->capture.channels_min = 0;
  4860. dai_driver->capture.channels_max = 0;
  4861. }
  4862. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  4863. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  4864. dai_data->tx_dai.pdata_mi2s_lines);
  4865. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  4866. __func__, dai_driver->playback.channels_max,
  4867. dai_driver->capture.channels_max);
  4868. rtn:
  4869. return rc;
  4870. }
  4871. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  4872. .name = "msm-dai-q6-mi2s",
  4873. };
  4874. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  4875. {
  4876. struct msm_dai_q6_mi2s_dai_data *dai_data;
  4877. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  4878. u32 tx_line = 0;
  4879. u32 rx_line = 0;
  4880. u32 mi2s_intf = 0;
  4881. struct msm_mi2s_pdata *mi2s_pdata;
  4882. int rc;
  4883. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  4884. &mi2s_intf);
  4885. if (rc) {
  4886. dev_err(&pdev->dev,
  4887. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  4888. goto rtn;
  4889. }
  4890. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  4891. mi2s_intf);
  4892. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  4893. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  4894. dev_err(&pdev->dev,
  4895. "%s: Invalid MI2S ID %u from Device Tree\n",
  4896. __func__, mi2s_intf);
  4897. rc = -ENXIO;
  4898. goto rtn;
  4899. }
  4900. pdev->id = mi2s_intf;
  4901. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  4902. if (!mi2s_pdata) {
  4903. rc = -ENOMEM;
  4904. goto rtn;
  4905. }
  4906. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  4907. &rx_line);
  4908. if (rc) {
  4909. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  4910. "qcom,msm-mi2s-rx-lines");
  4911. goto free_pdata;
  4912. }
  4913. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  4914. &tx_line);
  4915. if (rc) {
  4916. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  4917. "qcom,msm-mi2s-tx-lines");
  4918. goto free_pdata;
  4919. }
  4920. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  4921. dev_name(&pdev->dev), rx_line, tx_line);
  4922. mi2s_pdata->rx_sd_lines = rx_line;
  4923. mi2s_pdata->tx_sd_lines = tx_line;
  4924. mi2s_pdata->intf_id = mi2s_intf;
  4925. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  4926. GFP_KERNEL);
  4927. if (!dai_data) {
  4928. rc = -ENOMEM;
  4929. goto free_pdata;
  4930. } else
  4931. dev_set_drvdata(&pdev->dev, dai_data);
  4932. rc = of_property_read_u32(pdev->dev.of_node,
  4933. "qcom,msm-dai-is-island-supported",
  4934. &dai_data->is_island_dai);
  4935. if (rc)
  4936. dev_dbg(&pdev->dev, "island supported entry not found\n");
  4937. pdev->dev.platform_data = mi2s_pdata;
  4938. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  4939. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  4940. if (rc < 0)
  4941. goto free_dai_data;
  4942. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  4943. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  4944. if (rc < 0)
  4945. goto err_register;
  4946. return 0;
  4947. err_register:
  4948. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  4949. free_dai_data:
  4950. kfree(dai_data);
  4951. free_pdata:
  4952. kfree(mi2s_pdata);
  4953. rtn:
  4954. return rc;
  4955. }
  4956. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  4957. {
  4958. snd_soc_unregister_component(&pdev->dev);
  4959. return 0;
  4960. }
  4961. static const struct snd_soc_component_driver msm_dai_q6_component = {
  4962. .name = "msm-dai-q6-dev",
  4963. };
  4964. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  4965. {
  4966. int rc, id, i, len;
  4967. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  4968. char stream_name[80];
  4969. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  4970. if (rc) {
  4971. dev_err(&pdev->dev,
  4972. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  4973. return rc;
  4974. }
  4975. pdev->id = id;
  4976. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4977. dev_name(&pdev->dev), pdev->id);
  4978. switch (id) {
  4979. case SLIMBUS_0_RX:
  4980. strlcpy(stream_name, "Slimbus Playback", 80);
  4981. goto register_slim_playback;
  4982. case SLIMBUS_2_RX:
  4983. strlcpy(stream_name, "Slimbus2 Playback", 80);
  4984. goto register_slim_playback;
  4985. case SLIMBUS_1_RX:
  4986. strlcpy(stream_name, "Slimbus1 Playback", 80);
  4987. goto register_slim_playback;
  4988. case SLIMBUS_3_RX:
  4989. strlcpy(stream_name, "Slimbus3 Playback", 80);
  4990. goto register_slim_playback;
  4991. case SLIMBUS_4_RX:
  4992. strlcpy(stream_name, "Slimbus4 Playback", 80);
  4993. goto register_slim_playback;
  4994. case SLIMBUS_5_RX:
  4995. strlcpy(stream_name, "Slimbus5 Playback", 80);
  4996. goto register_slim_playback;
  4997. case SLIMBUS_6_RX:
  4998. strlcpy(stream_name, "Slimbus6 Playback", 80);
  4999. goto register_slim_playback;
  5000. case SLIMBUS_7_RX:
  5001. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  5002. goto register_slim_playback;
  5003. case SLIMBUS_8_RX:
  5004. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  5005. goto register_slim_playback;
  5006. register_slim_playback:
  5007. rc = -ENODEV;
  5008. len = strnlen(stream_name, 80);
  5009. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  5010. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  5011. !strcmp(stream_name,
  5012. msm_dai_q6_slimbus_rx_dai[i]
  5013. .playback.stream_name)) {
  5014. rc = snd_soc_register_component(&pdev->dev,
  5015. &msm_dai_q6_component,
  5016. &msm_dai_q6_slimbus_rx_dai[i], 1);
  5017. break;
  5018. }
  5019. }
  5020. if (rc)
  5021. pr_err("%s: Device not found stream name %s\n",
  5022. __func__, stream_name);
  5023. break;
  5024. case SLIMBUS_0_TX:
  5025. strlcpy(stream_name, "Slimbus Capture", 80);
  5026. goto register_slim_capture;
  5027. case SLIMBUS_1_TX:
  5028. strlcpy(stream_name, "Slimbus1 Capture", 80);
  5029. goto register_slim_capture;
  5030. case SLIMBUS_2_TX:
  5031. strlcpy(stream_name, "Slimbus2 Capture", 80);
  5032. goto register_slim_capture;
  5033. case SLIMBUS_3_TX:
  5034. strlcpy(stream_name, "Slimbus3 Capture", 80);
  5035. goto register_slim_capture;
  5036. case SLIMBUS_4_TX:
  5037. strlcpy(stream_name, "Slimbus4 Capture", 80);
  5038. goto register_slim_capture;
  5039. case SLIMBUS_5_TX:
  5040. strlcpy(stream_name, "Slimbus5 Capture", 80);
  5041. goto register_slim_capture;
  5042. case SLIMBUS_6_TX:
  5043. strlcpy(stream_name, "Slimbus6 Capture", 80);
  5044. goto register_slim_capture;
  5045. case SLIMBUS_7_TX:
  5046. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  5047. goto register_slim_capture;
  5048. case SLIMBUS_8_TX:
  5049. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  5050. goto register_slim_capture;
  5051. register_slim_capture:
  5052. rc = -ENODEV;
  5053. len = strnlen(stream_name, 80);
  5054. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  5055. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  5056. !strcmp(stream_name,
  5057. msm_dai_q6_slimbus_tx_dai[i]
  5058. .capture.stream_name)) {
  5059. rc = snd_soc_register_component(&pdev->dev,
  5060. &msm_dai_q6_component,
  5061. &msm_dai_q6_slimbus_tx_dai[i], 1);
  5062. break;
  5063. }
  5064. }
  5065. if (rc)
  5066. pr_err("%s: Device not found stream name %s\n",
  5067. __func__, stream_name);
  5068. break;
  5069. case INT_BT_SCO_RX:
  5070. rc = snd_soc_register_component(&pdev->dev,
  5071. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  5072. break;
  5073. case INT_BT_SCO_TX:
  5074. rc = snd_soc_register_component(&pdev->dev,
  5075. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  5076. break;
  5077. case INT_BT_A2DP_RX:
  5078. rc = snd_soc_register_component(&pdev->dev,
  5079. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  5080. break;
  5081. case INT_FM_RX:
  5082. rc = snd_soc_register_component(&pdev->dev,
  5083. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  5084. break;
  5085. case INT_FM_TX:
  5086. rc = snd_soc_register_component(&pdev->dev,
  5087. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  5088. break;
  5089. case AFE_PORT_ID_USB_RX:
  5090. rc = snd_soc_register_component(&pdev->dev,
  5091. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  5092. break;
  5093. case AFE_PORT_ID_USB_TX:
  5094. rc = snd_soc_register_component(&pdev->dev,
  5095. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  5096. break;
  5097. case RT_PROXY_DAI_001_RX:
  5098. strlcpy(stream_name, "AFE Playback", 80);
  5099. goto register_afe_playback;
  5100. case RT_PROXY_DAI_002_RX:
  5101. strlcpy(stream_name, "AFE-PROXY RX", 80);
  5102. register_afe_playback:
  5103. rc = -ENODEV;
  5104. len = strnlen(stream_name, 80);
  5105. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  5106. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  5107. !strcmp(stream_name,
  5108. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  5109. rc = snd_soc_register_component(&pdev->dev,
  5110. &msm_dai_q6_component,
  5111. &msm_dai_q6_afe_rx_dai[i], 1);
  5112. break;
  5113. }
  5114. }
  5115. if (rc)
  5116. pr_err("%s: Device not found stream name %s\n",
  5117. __func__, stream_name);
  5118. break;
  5119. case RT_PROXY_DAI_001_TX:
  5120. strlcpy(stream_name, "AFE-PROXY TX", 80);
  5121. goto register_afe_capture;
  5122. case RT_PROXY_DAI_002_TX:
  5123. strlcpy(stream_name, "AFE Capture", 80);
  5124. register_afe_capture:
  5125. rc = -ENODEV;
  5126. len = strnlen(stream_name, 80);
  5127. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  5128. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  5129. !strcmp(stream_name,
  5130. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  5131. rc = snd_soc_register_component(&pdev->dev,
  5132. &msm_dai_q6_component,
  5133. &msm_dai_q6_afe_tx_dai[i], 1);
  5134. break;
  5135. }
  5136. }
  5137. if (rc)
  5138. pr_err("%s: Device not found stream name %s\n",
  5139. __func__, stream_name);
  5140. break;
  5141. case VOICE_PLAYBACK_TX:
  5142. strlcpy(stream_name, "Voice Farend Playback", 80);
  5143. goto register_voice_playback;
  5144. case VOICE2_PLAYBACK_TX:
  5145. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  5146. register_voice_playback:
  5147. rc = -ENODEV;
  5148. len = strnlen(stream_name, 80);
  5149. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  5150. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  5151. && !strcmp(stream_name,
  5152. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  5153. rc = snd_soc_register_component(&pdev->dev,
  5154. &msm_dai_q6_component,
  5155. &msm_dai_q6_voc_playback_dai[i], 1);
  5156. break;
  5157. }
  5158. }
  5159. if (rc)
  5160. pr_err("%s Device not found stream name %s\n",
  5161. __func__, stream_name);
  5162. break;
  5163. case VOICE_RECORD_RX:
  5164. strlcpy(stream_name, "Voice Downlink Capture", 80);
  5165. goto register_uplink_capture;
  5166. case VOICE_RECORD_TX:
  5167. strlcpy(stream_name, "Voice Uplink Capture", 80);
  5168. register_uplink_capture:
  5169. rc = -ENODEV;
  5170. len = strnlen(stream_name, 80);
  5171. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  5172. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  5173. && !strcmp(stream_name,
  5174. msm_dai_q6_incall_record_dai[i].
  5175. capture.stream_name)) {
  5176. rc = snd_soc_register_component(&pdev->dev,
  5177. &msm_dai_q6_component,
  5178. &msm_dai_q6_incall_record_dai[i], 1);
  5179. break;
  5180. }
  5181. }
  5182. if (rc)
  5183. pr_err("%s: Device not found stream name %s\n",
  5184. __func__, stream_name);
  5185. break;
  5186. default:
  5187. rc = -ENODEV;
  5188. break;
  5189. }
  5190. return rc;
  5191. }
  5192. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  5193. {
  5194. snd_soc_unregister_component(&pdev->dev);
  5195. return 0;
  5196. }
  5197. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  5198. { .compatible = "qcom,msm-dai-q6-dev", },
  5199. { }
  5200. };
  5201. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  5202. static struct platform_driver msm_dai_q6_dev = {
  5203. .probe = msm_dai_q6_dev_probe,
  5204. .remove = msm_dai_q6_dev_remove,
  5205. .driver = {
  5206. .name = "msm-dai-q6-dev",
  5207. .owner = THIS_MODULE,
  5208. .of_match_table = msm_dai_q6_dev_dt_match,
  5209. },
  5210. };
  5211. static int msm_dai_q6_probe(struct platform_device *pdev)
  5212. {
  5213. int rc;
  5214. pr_debug("%s: dev name %s, id:%d\n", __func__,
  5215. dev_name(&pdev->dev), pdev->id);
  5216. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5217. if (rc) {
  5218. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5219. __func__, rc);
  5220. } else
  5221. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5222. return rc;
  5223. }
  5224. static int msm_dai_q6_remove(struct platform_device *pdev)
  5225. {
  5226. of_platform_depopulate(&pdev->dev);
  5227. return 0;
  5228. }
  5229. static const struct of_device_id msm_dai_q6_dt_match[] = {
  5230. { .compatible = "qcom,msm-dai-q6", },
  5231. { }
  5232. };
  5233. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  5234. static struct platform_driver msm_dai_q6 = {
  5235. .probe = msm_dai_q6_probe,
  5236. .remove = msm_dai_q6_remove,
  5237. .driver = {
  5238. .name = "msm-dai-q6",
  5239. .owner = THIS_MODULE,
  5240. .of_match_table = msm_dai_q6_dt_match,
  5241. },
  5242. };
  5243. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  5244. {
  5245. int rc;
  5246. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5247. if (rc) {
  5248. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5249. __func__, rc);
  5250. } else
  5251. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5252. return rc;
  5253. }
  5254. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  5255. {
  5256. return 0;
  5257. }
  5258. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  5259. { .compatible = "qcom,msm-dai-mi2s", },
  5260. { }
  5261. };
  5262. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  5263. static struct platform_driver msm_dai_mi2s_q6 = {
  5264. .probe = msm_dai_mi2s_q6_probe,
  5265. .remove = msm_dai_mi2s_q6_remove,
  5266. .driver = {
  5267. .name = "msm-dai-mi2s",
  5268. .owner = THIS_MODULE,
  5269. .of_match_table = msm_dai_mi2s_dt_match,
  5270. },
  5271. };
  5272. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  5273. { .compatible = "qcom,msm-dai-q6-mi2s", },
  5274. { }
  5275. };
  5276. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  5277. static struct platform_driver msm_dai_q6_mi2s_driver = {
  5278. .probe = msm_dai_q6_mi2s_dev_probe,
  5279. .remove = msm_dai_q6_mi2s_dev_remove,
  5280. .driver = {
  5281. .name = "msm-dai-q6-mi2s",
  5282. .owner = THIS_MODULE,
  5283. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  5284. },
  5285. };
  5286. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  5287. {
  5288. int rc, id;
  5289. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  5290. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  5291. if (rc) {
  5292. dev_err(&pdev->dev,
  5293. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  5294. return rc;
  5295. }
  5296. pdev->id = id;
  5297. pr_debug("%s: dev name %s, id:%d\n", __func__,
  5298. dev_name(&pdev->dev), pdev->id);
  5299. switch (pdev->id) {
  5300. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  5301. rc = snd_soc_register_component(&pdev->dev,
  5302. &msm_dai_spdif_q6_component,
  5303. &msm_dai_q6_spdif_spdif_rx_dai[0], 1);
  5304. break;
  5305. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  5306. rc = snd_soc_register_component(&pdev->dev,
  5307. &msm_dai_spdif_q6_component,
  5308. &msm_dai_q6_spdif_spdif_rx_dai[1], 1);
  5309. break;
  5310. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  5311. rc = snd_soc_register_component(&pdev->dev,
  5312. &msm_dai_spdif_q6_component,
  5313. &msm_dai_q6_spdif_spdif_tx_dai[0], 1);
  5314. break;
  5315. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  5316. rc = snd_soc_register_component(&pdev->dev,
  5317. &msm_dai_spdif_q6_component,
  5318. &msm_dai_q6_spdif_spdif_tx_dai[1], 1);
  5319. break;
  5320. default:
  5321. dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
  5322. rc = -ENODEV;
  5323. break;
  5324. }
  5325. return rc;
  5326. }
  5327. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  5328. {
  5329. snd_soc_unregister_component(&pdev->dev);
  5330. return 0;
  5331. }
  5332. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  5333. {.compatible = "qcom,msm-dai-q6-spdif"},
  5334. {}
  5335. };
  5336. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  5337. static struct platform_driver msm_dai_q6_spdif_driver = {
  5338. .probe = msm_dai_q6_spdif_dev_probe,
  5339. .remove = msm_dai_q6_spdif_dev_remove,
  5340. .driver = {
  5341. .name = "msm-dai-q6-spdif",
  5342. .owner = THIS_MODULE,
  5343. .of_match_table = msm_dai_q6_spdif_dt_match,
  5344. },
  5345. };
  5346. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  5347. struct afe_clk_set *clk_set, u32 mode)
  5348. {
  5349. switch (group_id) {
  5350. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  5351. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  5352. if (mode)
  5353. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  5354. else
  5355. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  5356. break;
  5357. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  5358. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  5359. if (mode)
  5360. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  5361. else
  5362. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  5363. break;
  5364. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  5365. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  5366. if (mode)
  5367. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  5368. else
  5369. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  5370. break;
  5371. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  5372. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  5373. if (mode)
  5374. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  5375. else
  5376. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  5377. break;
  5378. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  5379. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  5380. if (mode)
  5381. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  5382. else
  5383. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  5384. break;
  5385. default:
  5386. return -EINVAL;
  5387. }
  5388. return 0;
  5389. }
  5390. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  5391. {
  5392. int rc = 0;
  5393. const uint32_t *port_id_array = NULL;
  5394. uint32_t array_length = 0;
  5395. int i = 0;
  5396. int group_idx = 0;
  5397. u32 clk_mode = 0;
  5398. /* extract tdm group info into static */
  5399. rc = of_property_read_u32(pdev->dev.of_node,
  5400. "qcom,msm-cpudai-tdm-group-id",
  5401. (u32 *)&tdm_group_cfg.group_id);
  5402. if (rc) {
  5403. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  5404. __func__, "qcom,msm-cpudai-tdm-group-id");
  5405. goto rtn;
  5406. }
  5407. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  5408. __func__, tdm_group_cfg.group_id);
  5409. rc = of_property_read_u32(pdev->dev.of_node,
  5410. "qcom,msm-cpudai-tdm-group-num-ports",
  5411. &num_tdm_group_ports);
  5412. if (rc) {
  5413. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  5414. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  5415. goto rtn;
  5416. }
  5417. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  5418. __func__, num_tdm_group_ports);
  5419. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  5420. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  5421. __func__, num_tdm_group_ports,
  5422. AFE_GROUP_DEVICE_NUM_PORTS);
  5423. rc = -EINVAL;
  5424. goto rtn;
  5425. }
  5426. port_id_array = of_get_property(pdev->dev.of_node,
  5427. "qcom,msm-cpudai-tdm-group-port-id",
  5428. &array_length);
  5429. if (port_id_array == NULL) {
  5430. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  5431. __func__);
  5432. rc = -EINVAL;
  5433. goto rtn;
  5434. }
  5435. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  5436. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  5437. __func__, array_length,
  5438. sizeof(uint32_t) * num_tdm_group_ports);
  5439. rc = -EINVAL;
  5440. goto rtn;
  5441. }
  5442. for (i = 0; i < num_tdm_group_ports; i++)
  5443. tdm_group_cfg.port_id[i] =
  5444. (u16)be32_to_cpu(port_id_array[i]);
  5445. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  5446. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  5447. tdm_group_cfg.port_id[i] =
  5448. AFE_PORT_INVALID;
  5449. /* extract tdm clk info into static */
  5450. rc = of_property_read_u32(pdev->dev.of_node,
  5451. "qcom,msm-cpudai-tdm-clk-rate",
  5452. &tdm_clk_set.clk_freq_in_hz);
  5453. if (rc) {
  5454. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  5455. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  5456. goto rtn;
  5457. }
  5458. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  5459. __func__, tdm_clk_set.clk_freq_in_hz);
  5460. /* initialize static tdm clk attribute to default value */
  5461. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  5462. /* extract tdm clk attribute into static */
  5463. if (of_find_property(pdev->dev.of_node,
  5464. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  5465. rc = of_property_read_u16(pdev->dev.of_node,
  5466. "qcom,msm-cpudai-tdm-clk-attribute",
  5467. &tdm_clk_set.clk_attri);
  5468. if (rc) {
  5469. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  5470. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  5471. goto rtn;
  5472. }
  5473. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  5474. __func__, tdm_clk_set.clk_attri);
  5475. } else
  5476. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  5477. /* extract tdm clk src master/slave info into static */
  5478. rc = of_property_read_u32(pdev->dev.of_node,
  5479. "qcom,msm-cpudai-tdm-clk-internal",
  5480. &clk_mode);
  5481. if (rc) {
  5482. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  5483. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  5484. goto rtn;
  5485. }
  5486. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  5487. __func__, clk_mode);
  5488. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  5489. &tdm_clk_set, clk_mode);
  5490. if (rc) {
  5491. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  5492. __func__, tdm_group_cfg.group_id);
  5493. goto rtn;
  5494. }
  5495. /* other initializations within device group */
  5496. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  5497. if (group_idx < 0) {
  5498. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  5499. __func__, tdm_group_cfg.group_id);
  5500. rc = -EINVAL;
  5501. goto rtn;
  5502. }
  5503. atomic_set(&tdm_group_ref[group_idx], 0);
  5504. /* probe child node info */
  5505. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5506. if (rc) {
  5507. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5508. __func__, rc);
  5509. goto rtn;
  5510. } else
  5511. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5512. rtn:
  5513. return rc;
  5514. }
  5515. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  5516. {
  5517. return 0;
  5518. }
  5519. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  5520. { .compatible = "qcom,msm-dai-tdm", },
  5521. {}
  5522. };
  5523. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  5524. static struct platform_driver msm_dai_tdm_q6 = {
  5525. .probe = msm_dai_tdm_q6_probe,
  5526. .remove = msm_dai_tdm_q6_remove,
  5527. .driver = {
  5528. .name = "msm-dai-tdm",
  5529. .owner = THIS_MODULE,
  5530. .of_match_table = msm_dai_tdm_dt_match,
  5531. },
  5532. };
  5533. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  5534. struct snd_ctl_elem_value *ucontrol)
  5535. {
  5536. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5537. int value = ucontrol->value.integer.value[0];
  5538. switch (value) {
  5539. case 0:
  5540. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  5541. break;
  5542. case 1:
  5543. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  5544. break;
  5545. case 2:
  5546. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  5547. break;
  5548. default:
  5549. pr_err("%s: data_format invalid\n", __func__);
  5550. break;
  5551. }
  5552. pr_debug("%s: data_format = %d\n",
  5553. __func__, dai_data->port_cfg.tdm.data_format);
  5554. return 0;
  5555. }
  5556. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  5557. struct snd_ctl_elem_value *ucontrol)
  5558. {
  5559. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5560. ucontrol->value.integer.value[0] =
  5561. dai_data->port_cfg.tdm.data_format;
  5562. pr_debug("%s: data_format = %d\n",
  5563. __func__, dai_data->port_cfg.tdm.data_format);
  5564. return 0;
  5565. }
  5566. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  5567. struct snd_ctl_elem_value *ucontrol)
  5568. {
  5569. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5570. int value = ucontrol->value.integer.value[0];
  5571. dai_data->port_cfg.custom_tdm_header.header_type = value;
  5572. pr_debug("%s: header_type = %d\n",
  5573. __func__,
  5574. dai_data->port_cfg.custom_tdm_header.header_type);
  5575. return 0;
  5576. }
  5577. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  5578. struct snd_ctl_elem_value *ucontrol)
  5579. {
  5580. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5581. ucontrol->value.integer.value[0] =
  5582. dai_data->port_cfg.custom_tdm_header.header_type;
  5583. pr_debug("%s: header_type = %d\n",
  5584. __func__,
  5585. dai_data->port_cfg.custom_tdm_header.header_type);
  5586. return 0;
  5587. }
  5588. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  5589. struct snd_ctl_elem_value *ucontrol)
  5590. {
  5591. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5592. int i = 0;
  5593. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  5594. dai_data->port_cfg.custom_tdm_header.header[i] =
  5595. (u16)ucontrol->value.integer.value[i];
  5596. pr_debug("%s: header #%d = 0x%x\n",
  5597. __func__, i,
  5598. dai_data->port_cfg.custom_tdm_header.header[i]);
  5599. }
  5600. return 0;
  5601. }
  5602. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  5603. struct snd_ctl_elem_value *ucontrol)
  5604. {
  5605. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5606. int i = 0;
  5607. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  5608. ucontrol->value.integer.value[i] =
  5609. dai_data->port_cfg.custom_tdm_header.header[i];
  5610. pr_debug("%s: header #%d = 0x%x\n",
  5611. __func__, i,
  5612. dai_data->port_cfg.custom_tdm_header.header[i]);
  5613. }
  5614. return 0;
  5615. }
  5616. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  5617. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  5618. msm_dai_q6_tdm_data_format_get,
  5619. msm_dai_q6_tdm_data_format_put),
  5620. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  5621. msm_dai_q6_tdm_data_format_get,
  5622. msm_dai_q6_tdm_data_format_put),
  5623. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  5624. msm_dai_q6_tdm_data_format_get,
  5625. msm_dai_q6_tdm_data_format_put),
  5626. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  5627. msm_dai_q6_tdm_data_format_get,
  5628. msm_dai_q6_tdm_data_format_put),
  5629. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  5630. msm_dai_q6_tdm_data_format_get,
  5631. msm_dai_q6_tdm_data_format_put),
  5632. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  5633. msm_dai_q6_tdm_data_format_get,
  5634. msm_dai_q6_tdm_data_format_put),
  5635. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  5636. msm_dai_q6_tdm_data_format_get,
  5637. msm_dai_q6_tdm_data_format_put),
  5638. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  5639. msm_dai_q6_tdm_data_format_get,
  5640. msm_dai_q6_tdm_data_format_put),
  5641. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  5642. msm_dai_q6_tdm_data_format_get,
  5643. msm_dai_q6_tdm_data_format_put),
  5644. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  5645. msm_dai_q6_tdm_data_format_get,
  5646. msm_dai_q6_tdm_data_format_put),
  5647. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  5648. msm_dai_q6_tdm_data_format_get,
  5649. msm_dai_q6_tdm_data_format_put),
  5650. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  5651. msm_dai_q6_tdm_data_format_get,
  5652. msm_dai_q6_tdm_data_format_put),
  5653. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  5654. msm_dai_q6_tdm_data_format_get,
  5655. msm_dai_q6_tdm_data_format_put),
  5656. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  5657. msm_dai_q6_tdm_data_format_get,
  5658. msm_dai_q6_tdm_data_format_put),
  5659. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  5660. msm_dai_q6_tdm_data_format_get,
  5661. msm_dai_q6_tdm_data_format_put),
  5662. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  5663. msm_dai_q6_tdm_data_format_get,
  5664. msm_dai_q6_tdm_data_format_put),
  5665. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  5666. msm_dai_q6_tdm_data_format_get,
  5667. msm_dai_q6_tdm_data_format_put),
  5668. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  5669. msm_dai_q6_tdm_data_format_get,
  5670. msm_dai_q6_tdm_data_format_put),
  5671. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  5672. msm_dai_q6_tdm_data_format_get,
  5673. msm_dai_q6_tdm_data_format_put),
  5674. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  5675. msm_dai_q6_tdm_data_format_get,
  5676. msm_dai_q6_tdm_data_format_put),
  5677. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  5678. msm_dai_q6_tdm_data_format_get,
  5679. msm_dai_q6_tdm_data_format_put),
  5680. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  5681. msm_dai_q6_tdm_data_format_get,
  5682. msm_dai_q6_tdm_data_format_put),
  5683. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  5684. msm_dai_q6_tdm_data_format_get,
  5685. msm_dai_q6_tdm_data_format_put),
  5686. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  5687. msm_dai_q6_tdm_data_format_get,
  5688. msm_dai_q6_tdm_data_format_put),
  5689. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  5690. msm_dai_q6_tdm_data_format_get,
  5691. msm_dai_q6_tdm_data_format_put),
  5692. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  5693. msm_dai_q6_tdm_data_format_get,
  5694. msm_dai_q6_tdm_data_format_put),
  5695. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  5696. msm_dai_q6_tdm_data_format_get,
  5697. msm_dai_q6_tdm_data_format_put),
  5698. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  5699. msm_dai_q6_tdm_data_format_get,
  5700. msm_dai_q6_tdm_data_format_put),
  5701. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  5702. msm_dai_q6_tdm_data_format_get,
  5703. msm_dai_q6_tdm_data_format_put),
  5704. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  5705. msm_dai_q6_tdm_data_format_get,
  5706. msm_dai_q6_tdm_data_format_put),
  5707. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  5708. msm_dai_q6_tdm_data_format_get,
  5709. msm_dai_q6_tdm_data_format_put),
  5710. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  5711. msm_dai_q6_tdm_data_format_get,
  5712. msm_dai_q6_tdm_data_format_put),
  5713. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5714. msm_dai_q6_tdm_data_format_get,
  5715. msm_dai_q6_tdm_data_format_put),
  5716. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5717. msm_dai_q6_tdm_data_format_get,
  5718. msm_dai_q6_tdm_data_format_put),
  5719. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5720. msm_dai_q6_tdm_data_format_get,
  5721. msm_dai_q6_tdm_data_format_put),
  5722. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5723. msm_dai_q6_tdm_data_format_get,
  5724. msm_dai_q6_tdm_data_format_put),
  5725. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5726. msm_dai_q6_tdm_data_format_get,
  5727. msm_dai_q6_tdm_data_format_put),
  5728. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5729. msm_dai_q6_tdm_data_format_get,
  5730. msm_dai_q6_tdm_data_format_put),
  5731. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5732. msm_dai_q6_tdm_data_format_get,
  5733. msm_dai_q6_tdm_data_format_put),
  5734. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5735. msm_dai_q6_tdm_data_format_get,
  5736. msm_dai_q6_tdm_data_format_put),
  5737. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5738. msm_dai_q6_tdm_data_format_get,
  5739. msm_dai_q6_tdm_data_format_put),
  5740. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5741. msm_dai_q6_tdm_data_format_get,
  5742. msm_dai_q6_tdm_data_format_put),
  5743. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5744. msm_dai_q6_tdm_data_format_get,
  5745. msm_dai_q6_tdm_data_format_put),
  5746. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5747. msm_dai_q6_tdm_data_format_get,
  5748. msm_dai_q6_tdm_data_format_put),
  5749. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5750. msm_dai_q6_tdm_data_format_get,
  5751. msm_dai_q6_tdm_data_format_put),
  5752. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5753. msm_dai_q6_tdm_data_format_get,
  5754. msm_dai_q6_tdm_data_format_put),
  5755. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5756. msm_dai_q6_tdm_data_format_get,
  5757. msm_dai_q6_tdm_data_format_put),
  5758. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5759. msm_dai_q6_tdm_data_format_get,
  5760. msm_dai_q6_tdm_data_format_put),
  5761. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5762. msm_dai_q6_tdm_data_format_get,
  5763. msm_dai_q6_tdm_data_format_put),
  5764. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5765. msm_dai_q6_tdm_data_format_get,
  5766. msm_dai_q6_tdm_data_format_put),
  5767. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5768. msm_dai_q6_tdm_data_format_get,
  5769. msm_dai_q6_tdm_data_format_put),
  5770. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5771. msm_dai_q6_tdm_data_format_get,
  5772. msm_dai_q6_tdm_data_format_put),
  5773. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5774. msm_dai_q6_tdm_data_format_get,
  5775. msm_dai_q6_tdm_data_format_put),
  5776. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5777. msm_dai_q6_tdm_data_format_get,
  5778. msm_dai_q6_tdm_data_format_put),
  5779. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5780. msm_dai_q6_tdm_data_format_get,
  5781. msm_dai_q6_tdm_data_format_put),
  5782. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5783. msm_dai_q6_tdm_data_format_get,
  5784. msm_dai_q6_tdm_data_format_put),
  5785. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5786. msm_dai_q6_tdm_data_format_get,
  5787. msm_dai_q6_tdm_data_format_put),
  5788. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5789. msm_dai_q6_tdm_data_format_get,
  5790. msm_dai_q6_tdm_data_format_put),
  5791. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5792. msm_dai_q6_tdm_data_format_get,
  5793. msm_dai_q6_tdm_data_format_put),
  5794. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5795. msm_dai_q6_tdm_data_format_get,
  5796. msm_dai_q6_tdm_data_format_put),
  5797. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5798. msm_dai_q6_tdm_data_format_get,
  5799. msm_dai_q6_tdm_data_format_put),
  5800. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5801. msm_dai_q6_tdm_data_format_get,
  5802. msm_dai_q6_tdm_data_format_put),
  5803. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5804. msm_dai_q6_tdm_data_format_get,
  5805. msm_dai_q6_tdm_data_format_put),
  5806. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5807. msm_dai_q6_tdm_data_format_get,
  5808. msm_dai_q6_tdm_data_format_put),
  5809. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  5810. msm_dai_q6_tdm_data_format_get,
  5811. msm_dai_q6_tdm_data_format_put),
  5812. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  5813. msm_dai_q6_tdm_data_format_get,
  5814. msm_dai_q6_tdm_data_format_put),
  5815. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  5816. msm_dai_q6_tdm_data_format_get,
  5817. msm_dai_q6_tdm_data_format_put),
  5818. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  5819. msm_dai_q6_tdm_data_format_get,
  5820. msm_dai_q6_tdm_data_format_put),
  5821. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  5822. msm_dai_q6_tdm_data_format_get,
  5823. msm_dai_q6_tdm_data_format_put),
  5824. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  5825. msm_dai_q6_tdm_data_format_get,
  5826. msm_dai_q6_tdm_data_format_put),
  5827. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  5828. msm_dai_q6_tdm_data_format_get,
  5829. msm_dai_q6_tdm_data_format_put),
  5830. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  5831. msm_dai_q6_tdm_data_format_get,
  5832. msm_dai_q6_tdm_data_format_put),
  5833. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  5834. msm_dai_q6_tdm_data_format_get,
  5835. msm_dai_q6_tdm_data_format_put),
  5836. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  5837. msm_dai_q6_tdm_data_format_get,
  5838. msm_dai_q6_tdm_data_format_put),
  5839. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  5840. msm_dai_q6_tdm_data_format_get,
  5841. msm_dai_q6_tdm_data_format_put),
  5842. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  5843. msm_dai_q6_tdm_data_format_get,
  5844. msm_dai_q6_tdm_data_format_put),
  5845. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  5846. msm_dai_q6_tdm_data_format_get,
  5847. msm_dai_q6_tdm_data_format_put),
  5848. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  5849. msm_dai_q6_tdm_data_format_get,
  5850. msm_dai_q6_tdm_data_format_put),
  5851. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  5852. msm_dai_q6_tdm_data_format_get,
  5853. msm_dai_q6_tdm_data_format_put),
  5854. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  5855. msm_dai_q6_tdm_data_format_get,
  5856. msm_dai_q6_tdm_data_format_put),
  5857. };
  5858. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  5859. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  5860. msm_dai_q6_tdm_header_type_get,
  5861. msm_dai_q6_tdm_header_type_put),
  5862. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  5863. msm_dai_q6_tdm_header_type_get,
  5864. msm_dai_q6_tdm_header_type_put),
  5865. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  5866. msm_dai_q6_tdm_header_type_get,
  5867. msm_dai_q6_tdm_header_type_put),
  5868. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  5869. msm_dai_q6_tdm_header_type_get,
  5870. msm_dai_q6_tdm_header_type_put),
  5871. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  5872. msm_dai_q6_tdm_header_type_get,
  5873. msm_dai_q6_tdm_header_type_put),
  5874. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  5875. msm_dai_q6_tdm_header_type_get,
  5876. msm_dai_q6_tdm_header_type_put),
  5877. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  5878. msm_dai_q6_tdm_header_type_get,
  5879. msm_dai_q6_tdm_header_type_put),
  5880. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  5881. msm_dai_q6_tdm_header_type_get,
  5882. msm_dai_q6_tdm_header_type_put),
  5883. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  5884. msm_dai_q6_tdm_header_type_get,
  5885. msm_dai_q6_tdm_header_type_put),
  5886. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  5887. msm_dai_q6_tdm_header_type_get,
  5888. msm_dai_q6_tdm_header_type_put),
  5889. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  5890. msm_dai_q6_tdm_header_type_get,
  5891. msm_dai_q6_tdm_header_type_put),
  5892. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  5893. msm_dai_q6_tdm_header_type_get,
  5894. msm_dai_q6_tdm_header_type_put),
  5895. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  5896. msm_dai_q6_tdm_header_type_get,
  5897. msm_dai_q6_tdm_header_type_put),
  5898. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  5899. msm_dai_q6_tdm_header_type_get,
  5900. msm_dai_q6_tdm_header_type_put),
  5901. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  5902. msm_dai_q6_tdm_header_type_get,
  5903. msm_dai_q6_tdm_header_type_put),
  5904. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  5905. msm_dai_q6_tdm_header_type_get,
  5906. msm_dai_q6_tdm_header_type_put),
  5907. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  5908. msm_dai_q6_tdm_header_type_get,
  5909. msm_dai_q6_tdm_header_type_put),
  5910. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  5911. msm_dai_q6_tdm_header_type_get,
  5912. msm_dai_q6_tdm_header_type_put),
  5913. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  5914. msm_dai_q6_tdm_header_type_get,
  5915. msm_dai_q6_tdm_header_type_put),
  5916. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  5917. msm_dai_q6_tdm_header_type_get,
  5918. msm_dai_q6_tdm_header_type_put),
  5919. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  5920. msm_dai_q6_tdm_header_type_get,
  5921. msm_dai_q6_tdm_header_type_put),
  5922. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  5923. msm_dai_q6_tdm_header_type_get,
  5924. msm_dai_q6_tdm_header_type_put),
  5925. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  5926. msm_dai_q6_tdm_header_type_get,
  5927. msm_dai_q6_tdm_header_type_put),
  5928. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  5929. msm_dai_q6_tdm_header_type_get,
  5930. msm_dai_q6_tdm_header_type_put),
  5931. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  5932. msm_dai_q6_tdm_header_type_get,
  5933. msm_dai_q6_tdm_header_type_put),
  5934. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  5935. msm_dai_q6_tdm_header_type_get,
  5936. msm_dai_q6_tdm_header_type_put),
  5937. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  5938. msm_dai_q6_tdm_header_type_get,
  5939. msm_dai_q6_tdm_header_type_put),
  5940. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  5941. msm_dai_q6_tdm_header_type_get,
  5942. msm_dai_q6_tdm_header_type_put),
  5943. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  5944. msm_dai_q6_tdm_header_type_get,
  5945. msm_dai_q6_tdm_header_type_put),
  5946. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  5947. msm_dai_q6_tdm_header_type_get,
  5948. msm_dai_q6_tdm_header_type_put),
  5949. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  5950. msm_dai_q6_tdm_header_type_get,
  5951. msm_dai_q6_tdm_header_type_put),
  5952. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  5953. msm_dai_q6_tdm_header_type_get,
  5954. msm_dai_q6_tdm_header_type_put),
  5955. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  5956. msm_dai_q6_tdm_header_type_get,
  5957. msm_dai_q6_tdm_header_type_put),
  5958. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  5959. msm_dai_q6_tdm_header_type_get,
  5960. msm_dai_q6_tdm_header_type_put),
  5961. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  5962. msm_dai_q6_tdm_header_type_get,
  5963. msm_dai_q6_tdm_header_type_put),
  5964. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  5965. msm_dai_q6_tdm_header_type_get,
  5966. msm_dai_q6_tdm_header_type_put),
  5967. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  5968. msm_dai_q6_tdm_header_type_get,
  5969. msm_dai_q6_tdm_header_type_put),
  5970. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  5971. msm_dai_q6_tdm_header_type_get,
  5972. msm_dai_q6_tdm_header_type_put),
  5973. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  5974. msm_dai_q6_tdm_header_type_get,
  5975. msm_dai_q6_tdm_header_type_put),
  5976. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  5977. msm_dai_q6_tdm_header_type_get,
  5978. msm_dai_q6_tdm_header_type_put),
  5979. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  5980. msm_dai_q6_tdm_header_type_get,
  5981. msm_dai_q6_tdm_header_type_put),
  5982. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  5983. msm_dai_q6_tdm_header_type_get,
  5984. msm_dai_q6_tdm_header_type_put),
  5985. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  5986. msm_dai_q6_tdm_header_type_get,
  5987. msm_dai_q6_tdm_header_type_put),
  5988. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  5989. msm_dai_q6_tdm_header_type_get,
  5990. msm_dai_q6_tdm_header_type_put),
  5991. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  5992. msm_dai_q6_tdm_header_type_get,
  5993. msm_dai_q6_tdm_header_type_put),
  5994. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  5995. msm_dai_q6_tdm_header_type_get,
  5996. msm_dai_q6_tdm_header_type_put),
  5997. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  5998. msm_dai_q6_tdm_header_type_get,
  5999. msm_dai_q6_tdm_header_type_put),
  6000. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  6001. msm_dai_q6_tdm_header_type_get,
  6002. msm_dai_q6_tdm_header_type_put),
  6003. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  6004. msm_dai_q6_tdm_header_type_get,
  6005. msm_dai_q6_tdm_header_type_put),
  6006. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  6007. msm_dai_q6_tdm_header_type_get,
  6008. msm_dai_q6_tdm_header_type_put),
  6009. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  6010. msm_dai_q6_tdm_header_type_get,
  6011. msm_dai_q6_tdm_header_type_put),
  6012. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  6013. msm_dai_q6_tdm_header_type_get,
  6014. msm_dai_q6_tdm_header_type_put),
  6015. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  6016. msm_dai_q6_tdm_header_type_get,
  6017. msm_dai_q6_tdm_header_type_put),
  6018. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  6019. msm_dai_q6_tdm_header_type_get,
  6020. msm_dai_q6_tdm_header_type_put),
  6021. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  6022. msm_dai_q6_tdm_header_type_get,
  6023. msm_dai_q6_tdm_header_type_put),
  6024. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  6025. msm_dai_q6_tdm_header_type_get,
  6026. msm_dai_q6_tdm_header_type_put),
  6027. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  6028. msm_dai_q6_tdm_header_type_get,
  6029. msm_dai_q6_tdm_header_type_put),
  6030. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  6031. msm_dai_q6_tdm_header_type_get,
  6032. msm_dai_q6_tdm_header_type_put),
  6033. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  6034. msm_dai_q6_tdm_header_type_get,
  6035. msm_dai_q6_tdm_header_type_put),
  6036. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  6037. msm_dai_q6_tdm_header_type_get,
  6038. msm_dai_q6_tdm_header_type_put),
  6039. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  6040. msm_dai_q6_tdm_header_type_get,
  6041. msm_dai_q6_tdm_header_type_put),
  6042. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  6043. msm_dai_q6_tdm_header_type_get,
  6044. msm_dai_q6_tdm_header_type_put),
  6045. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  6046. msm_dai_q6_tdm_header_type_get,
  6047. msm_dai_q6_tdm_header_type_put),
  6048. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  6049. msm_dai_q6_tdm_header_type_get,
  6050. msm_dai_q6_tdm_header_type_put),
  6051. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  6052. msm_dai_q6_tdm_header_type_get,
  6053. msm_dai_q6_tdm_header_type_put),
  6054. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  6055. msm_dai_q6_tdm_header_type_get,
  6056. msm_dai_q6_tdm_header_type_put),
  6057. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  6058. msm_dai_q6_tdm_header_type_get,
  6059. msm_dai_q6_tdm_header_type_put),
  6060. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  6061. msm_dai_q6_tdm_header_type_get,
  6062. msm_dai_q6_tdm_header_type_put),
  6063. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  6064. msm_dai_q6_tdm_header_type_get,
  6065. msm_dai_q6_tdm_header_type_put),
  6066. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  6067. msm_dai_q6_tdm_header_type_get,
  6068. msm_dai_q6_tdm_header_type_put),
  6069. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  6070. msm_dai_q6_tdm_header_type_get,
  6071. msm_dai_q6_tdm_header_type_put),
  6072. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  6073. msm_dai_q6_tdm_header_type_get,
  6074. msm_dai_q6_tdm_header_type_put),
  6075. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  6076. msm_dai_q6_tdm_header_type_get,
  6077. msm_dai_q6_tdm_header_type_put),
  6078. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  6079. msm_dai_q6_tdm_header_type_get,
  6080. msm_dai_q6_tdm_header_type_put),
  6081. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  6082. msm_dai_q6_tdm_header_type_get,
  6083. msm_dai_q6_tdm_header_type_put),
  6084. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  6085. msm_dai_q6_tdm_header_type_get,
  6086. msm_dai_q6_tdm_header_type_put),
  6087. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  6088. msm_dai_q6_tdm_header_type_get,
  6089. msm_dai_q6_tdm_header_type_put),
  6090. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  6091. msm_dai_q6_tdm_header_type_get,
  6092. msm_dai_q6_tdm_header_type_put),
  6093. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  6094. msm_dai_q6_tdm_header_type_get,
  6095. msm_dai_q6_tdm_header_type_put),
  6096. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  6097. msm_dai_q6_tdm_header_type_get,
  6098. msm_dai_q6_tdm_header_type_put),
  6099. };
  6100. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  6101. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  6102. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6103. msm_dai_q6_tdm_header_get,
  6104. msm_dai_q6_tdm_header_put),
  6105. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  6106. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6107. msm_dai_q6_tdm_header_get,
  6108. msm_dai_q6_tdm_header_put),
  6109. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  6110. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6111. msm_dai_q6_tdm_header_get,
  6112. msm_dai_q6_tdm_header_put),
  6113. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  6114. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6115. msm_dai_q6_tdm_header_get,
  6116. msm_dai_q6_tdm_header_put),
  6117. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  6118. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6119. msm_dai_q6_tdm_header_get,
  6120. msm_dai_q6_tdm_header_put),
  6121. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  6122. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6123. msm_dai_q6_tdm_header_get,
  6124. msm_dai_q6_tdm_header_put),
  6125. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  6126. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6127. msm_dai_q6_tdm_header_get,
  6128. msm_dai_q6_tdm_header_put),
  6129. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  6130. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6131. msm_dai_q6_tdm_header_get,
  6132. msm_dai_q6_tdm_header_put),
  6133. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  6134. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6135. msm_dai_q6_tdm_header_get,
  6136. msm_dai_q6_tdm_header_put),
  6137. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  6138. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6139. msm_dai_q6_tdm_header_get,
  6140. msm_dai_q6_tdm_header_put),
  6141. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  6142. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6143. msm_dai_q6_tdm_header_get,
  6144. msm_dai_q6_tdm_header_put),
  6145. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  6146. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6147. msm_dai_q6_tdm_header_get,
  6148. msm_dai_q6_tdm_header_put),
  6149. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  6150. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6151. msm_dai_q6_tdm_header_get,
  6152. msm_dai_q6_tdm_header_put),
  6153. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  6154. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6155. msm_dai_q6_tdm_header_get,
  6156. msm_dai_q6_tdm_header_put),
  6157. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  6158. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6159. msm_dai_q6_tdm_header_get,
  6160. msm_dai_q6_tdm_header_put),
  6161. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  6162. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6163. msm_dai_q6_tdm_header_get,
  6164. msm_dai_q6_tdm_header_put),
  6165. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  6166. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6167. msm_dai_q6_tdm_header_get,
  6168. msm_dai_q6_tdm_header_put),
  6169. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  6170. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6171. msm_dai_q6_tdm_header_get,
  6172. msm_dai_q6_tdm_header_put),
  6173. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  6174. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6175. msm_dai_q6_tdm_header_get,
  6176. msm_dai_q6_tdm_header_put),
  6177. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  6178. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6179. msm_dai_q6_tdm_header_get,
  6180. msm_dai_q6_tdm_header_put),
  6181. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  6182. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6183. msm_dai_q6_tdm_header_get,
  6184. msm_dai_q6_tdm_header_put),
  6185. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  6186. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6187. msm_dai_q6_tdm_header_get,
  6188. msm_dai_q6_tdm_header_put),
  6189. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  6190. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6191. msm_dai_q6_tdm_header_get,
  6192. msm_dai_q6_tdm_header_put),
  6193. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  6194. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6195. msm_dai_q6_tdm_header_get,
  6196. msm_dai_q6_tdm_header_put),
  6197. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  6198. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6199. msm_dai_q6_tdm_header_get,
  6200. msm_dai_q6_tdm_header_put),
  6201. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  6202. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6203. msm_dai_q6_tdm_header_get,
  6204. msm_dai_q6_tdm_header_put),
  6205. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  6206. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6207. msm_dai_q6_tdm_header_get,
  6208. msm_dai_q6_tdm_header_put),
  6209. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  6210. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6211. msm_dai_q6_tdm_header_get,
  6212. msm_dai_q6_tdm_header_put),
  6213. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  6214. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6215. msm_dai_q6_tdm_header_get,
  6216. msm_dai_q6_tdm_header_put),
  6217. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  6218. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6219. msm_dai_q6_tdm_header_get,
  6220. msm_dai_q6_tdm_header_put),
  6221. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  6222. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6223. msm_dai_q6_tdm_header_get,
  6224. msm_dai_q6_tdm_header_put),
  6225. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  6226. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6227. msm_dai_q6_tdm_header_get,
  6228. msm_dai_q6_tdm_header_put),
  6229. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  6230. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6231. msm_dai_q6_tdm_header_get,
  6232. msm_dai_q6_tdm_header_put),
  6233. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  6234. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6235. msm_dai_q6_tdm_header_get,
  6236. msm_dai_q6_tdm_header_put),
  6237. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  6238. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6239. msm_dai_q6_tdm_header_get,
  6240. msm_dai_q6_tdm_header_put),
  6241. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  6242. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6243. msm_dai_q6_tdm_header_get,
  6244. msm_dai_q6_tdm_header_put),
  6245. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  6246. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6247. msm_dai_q6_tdm_header_get,
  6248. msm_dai_q6_tdm_header_put),
  6249. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  6250. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6251. msm_dai_q6_tdm_header_get,
  6252. msm_dai_q6_tdm_header_put),
  6253. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  6254. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6255. msm_dai_q6_tdm_header_get,
  6256. msm_dai_q6_tdm_header_put),
  6257. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  6258. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6259. msm_dai_q6_tdm_header_get,
  6260. msm_dai_q6_tdm_header_put),
  6261. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  6262. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6263. msm_dai_q6_tdm_header_get,
  6264. msm_dai_q6_tdm_header_put),
  6265. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  6266. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6267. msm_dai_q6_tdm_header_get,
  6268. msm_dai_q6_tdm_header_put),
  6269. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  6270. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6271. msm_dai_q6_tdm_header_get,
  6272. msm_dai_q6_tdm_header_put),
  6273. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  6274. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6275. msm_dai_q6_tdm_header_get,
  6276. msm_dai_q6_tdm_header_put),
  6277. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  6278. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6279. msm_dai_q6_tdm_header_get,
  6280. msm_dai_q6_tdm_header_put),
  6281. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  6282. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6283. msm_dai_q6_tdm_header_get,
  6284. msm_dai_q6_tdm_header_put),
  6285. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  6286. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6287. msm_dai_q6_tdm_header_get,
  6288. msm_dai_q6_tdm_header_put),
  6289. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  6290. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6291. msm_dai_q6_tdm_header_get,
  6292. msm_dai_q6_tdm_header_put),
  6293. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  6294. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6295. msm_dai_q6_tdm_header_get,
  6296. msm_dai_q6_tdm_header_put),
  6297. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  6298. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6299. msm_dai_q6_tdm_header_get,
  6300. msm_dai_q6_tdm_header_put),
  6301. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  6302. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6303. msm_dai_q6_tdm_header_get,
  6304. msm_dai_q6_tdm_header_put),
  6305. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  6306. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6307. msm_dai_q6_tdm_header_get,
  6308. msm_dai_q6_tdm_header_put),
  6309. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  6310. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6311. msm_dai_q6_tdm_header_get,
  6312. msm_dai_q6_tdm_header_put),
  6313. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  6314. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6315. msm_dai_q6_tdm_header_get,
  6316. msm_dai_q6_tdm_header_put),
  6317. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  6318. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6319. msm_dai_q6_tdm_header_get,
  6320. msm_dai_q6_tdm_header_put),
  6321. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  6322. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6323. msm_dai_q6_tdm_header_get,
  6324. msm_dai_q6_tdm_header_put),
  6325. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  6326. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6327. msm_dai_q6_tdm_header_get,
  6328. msm_dai_q6_tdm_header_put),
  6329. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  6330. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6331. msm_dai_q6_tdm_header_get,
  6332. msm_dai_q6_tdm_header_put),
  6333. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  6334. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6335. msm_dai_q6_tdm_header_get,
  6336. msm_dai_q6_tdm_header_put),
  6337. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  6338. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6339. msm_dai_q6_tdm_header_get,
  6340. msm_dai_q6_tdm_header_put),
  6341. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  6342. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6343. msm_dai_q6_tdm_header_get,
  6344. msm_dai_q6_tdm_header_put),
  6345. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  6346. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6347. msm_dai_q6_tdm_header_get,
  6348. msm_dai_q6_tdm_header_put),
  6349. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  6350. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6351. msm_dai_q6_tdm_header_get,
  6352. msm_dai_q6_tdm_header_put),
  6353. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  6354. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6355. msm_dai_q6_tdm_header_get,
  6356. msm_dai_q6_tdm_header_put),
  6357. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  6358. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6359. msm_dai_q6_tdm_header_get,
  6360. msm_dai_q6_tdm_header_put),
  6361. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  6362. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6363. msm_dai_q6_tdm_header_get,
  6364. msm_dai_q6_tdm_header_put),
  6365. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  6366. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6367. msm_dai_q6_tdm_header_get,
  6368. msm_dai_q6_tdm_header_put),
  6369. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  6370. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6371. msm_dai_q6_tdm_header_get,
  6372. msm_dai_q6_tdm_header_put),
  6373. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  6374. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6375. msm_dai_q6_tdm_header_get,
  6376. msm_dai_q6_tdm_header_put),
  6377. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  6378. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6379. msm_dai_q6_tdm_header_get,
  6380. msm_dai_q6_tdm_header_put),
  6381. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  6382. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6383. msm_dai_q6_tdm_header_get,
  6384. msm_dai_q6_tdm_header_put),
  6385. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  6386. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6387. msm_dai_q6_tdm_header_get,
  6388. msm_dai_q6_tdm_header_put),
  6389. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  6390. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6391. msm_dai_q6_tdm_header_get,
  6392. msm_dai_q6_tdm_header_put),
  6393. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  6394. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6395. msm_dai_q6_tdm_header_get,
  6396. msm_dai_q6_tdm_header_put),
  6397. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  6398. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6399. msm_dai_q6_tdm_header_get,
  6400. msm_dai_q6_tdm_header_put),
  6401. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  6402. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6403. msm_dai_q6_tdm_header_get,
  6404. msm_dai_q6_tdm_header_put),
  6405. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  6406. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6407. msm_dai_q6_tdm_header_get,
  6408. msm_dai_q6_tdm_header_put),
  6409. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  6410. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6411. msm_dai_q6_tdm_header_get,
  6412. msm_dai_q6_tdm_header_put),
  6413. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  6414. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6415. msm_dai_q6_tdm_header_get,
  6416. msm_dai_q6_tdm_header_put),
  6417. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  6418. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6419. msm_dai_q6_tdm_header_get,
  6420. msm_dai_q6_tdm_header_put),
  6421. };
  6422. static int msm_dai_q6_tdm_set_clk(
  6423. struct msm_dai_q6_tdm_dai_data *dai_data,
  6424. u16 port_id, bool enable)
  6425. {
  6426. int rc = 0;
  6427. dai_data->clk_set.enable = enable;
  6428. rc = afe_set_lpass_clock_v2(port_id,
  6429. &dai_data->clk_set);
  6430. if (rc < 0)
  6431. pr_err("%s: afe lpass clock failed, err:%d\n",
  6432. __func__, rc);
  6433. return rc;
  6434. }
  6435. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  6436. {
  6437. int rc = 0;
  6438. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  6439. dev_get_drvdata(dai->dev);
  6440. struct snd_kcontrol *data_format_kcontrol = NULL;
  6441. struct snd_kcontrol *header_type_kcontrol = NULL;
  6442. struct snd_kcontrol *header_kcontrol = NULL;
  6443. int port_idx = 0;
  6444. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  6445. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  6446. const struct snd_kcontrol_new *header_ctrl = NULL;
  6447. msm_dai_q6_set_dai_id(dai);
  6448. port_idx = msm_dai_q6_get_port_idx(dai->id);
  6449. if (port_idx < 0) {
  6450. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6451. __func__, dai->id);
  6452. rc = -EINVAL;
  6453. goto rtn;
  6454. }
  6455. data_format_ctrl =
  6456. &tdm_config_controls_data_format[port_idx];
  6457. header_type_ctrl =
  6458. &tdm_config_controls_header_type[port_idx];
  6459. header_ctrl =
  6460. &tdm_config_controls_header[port_idx];
  6461. if (data_format_ctrl) {
  6462. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  6463. tdm_dai_data);
  6464. rc = snd_ctl_add(dai->component->card->snd_card,
  6465. data_format_kcontrol);
  6466. if (rc < 0) {
  6467. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  6468. __func__, dai->name);
  6469. goto rtn;
  6470. }
  6471. }
  6472. if (header_type_ctrl) {
  6473. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  6474. tdm_dai_data);
  6475. rc = snd_ctl_add(dai->component->card->snd_card,
  6476. header_type_kcontrol);
  6477. if (rc < 0) {
  6478. if (data_format_kcontrol)
  6479. snd_ctl_remove(dai->component->card->snd_card,
  6480. data_format_kcontrol);
  6481. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  6482. __func__, dai->name);
  6483. goto rtn;
  6484. }
  6485. }
  6486. if (header_ctrl) {
  6487. header_kcontrol = snd_ctl_new1(header_ctrl,
  6488. tdm_dai_data);
  6489. rc = snd_ctl_add(dai->component->card->snd_card,
  6490. header_kcontrol);
  6491. if (rc < 0) {
  6492. if (header_type_kcontrol)
  6493. snd_ctl_remove(dai->component->card->snd_card,
  6494. header_type_kcontrol);
  6495. if (data_format_kcontrol)
  6496. snd_ctl_remove(dai->component->card->snd_card,
  6497. data_format_kcontrol);
  6498. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  6499. __func__, dai->name);
  6500. goto rtn;
  6501. }
  6502. }
  6503. if (tdm_dai_data->is_island_dai)
  6504. rc = msm_dai_q6_add_island_mx_ctls(
  6505. dai->component->card->snd_card,
  6506. dai->name,
  6507. dai->id, (void *)tdm_dai_data);
  6508. rc = msm_dai_q6_dai_add_route(dai);
  6509. rtn:
  6510. return rc;
  6511. }
  6512. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  6513. {
  6514. int rc = 0;
  6515. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  6516. dev_get_drvdata(dai->dev);
  6517. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  6518. int group_idx = 0;
  6519. atomic_t *group_ref = NULL;
  6520. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6521. if (group_idx < 0) {
  6522. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6523. __func__, dai->id);
  6524. return -EINVAL;
  6525. }
  6526. group_ref = &tdm_group_ref[group_idx];
  6527. /* If AFE port is still up, close it */
  6528. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  6529. rc = afe_close(dai->id); /* can block */
  6530. if (rc < 0) {
  6531. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  6532. __func__, dai->id);
  6533. }
  6534. atomic_dec(group_ref);
  6535. clear_bit(STATUS_PORT_STARTED,
  6536. tdm_dai_data->status_mask);
  6537. if (atomic_read(group_ref) == 0) {
  6538. rc = afe_port_group_enable(group_id,
  6539. NULL, false);
  6540. if (rc < 0) {
  6541. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  6542. group_id);
  6543. }
  6544. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  6545. dai->id, false);
  6546. if (rc < 0) {
  6547. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  6548. __func__, dai->id);
  6549. }
  6550. }
  6551. }
  6552. return 0;
  6553. }
  6554. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  6555. unsigned int tx_mask,
  6556. unsigned int rx_mask,
  6557. int slots, int slot_width)
  6558. {
  6559. int rc = 0;
  6560. struct msm_dai_q6_tdm_dai_data *dai_data =
  6561. dev_get_drvdata(dai->dev);
  6562. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  6563. &dai_data->group_cfg.tdm_cfg;
  6564. unsigned int cap_mask;
  6565. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  6566. /* HW only supports 16 and 32 bit slot width configuration */
  6567. if ((slot_width != 16) && (slot_width != 32)) {
  6568. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  6569. __func__, slot_width);
  6570. return -EINVAL;
  6571. }
  6572. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  6573. switch (slots) {
  6574. case 2:
  6575. cap_mask = 0x03;
  6576. break;
  6577. case 4:
  6578. cap_mask = 0x0F;
  6579. break;
  6580. case 8:
  6581. cap_mask = 0xFF;
  6582. break;
  6583. case 16:
  6584. cap_mask = 0xFFFF;
  6585. break;
  6586. default:
  6587. dev_err(dai->dev, "%s: invalid slots %d\n",
  6588. __func__, slots);
  6589. return -EINVAL;
  6590. }
  6591. switch (dai->id) {
  6592. case AFE_PORT_ID_PRIMARY_TDM_RX:
  6593. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  6594. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  6595. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  6596. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  6597. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  6598. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  6599. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  6600. case AFE_PORT_ID_SECONDARY_TDM_RX:
  6601. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  6602. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  6603. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  6604. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  6605. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  6606. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  6607. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  6608. case AFE_PORT_ID_TERTIARY_TDM_RX:
  6609. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  6610. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  6611. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  6612. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  6613. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  6614. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  6615. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  6616. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  6617. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  6618. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  6619. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  6620. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  6621. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  6622. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  6623. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  6624. case AFE_PORT_ID_QUINARY_TDM_RX:
  6625. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  6626. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  6627. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  6628. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  6629. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  6630. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  6631. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  6632. tdm_group->nslots_per_frame = slots;
  6633. tdm_group->slot_width = slot_width;
  6634. tdm_group->slot_mask = rx_mask & cap_mask;
  6635. break;
  6636. case AFE_PORT_ID_PRIMARY_TDM_TX:
  6637. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6638. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6639. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6640. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6641. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6642. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6643. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6644. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6645. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6646. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6647. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6648. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6649. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6650. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6651. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6652. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6653. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6654. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6655. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6656. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6657. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6658. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6659. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6660. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6661. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6662. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6663. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6664. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6665. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6666. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6667. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6668. case AFE_PORT_ID_QUINARY_TDM_TX:
  6669. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6670. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6671. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6672. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6673. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6674. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6675. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6676. tdm_group->nslots_per_frame = slots;
  6677. tdm_group->slot_width = slot_width;
  6678. tdm_group->slot_mask = tx_mask & cap_mask;
  6679. break;
  6680. default:
  6681. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6682. __func__, dai->id);
  6683. return -EINVAL;
  6684. }
  6685. return rc;
  6686. }
  6687. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  6688. int clk_id, unsigned int freq, int dir)
  6689. {
  6690. struct msm_dai_q6_tdm_dai_data *dai_data =
  6691. dev_get_drvdata(dai->dev);
  6692. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  6693. (dai->id <= AFE_PORT_ID_QUINARY_TDM_TX_7)) {
  6694. dai_data->clk_set.clk_freq_in_hz = freq;
  6695. } else {
  6696. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6697. __func__, dai->id);
  6698. return -EINVAL;
  6699. }
  6700. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  6701. __func__, dai->id, freq);
  6702. return 0;
  6703. }
  6704. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  6705. unsigned int tx_num, unsigned int *tx_slot,
  6706. unsigned int rx_num, unsigned int *rx_slot)
  6707. {
  6708. int rc = 0;
  6709. struct msm_dai_q6_tdm_dai_data *dai_data =
  6710. dev_get_drvdata(dai->dev);
  6711. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6712. &dai_data->port_cfg.slot_mapping;
  6713. int i = 0;
  6714. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  6715. switch (dai->id) {
  6716. case AFE_PORT_ID_PRIMARY_TDM_RX:
  6717. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  6718. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  6719. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  6720. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  6721. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  6722. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  6723. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  6724. case AFE_PORT_ID_SECONDARY_TDM_RX:
  6725. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  6726. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  6727. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  6728. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  6729. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  6730. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  6731. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  6732. case AFE_PORT_ID_TERTIARY_TDM_RX:
  6733. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  6734. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  6735. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  6736. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  6737. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  6738. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  6739. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  6740. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  6741. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  6742. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  6743. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  6744. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  6745. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  6746. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  6747. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  6748. case AFE_PORT_ID_QUINARY_TDM_RX:
  6749. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  6750. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  6751. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  6752. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  6753. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  6754. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  6755. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  6756. if (!rx_slot) {
  6757. dev_err(dai->dev, "%s: rx slot not found\n", __func__);
  6758. return -EINVAL;
  6759. }
  6760. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6761. dev_err(dai->dev, "%s: invalid rx num %d\n", __func__,
  6762. rx_num);
  6763. return -EINVAL;
  6764. }
  6765. for (i = 0; i < rx_num; i++)
  6766. slot_mapping->offset[i] = rx_slot[i];
  6767. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6768. slot_mapping->offset[i] =
  6769. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6770. slot_mapping->num_channel = rx_num;
  6771. break;
  6772. case AFE_PORT_ID_PRIMARY_TDM_TX:
  6773. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6774. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6775. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6776. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6777. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6778. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6779. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6780. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6781. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6782. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6783. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6784. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6785. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6786. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6787. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6788. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6789. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6790. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6791. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6792. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6793. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6794. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6795. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6796. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6797. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6798. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6799. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6800. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6801. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6802. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6803. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6804. case AFE_PORT_ID_QUINARY_TDM_TX:
  6805. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6806. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6807. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6808. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6809. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6810. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6811. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6812. if (!tx_slot) {
  6813. dev_err(dai->dev, "%s: tx slot not found\n", __func__);
  6814. return -EINVAL;
  6815. }
  6816. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6817. dev_err(dai->dev, "%s: invalid tx num %d\n", __func__,
  6818. tx_num);
  6819. return -EINVAL;
  6820. }
  6821. for (i = 0; i < tx_num; i++)
  6822. slot_mapping->offset[i] = tx_slot[i];
  6823. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6824. slot_mapping->offset[i] =
  6825. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6826. slot_mapping->num_channel = tx_num;
  6827. break;
  6828. default:
  6829. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6830. __func__, dai->id);
  6831. return -EINVAL;
  6832. }
  6833. return rc;
  6834. }
  6835. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  6836. struct snd_pcm_hw_params *params,
  6837. struct snd_soc_dai *dai)
  6838. {
  6839. struct msm_dai_q6_tdm_dai_data *dai_data =
  6840. dev_get_drvdata(dai->dev);
  6841. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  6842. &dai_data->group_cfg.tdm_cfg;
  6843. struct afe_param_id_tdm_cfg *tdm =
  6844. &dai_data->port_cfg.tdm;
  6845. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6846. &dai_data->port_cfg.slot_mapping;
  6847. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  6848. &dai_data->port_cfg.custom_tdm_header;
  6849. pr_debug("%s: dev_name: %s\n",
  6850. __func__, dev_name(dai->dev));
  6851. if ((params_channels(params) == 0) ||
  6852. (params_channels(params) > 8)) {
  6853. dev_err(dai->dev, "%s: invalid param channels %d\n",
  6854. __func__, params_channels(params));
  6855. return -EINVAL;
  6856. }
  6857. switch (params_format(params)) {
  6858. case SNDRV_PCM_FORMAT_S16_LE:
  6859. dai_data->bitwidth = 16;
  6860. break;
  6861. case SNDRV_PCM_FORMAT_S24_LE:
  6862. case SNDRV_PCM_FORMAT_S24_3LE:
  6863. dai_data->bitwidth = 24;
  6864. break;
  6865. case SNDRV_PCM_FORMAT_S32_LE:
  6866. dai_data->bitwidth = 32;
  6867. break;
  6868. default:
  6869. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  6870. __func__, params_format(params));
  6871. return -EINVAL;
  6872. }
  6873. dai_data->channels = params_channels(params);
  6874. dai_data->rate = params_rate(params);
  6875. /*
  6876. * update tdm group config param
  6877. * NOTE: group config is set to the same as slot config.
  6878. */
  6879. tdm_group->bit_width = tdm_group->slot_width;
  6880. tdm_group->num_channels = tdm_group->nslots_per_frame;
  6881. tdm_group->sample_rate = dai_data->rate;
  6882. pr_debug("%s: TDM GROUP:\n"
  6883. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6884. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  6885. __func__,
  6886. tdm_group->num_channels,
  6887. tdm_group->sample_rate,
  6888. tdm_group->bit_width,
  6889. tdm_group->nslots_per_frame,
  6890. tdm_group->slot_width,
  6891. tdm_group->slot_mask);
  6892. pr_debug("%s: TDM GROUP:\n"
  6893. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  6894. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  6895. __func__,
  6896. tdm_group->port_id[0],
  6897. tdm_group->port_id[1],
  6898. tdm_group->port_id[2],
  6899. tdm_group->port_id[3],
  6900. tdm_group->port_id[4],
  6901. tdm_group->port_id[5],
  6902. tdm_group->port_id[6],
  6903. tdm_group->port_id[7]);
  6904. /*
  6905. * update tdm config param
  6906. * NOTE: channels/rate/bitwidth are per stream property
  6907. */
  6908. tdm->num_channels = dai_data->channels;
  6909. tdm->sample_rate = dai_data->rate;
  6910. tdm->bit_width = dai_data->bitwidth;
  6911. /*
  6912. * port slot config is the same as group slot config
  6913. * port slot mask should be set according to offset
  6914. */
  6915. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  6916. tdm->slot_width = tdm_group->slot_width;
  6917. tdm->slot_mask = tdm_group->slot_mask;
  6918. pr_debug("%s: TDM:\n"
  6919. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6920. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  6921. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  6922. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  6923. __func__,
  6924. tdm->num_channels,
  6925. tdm->sample_rate,
  6926. tdm->bit_width,
  6927. tdm->nslots_per_frame,
  6928. tdm->slot_width,
  6929. tdm->slot_mask,
  6930. tdm->data_format,
  6931. tdm->sync_mode,
  6932. tdm->sync_src,
  6933. tdm->ctrl_data_out_enable,
  6934. tdm->ctrl_invert_sync_pulse,
  6935. tdm->ctrl_sync_data_delay);
  6936. /*
  6937. * update slot mapping config param
  6938. * NOTE: channels/rate/bitwidth are per stream property
  6939. */
  6940. slot_mapping->bitwidth = dai_data->bitwidth;
  6941. pr_debug("%s: SLOT MAPPING:\n"
  6942. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  6943. __func__,
  6944. slot_mapping->num_channel,
  6945. slot_mapping->bitwidth,
  6946. slot_mapping->data_align_type);
  6947. pr_debug("%s: SLOT MAPPING:\n"
  6948. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  6949. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  6950. __func__,
  6951. slot_mapping->offset[0],
  6952. slot_mapping->offset[1],
  6953. slot_mapping->offset[2],
  6954. slot_mapping->offset[3],
  6955. slot_mapping->offset[4],
  6956. slot_mapping->offset[5],
  6957. slot_mapping->offset[6],
  6958. slot_mapping->offset[7]);
  6959. /*
  6960. * update custom header config param
  6961. * NOTE: channels/rate/bitwidth are per playback stream property.
  6962. * custom tdm header only applicable to playback stream.
  6963. */
  6964. if (custom_tdm_header->header_type !=
  6965. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  6966. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6967. "start_offset=0x%x header_width=%d\n"
  6968. "num_frame_repeat=%d header_type=0x%x\n",
  6969. __func__,
  6970. custom_tdm_header->start_offset,
  6971. custom_tdm_header->header_width,
  6972. custom_tdm_header->num_frame_repeat,
  6973. custom_tdm_header->header_type);
  6974. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6975. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  6976. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  6977. __func__,
  6978. custom_tdm_header->header[0],
  6979. custom_tdm_header->header[1],
  6980. custom_tdm_header->header[2],
  6981. custom_tdm_header->header[3],
  6982. custom_tdm_header->header[4],
  6983. custom_tdm_header->header[5],
  6984. custom_tdm_header->header[6],
  6985. custom_tdm_header->header[7]);
  6986. }
  6987. return 0;
  6988. }
  6989. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  6990. struct snd_soc_dai *dai)
  6991. {
  6992. int rc = 0;
  6993. struct msm_dai_q6_tdm_dai_data *dai_data =
  6994. dev_get_drvdata(dai->dev);
  6995. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  6996. int group_idx = 0;
  6997. atomic_t *group_ref = NULL;
  6998. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  6999. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  7000. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  7001. dev_dbg(dai->dev,
  7002. "%s: Custom tdm header not supported\n", __func__);
  7003. group_idx = msm_dai_q6_get_group_idx(dai->id);
  7004. if (group_idx < 0) {
  7005. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  7006. __func__, dai->id);
  7007. return -EINVAL;
  7008. }
  7009. mutex_lock(&tdm_mutex);
  7010. group_ref = &tdm_group_ref[group_idx];
  7011. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  7012. if (q6core_get_avcs_api_version_per_service(
  7013. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  7014. /*
  7015. * send island mode config.
  7016. * This should be the first configuration
  7017. */
  7018. rc = afe_send_port_island_mode(dai->id);
  7019. if (rc)
  7020. dev_err(dai->dev, "%s: afe send island mode failed %d\n",
  7021. __func__, rc);
  7022. }
  7023. /* PORT START should be set if prepare called
  7024. * in active state.
  7025. */
  7026. if (atomic_read(group_ref) == 0) {
  7027. /* TX and RX share the same clk.
  7028. * AFE clk is enabled per group to simplify the logic.
  7029. * DSP will monitor the clk count.
  7030. */
  7031. rc = msm_dai_q6_tdm_set_clk(dai_data,
  7032. dai->id, true);
  7033. if (rc < 0) {
  7034. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  7035. __func__, dai->id);
  7036. goto rtn;
  7037. }
  7038. /*
  7039. * if only one port, don't do group enable as there
  7040. * is no group need for only one port
  7041. */
  7042. if (dai_data->num_group_ports > 1) {
  7043. rc = afe_port_group_enable(group_id,
  7044. &dai_data->group_cfg, true);
  7045. if (rc < 0) {
  7046. dev_err(dai->dev,
  7047. "%s: fail to enable AFE group 0x%x\n",
  7048. __func__, group_id);
  7049. goto rtn;
  7050. }
  7051. }
  7052. }
  7053. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  7054. dai_data->rate, dai_data->num_group_ports);
  7055. if (rc < 0) {
  7056. if (atomic_read(group_ref) == 0) {
  7057. afe_port_group_enable(group_id,
  7058. NULL, false);
  7059. msm_dai_q6_tdm_set_clk(dai_data,
  7060. dai->id, false);
  7061. }
  7062. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  7063. __func__, dai->id);
  7064. } else {
  7065. set_bit(STATUS_PORT_STARTED,
  7066. dai_data->status_mask);
  7067. atomic_inc(group_ref);
  7068. }
  7069. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  7070. /* NOTE: AFE should error out if HW resource contention */
  7071. }
  7072. rtn:
  7073. mutex_unlock(&tdm_mutex);
  7074. return rc;
  7075. }
  7076. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  7077. struct snd_soc_dai *dai)
  7078. {
  7079. int rc = 0;
  7080. struct msm_dai_q6_tdm_dai_data *dai_data =
  7081. dev_get_drvdata(dai->dev);
  7082. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  7083. int group_idx = 0;
  7084. atomic_t *group_ref = NULL;
  7085. group_idx = msm_dai_q6_get_group_idx(dai->id);
  7086. if (group_idx < 0) {
  7087. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  7088. __func__, dai->id);
  7089. return;
  7090. }
  7091. mutex_lock(&tdm_mutex);
  7092. group_ref = &tdm_group_ref[group_idx];
  7093. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  7094. rc = afe_close(dai->id);
  7095. if (rc < 0) {
  7096. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  7097. __func__, dai->id);
  7098. }
  7099. atomic_dec(group_ref);
  7100. clear_bit(STATUS_PORT_STARTED,
  7101. dai_data->status_mask);
  7102. if (atomic_read(group_ref) == 0) {
  7103. rc = afe_port_group_enable(group_id,
  7104. NULL, false);
  7105. if (rc < 0) {
  7106. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  7107. __func__, group_id);
  7108. }
  7109. rc = msm_dai_q6_tdm_set_clk(dai_data,
  7110. dai->id, false);
  7111. if (rc < 0) {
  7112. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  7113. __func__, dai->id);
  7114. }
  7115. }
  7116. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  7117. /* NOTE: AFE should error out if HW resource contention */
  7118. }
  7119. mutex_unlock(&tdm_mutex);
  7120. }
  7121. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  7122. .prepare = msm_dai_q6_tdm_prepare,
  7123. .hw_params = msm_dai_q6_tdm_hw_params,
  7124. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  7125. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  7126. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  7127. .shutdown = msm_dai_q6_tdm_shutdown,
  7128. };
  7129. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  7130. {
  7131. .playback = {
  7132. .stream_name = "Primary TDM0 Playback",
  7133. .aif_name = "PRI_TDM_RX_0",
  7134. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7135. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7136. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7137. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7138. SNDRV_PCM_FMTBIT_S24_LE |
  7139. SNDRV_PCM_FMTBIT_S32_LE,
  7140. .channels_min = 1,
  7141. .channels_max = 8,
  7142. .rate_min = 8000,
  7143. .rate_max = 352800,
  7144. },
  7145. .ops = &msm_dai_q6_tdm_ops,
  7146. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  7147. .probe = msm_dai_q6_dai_tdm_probe,
  7148. .remove = msm_dai_q6_dai_tdm_remove,
  7149. },
  7150. {
  7151. .playback = {
  7152. .stream_name = "Primary TDM1 Playback",
  7153. .aif_name = "PRI_TDM_RX_1",
  7154. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7155. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7156. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7157. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7158. SNDRV_PCM_FMTBIT_S24_LE |
  7159. SNDRV_PCM_FMTBIT_S32_LE,
  7160. .channels_min = 1,
  7161. .channels_max = 8,
  7162. .rate_min = 8000,
  7163. .rate_max = 352800,
  7164. },
  7165. .ops = &msm_dai_q6_tdm_ops,
  7166. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  7167. .probe = msm_dai_q6_dai_tdm_probe,
  7168. .remove = msm_dai_q6_dai_tdm_remove,
  7169. },
  7170. {
  7171. .playback = {
  7172. .stream_name = "Primary TDM2 Playback",
  7173. .aif_name = "PRI_TDM_RX_2",
  7174. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7175. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7176. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7177. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7178. SNDRV_PCM_FMTBIT_S24_LE |
  7179. SNDRV_PCM_FMTBIT_S32_LE,
  7180. .channels_min = 1,
  7181. .channels_max = 8,
  7182. .rate_min = 8000,
  7183. .rate_max = 352800,
  7184. },
  7185. .ops = &msm_dai_q6_tdm_ops,
  7186. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  7187. .probe = msm_dai_q6_dai_tdm_probe,
  7188. .remove = msm_dai_q6_dai_tdm_remove,
  7189. },
  7190. {
  7191. .playback = {
  7192. .stream_name = "Primary TDM3 Playback",
  7193. .aif_name = "PRI_TDM_RX_3",
  7194. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7195. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7196. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7197. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7198. SNDRV_PCM_FMTBIT_S24_LE |
  7199. SNDRV_PCM_FMTBIT_S32_LE,
  7200. .channels_min = 1,
  7201. .channels_max = 8,
  7202. .rate_min = 8000,
  7203. .rate_max = 352800,
  7204. },
  7205. .ops = &msm_dai_q6_tdm_ops,
  7206. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  7207. .probe = msm_dai_q6_dai_tdm_probe,
  7208. .remove = msm_dai_q6_dai_tdm_remove,
  7209. },
  7210. {
  7211. .playback = {
  7212. .stream_name = "Primary TDM4 Playback",
  7213. .aif_name = "PRI_TDM_RX_4",
  7214. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7215. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7216. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7217. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7218. SNDRV_PCM_FMTBIT_S24_LE |
  7219. SNDRV_PCM_FMTBIT_S32_LE,
  7220. .channels_min = 1,
  7221. .channels_max = 8,
  7222. .rate_min = 8000,
  7223. .rate_max = 352800,
  7224. },
  7225. .ops = &msm_dai_q6_tdm_ops,
  7226. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  7227. .probe = msm_dai_q6_dai_tdm_probe,
  7228. .remove = msm_dai_q6_dai_tdm_remove,
  7229. },
  7230. {
  7231. .playback = {
  7232. .stream_name = "Primary TDM5 Playback",
  7233. .aif_name = "PRI_TDM_RX_5",
  7234. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7235. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7236. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7237. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7238. SNDRV_PCM_FMTBIT_S24_LE |
  7239. SNDRV_PCM_FMTBIT_S32_LE,
  7240. .channels_min = 1,
  7241. .channels_max = 8,
  7242. .rate_min = 8000,
  7243. .rate_max = 352800,
  7244. },
  7245. .ops = &msm_dai_q6_tdm_ops,
  7246. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  7247. .probe = msm_dai_q6_dai_tdm_probe,
  7248. .remove = msm_dai_q6_dai_tdm_remove,
  7249. },
  7250. {
  7251. .playback = {
  7252. .stream_name = "Primary TDM6 Playback",
  7253. .aif_name = "PRI_TDM_RX_6",
  7254. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7255. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7256. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7257. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7258. SNDRV_PCM_FMTBIT_S24_LE |
  7259. SNDRV_PCM_FMTBIT_S32_LE,
  7260. .channels_min = 1,
  7261. .channels_max = 8,
  7262. .rate_min = 8000,
  7263. .rate_max = 352800,
  7264. },
  7265. .ops = &msm_dai_q6_tdm_ops,
  7266. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  7267. .probe = msm_dai_q6_dai_tdm_probe,
  7268. .remove = msm_dai_q6_dai_tdm_remove,
  7269. },
  7270. {
  7271. .playback = {
  7272. .stream_name = "Primary TDM7 Playback",
  7273. .aif_name = "PRI_TDM_RX_7",
  7274. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7275. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7276. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7277. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7278. SNDRV_PCM_FMTBIT_S24_LE |
  7279. SNDRV_PCM_FMTBIT_S32_LE,
  7280. .channels_min = 1,
  7281. .channels_max = 8,
  7282. .rate_min = 8000,
  7283. .rate_max = 352800,
  7284. },
  7285. .ops = &msm_dai_q6_tdm_ops,
  7286. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  7287. .probe = msm_dai_q6_dai_tdm_probe,
  7288. .remove = msm_dai_q6_dai_tdm_remove,
  7289. },
  7290. {
  7291. .capture = {
  7292. .stream_name = "Primary TDM0 Capture",
  7293. .aif_name = "PRI_TDM_TX_0",
  7294. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7295. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7296. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7297. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7298. SNDRV_PCM_FMTBIT_S24_LE |
  7299. SNDRV_PCM_FMTBIT_S32_LE,
  7300. .channels_min = 1,
  7301. .channels_max = 8,
  7302. .rate_min = 8000,
  7303. .rate_max = 352800,
  7304. },
  7305. .ops = &msm_dai_q6_tdm_ops,
  7306. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  7307. .probe = msm_dai_q6_dai_tdm_probe,
  7308. .remove = msm_dai_q6_dai_tdm_remove,
  7309. },
  7310. {
  7311. .capture = {
  7312. .stream_name = "Primary TDM1 Capture",
  7313. .aif_name = "PRI_TDM_TX_1",
  7314. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7315. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7316. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7317. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7318. SNDRV_PCM_FMTBIT_S24_LE |
  7319. SNDRV_PCM_FMTBIT_S32_LE,
  7320. .channels_min = 1,
  7321. .channels_max = 8,
  7322. .rate_min = 8000,
  7323. .rate_max = 352800,
  7324. },
  7325. .ops = &msm_dai_q6_tdm_ops,
  7326. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  7327. .probe = msm_dai_q6_dai_tdm_probe,
  7328. .remove = msm_dai_q6_dai_tdm_remove,
  7329. },
  7330. {
  7331. .capture = {
  7332. .stream_name = "Primary TDM2 Capture",
  7333. .aif_name = "PRI_TDM_TX_2",
  7334. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7335. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7336. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7337. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7338. SNDRV_PCM_FMTBIT_S24_LE |
  7339. SNDRV_PCM_FMTBIT_S32_LE,
  7340. .channels_min = 1,
  7341. .channels_max = 8,
  7342. .rate_min = 8000,
  7343. .rate_max = 352800,
  7344. },
  7345. .ops = &msm_dai_q6_tdm_ops,
  7346. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  7347. .probe = msm_dai_q6_dai_tdm_probe,
  7348. .remove = msm_dai_q6_dai_tdm_remove,
  7349. },
  7350. {
  7351. .capture = {
  7352. .stream_name = "Primary TDM3 Capture",
  7353. .aif_name = "PRI_TDM_TX_3",
  7354. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7355. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7356. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7357. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7358. SNDRV_PCM_FMTBIT_S24_LE |
  7359. SNDRV_PCM_FMTBIT_S32_LE,
  7360. .channels_min = 1,
  7361. .channels_max = 8,
  7362. .rate_min = 8000,
  7363. .rate_max = 352800,
  7364. },
  7365. .ops = &msm_dai_q6_tdm_ops,
  7366. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  7367. .probe = msm_dai_q6_dai_tdm_probe,
  7368. .remove = msm_dai_q6_dai_tdm_remove,
  7369. },
  7370. {
  7371. .capture = {
  7372. .stream_name = "Primary TDM4 Capture",
  7373. .aif_name = "PRI_TDM_TX_4",
  7374. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7375. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7376. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7377. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7378. SNDRV_PCM_FMTBIT_S24_LE |
  7379. SNDRV_PCM_FMTBIT_S32_LE,
  7380. .channels_min = 1,
  7381. .channels_max = 8,
  7382. .rate_min = 8000,
  7383. .rate_max = 352800,
  7384. },
  7385. .ops = &msm_dai_q6_tdm_ops,
  7386. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  7387. .probe = msm_dai_q6_dai_tdm_probe,
  7388. .remove = msm_dai_q6_dai_tdm_remove,
  7389. },
  7390. {
  7391. .capture = {
  7392. .stream_name = "Primary TDM5 Capture",
  7393. .aif_name = "PRI_TDM_TX_5",
  7394. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7395. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7396. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7397. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7398. SNDRV_PCM_FMTBIT_S24_LE |
  7399. SNDRV_PCM_FMTBIT_S32_LE,
  7400. .channels_min = 1,
  7401. .channels_max = 8,
  7402. .rate_min = 8000,
  7403. .rate_max = 352800,
  7404. },
  7405. .ops = &msm_dai_q6_tdm_ops,
  7406. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  7407. .probe = msm_dai_q6_dai_tdm_probe,
  7408. .remove = msm_dai_q6_dai_tdm_remove,
  7409. },
  7410. {
  7411. .capture = {
  7412. .stream_name = "Primary TDM6 Capture",
  7413. .aif_name = "PRI_TDM_TX_6",
  7414. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7415. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7416. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7417. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7418. SNDRV_PCM_FMTBIT_S24_LE |
  7419. SNDRV_PCM_FMTBIT_S32_LE,
  7420. .channels_min = 1,
  7421. .channels_max = 8,
  7422. .rate_min = 8000,
  7423. .rate_max = 352800,
  7424. },
  7425. .ops = &msm_dai_q6_tdm_ops,
  7426. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  7427. .probe = msm_dai_q6_dai_tdm_probe,
  7428. .remove = msm_dai_q6_dai_tdm_remove,
  7429. },
  7430. {
  7431. .capture = {
  7432. .stream_name = "Primary TDM7 Capture",
  7433. .aif_name = "PRI_TDM_TX_7",
  7434. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7435. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7436. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7437. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7438. SNDRV_PCM_FMTBIT_S24_LE |
  7439. SNDRV_PCM_FMTBIT_S32_LE,
  7440. .channels_min = 1,
  7441. .channels_max = 8,
  7442. .rate_min = 8000,
  7443. .rate_max = 352800,
  7444. },
  7445. .ops = &msm_dai_q6_tdm_ops,
  7446. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  7447. .probe = msm_dai_q6_dai_tdm_probe,
  7448. .remove = msm_dai_q6_dai_tdm_remove,
  7449. },
  7450. {
  7451. .playback = {
  7452. .stream_name = "Secondary TDM0 Playback",
  7453. .aif_name = "SEC_TDM_RX_0",
  7454. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7455. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7456. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7457. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7458. SNDRV_PCM_FMTBIT_S24_LE |
  7459. SNDRV_PCM_FMTBIT_S32_LE,
  7460. .channels_min = 1,
  7461. .channels_max = 8,
  7462. .rate_min = 8000,
  7463. .rate_max = 352800,
  7464. },
  7465. .ops = &msm_dai_q6_tdm_ops,
  7466. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  7467. .probe = msm_dai_q6_dai_tdm_probe,
  7468. .remove = msm_dai_q6_dai_tdm_remove,
  7469. },
  7470. {
  7471. .playback = {
  7472. .stream_name = "Secondary TDM1 Playback",
  7473. .aif_name = "SEC_TDM_RX_1",
  7474. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7475. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7476. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7477. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7478. SNDRV_PCM_FMTBIT_S24_LE |
  7479. SNDRV_PCM_FMTBIT_S32_LE,
  7480. .channels_min = 1,
  7481. .channels_max = 8,
  7482. .rate_min = 8000,
  7483. .rate_max = 352800,
  7484. },
  7485. .ops = &msm_dai_q6_tdm_ops,
  7486. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  7487. .probe = msm_dai_q6_dai_tdm_probe,
  7488. .remove = msm_dai_q6_dai_tdm_remove,
  7489. },
  7490. {
  7491. .playback = {
  7492. .stream_name = "Secondary TDM2 Playback",
  7493. .aif_name = "SEC_TDM_RX_2",
  7494. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7495. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7496. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7497. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7498. SNDRV_PCM_FMTBIT_S24_LE |
  7499. SNDRV_PCM_FMTBIT_S32_LE,
  7500. .channels_min = 1,
  7501. .channels_max = 8,
  7502. .rate_min = 8000,
  7503. .rate_max = 352800,
  7504. },
  7505. .ops = &msm_dai_q6_tdm_ops,
  7506. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  7507. .probe = msm_dai_q6_dai_tdm_probe,
  7508. .remove = msm_dai_q6_dai_tdm_remove,
  7509. },
  7510. {
  7511. .playback = {
  7512. .stream_name = "Secondary TDM3 Playback",
  7513. .aif_name = "SEC_TDM_RX_3",
  7514. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7515. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7516. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7517. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7518. SNDRV_PCM_FMTBIT_S24_LE |
  7519. SNDRV_PCM_FMTBIT_S32_LE,
  7520. .channels_min = 1,
  7521. .channels_max = 8,
  7522. .rate_min = 8000,
  7523. .rate_max = 352800,
  7524. },
  7525. .ops = &msm_dai_q6_tdm_ops,
  7526. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  7527. .probe = msm_dai_q6_dai_tdm_probe,
  7528. .remove = msm_dai_q6_dai_tdm_remove,
  7529. },
  7530. {
  7531. .playback = {
  7532. .stream_name = "Secondary TDM4 Playback",
  7533. .aif_name = "SEC_TDM_RX_4",
  7534. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7535. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7536. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7537. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7538. SNDRV_PCM_FMTBIT_S24_LE |
  7539. SNDRV_PCM_FMTBIT_S32_LE,
  7540. .channels_min = 1,
  7541. .channels_max = 8,
  7542. .rate_min = 8000,
  7543. .rate_max = 352800,
  7544. },
  7545. .ops = &msm_dai_q6_tdm_ops,
  7546. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  7547. .probe = msm_dai_q6_dai_tdm_probe,
  7548. .remove = msm_dai_q6_dai_tdm_remove,
  7549. },
  7550. {
  7551. .playback = {
  7552. .stream_name = "Secondary TDM5 Playback",
  7553. .aif_name = "SEC_TDM_RX_5",
  7554. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7555. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7556. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7557. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7558. SNDRV_PCM_FMTBIT_S24_LE |
  7559. SNDRV_PCM_FMTBIT_S32_LE,
  7560. .channels_min = 1,
  7561. .channels_max = 8,
  7562. .rate_min = 8000,
  7563. .rate_max = 352800,
  7564. },
  7565. .ops = &msm_dai_q6_tdm_ops,
  7566. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  7567. .probe = msm_dai_q6_dai_tdm_probe,
  7568. .remove = msm_dai_q6_dai_tdm_remove,
  7569. },
  7570. {
  7571. .playback = {
  7572. .stream_name = "Secondary TDM6 Playback",
  7573. .aif_name = "SEC_TDM_RX_6",
  7574. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7575. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7576. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7577. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7578. SNDRV_PCM_FMTBIT_S24_LE |
  7579. SNDRV_PCM_FMTBIT_S32_LE,
  7580. .channels_min = 1,
  7581. .channels_max = 8,
  7582. .rate_min = 8000,
  7583. .rate_max = 352800,
  7584. },
  7585. .ops = &msm_dai_q6_tdm_ops,
  7586. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  7587. .probe = msm_dai_q6_dai_tdm_probe,
  7588. .remove = msm_dai_q6_dai_tdm_remove,
  7589. },
  7590. {
  7591. .playback = {
  7592. .stream_name = "Secondary TDM7 Playback",
  7593. .aif_name = "SEC_TDM_RX_7",
  7594. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7595. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7596. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7597. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7598. SNDRV_PCM_FMTBIT_S24_LE |
  7599. SNDRV_PCM_FMTBIT_S32_LE,
  7600. .channels_min = 1,
  7601. .channels_max = 8,
  7602. .rate_min = 8000,
  7603. .rate_max = 352800,
  7604. },
  7605. .ops = &msm_dai_q6_tdm_ops,
  7606. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  7607. .probe = msm_dai_q6_dai_tdm_probe,
  7608. .remove = msm_dai_q6_dai_tdm_remove,
  7609. },
  7610. {
  7611. .capture = {
  7612. .stream_name = "Secondary TDM0 Capture",
  7613. .aif_name = "SEC_TDM_TX_0",
  7614. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7615. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7616. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7617. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7618. SNDRV_PCM_FMTBIT_S24_LE |
  7619. SNDRV_PCM_FMTBIT_S32_LE,
  7620. .channels_min = 1,
  7621. .channels_max = 8,
  7622. .rate_min = 8000,
  7623. .rate_max = 352800,
  7624. },
  7625. .ops = &msm_dai_q6_tdm_ops,
  7626. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  7627. .probe = msm_dai_q6_dai_tdm_probe,
  7628. .remove = msm_dai_q6_dai_tdm_remove,
  7629. },
  7630. {
  7631. .capture = {
  7632. .stream_name = "Secondary TDM1 Capture",
  7633. .aif_name = "SEC_TDM_TX_1",
  7634. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7635. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7636. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7637. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7638. SNDRV_PCM_FMTBIT_S24_LE |
  7639. SNDRV_PCM_FMTBIT_S32_LE,
  7640. .channels_min = 1,
  7641. .channels_max = 8,
  7642. .rate_min = 8000,
  7643. .rate_max = 352800,
  7644. },
  7645. .ops = &msm_dai_q6_tdm_ops,
  7646. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  7647. .probe = msm_dai_q6_dai_tdm_probe,
  7648. .remove = msm_dai_q6_dai_tdm_remove,
  7649. },
  7650. {
  7651. .capture = {
  7652. .stream_name = "Secondary TDM2 Capture",
  7653. .aif_name = "SEC_TDM_TX_2",
  7654. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7655. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7656. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7657. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7658. SNDRV_PCM_FMTBIT_S24_LE |
  7659. SNDRV_PCM_FMTBIT_S32_LE,
  7660. .channels_min = 1,
  7661. .channels_max = 8,
  7662. .rate_min = 8000,
  7663. .rate_max = 352800,
  7664. },
  7665. .ops = &msm_dai_q6_tdm_ops,
  7666. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  7667. .probe = msm_dai_q6_dai_tdm_probe,
  7668. .remove = msm_dai_q6_dai_tdm_remove,
  7669. },
  7670. {
  7671. .capture = {
  7672. .stream_name = "Secondary TDM3 Capture",
  7673. .aif_name = "SEC_TDM_TX_3",
  7674. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7675. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7676. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7677. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7678. SNDRV_PCM_FMTBIT_S24_LE |
  7679. SNDRV_PCM_FMTBIT_S32_LE,
  7680. .channels_min = 1,
  7681. .channels_max = 8,
  7682. .rate_min = 8000,
  7683. .rate_max = 352800,
  7684. },
  7685. .ops = &msm_dai_q6_tdm_ops,
  7686. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  7687. .probe = msm_dai_q6_dai_tdm_probe,
  7688. .remove = msm_dai_q6_dai_tdm_remove,
  7689. },
  7690. {
  7691. .capture = {
  7692. .stream_name = "Secondary TDM4 Capture",
  7693. .aif_name = "SEC_TDM_TX_4",
  7694. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7695. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7696. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7697. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7698. SNDRV_PCM_FMTBIT_S24_LE |
  7699. SNDRV_PCM_FMTBIT_S32_LE,
  7700. .channels_min = 1,
  7701. .channels_max = 8,
  7702. .rate_min = 8000,
  7703. .rate_max = 352800,
  7704. },
  7705. .ops = &msm_dai_q6_tdm_ops,
  7706. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  7707. .probe = msm_dai_q6_dai_tdm_probe,
  7708. .remove = msm_dai_q6_dai_tdm_remove,
  7709. },
  7710. {
  7711. .capture = {
  7712. .stream_name = "Secondary TDM5 Capture",
  7713. .aif_name = "SEC_TDM_TX_5",
  7714. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7715. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7716. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7717. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7718. SNDRV_PCM_FMTBIT_S24_LE |
  7719. SNDRV_PCM_FMTBIT_S32_LE,
  7720. .channels_min = 1,
  7721. .channels_max = 8,
  7722. .rate_min = 8000,
  7723. .rate_max = 352800,
  7724. },
  7725. .ops = &msm_dai_q6_tdm_ops,
  7726. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  7727. .probe = msm_dai_q6_dai_tdm_probe,
  7728. .remove = msm_dai_q6_dai_tdm_remove,
  7729. },
  7730. {
  7731. .capture = {
  7732. .stream_name = "Secondary TDM6 Capture",
  7733. .aif_name = "SEC_TDM_TX_6",
  7734. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7735. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7736. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7737. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7738. SNDRV_PCM_FMTBIT_S24_LE |
  7739. SNDRV_PCM_FMTBIT_S32_LE,
  7740. .channels_min = 1,
  7741. .channels_max = 8,
  7742. .rate_min = 8000,
  7743. .rate_max = 352800,
  7744. },
  7745. .ops = &msm_dai_q6_tdm_ops,
  7746. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  7747. .probe = msm_dai_q6_dai_tdm_probe,
  7748. .remove = msm_dai_q6_dai_tdm_remove,
  7749. },
  7750. {
  7751. .capture = {
  7752. .stream_name = "Secondary TDM7 Capture",
  7753. .aif_name = "SEC_TDM_TX_7",
  7754. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7755. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7756. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7757. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7758. SNDRV_PCM_FMTBIT_S24_LE |
  7759. SNDRV_PCM_FMTBIT_S32_LE,
  7760. .channels_min = 1,
  7761. .channels_max = 8,
  7762. .rate_min = 8000,
  7763. .rate_max = 352800,
  7764. },
  7765. .ops = &msm_dai_q6_tdm_ops,
  7766. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  7767. .probe = msm_dai_q6_dai_tdm_probe,
  7768. .remove = msm_dai_q6_dai_tdm_remove,
  7769. },
  7770. {
  7771. .playback = {
  7772. .stream_name = "Tertiary TDM0 Playback",
  7773. .aif_name = "TERT_TDM_RX_0",
  7774. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7775. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7776. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7777. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7778. SNDRV_PCM_FMTBIT_S24_LE |
  7779. SNDRV_PCM_FMTBIT_S32_LE,
  7780. .channels_min = 1,
  7781. .channels_max = 8,
  7782. .rate_min = 8000,
  7783. .rate_max = 352800,
  7784. },
  7785. .ops = &msm_dai_q6_tdm_ops,
  7786. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  7787. .probe = msm_dai_q6_dai_tdm_probe,
  7788. .remove = msm_dai_q6_dai_tdm_remove,
  7789. },
  7790. {
  7791. .playback = {
  7792. .stream_name = "Tertiary TDM1 Playback",
  7793. .aif_name = "TERT_TDM_RX_1",
  7794. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7795. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7796. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7797. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7798. SNDRV_PCM_FMTBIT_S24_LE |
  7799. SNDRV_PCM_FMTBIT_S32_LE,
  7800. .channels_min = 1,
  7801. .channels_max = 8,
  7802. .rate_min = 8000,
  7803. .rate_max = 352800,
  7804. },
  7805. .ops = &msm_dai_q6_tdm_ops,
  7806. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  7807. .probe = msm_dai_q6_dai_tdm_probe,
  7808. .remove = msm_dai_q6_dai_tdm_remove,
  7809. },
  7810. {
  7811. .playback = {
  7812. .stream_name = "Tertiary TDM2 Playback",
  7813. .aif_name = "TERT_TDM_RX_2",
  7814. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7815. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7816. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7817. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7818. SNDRV_PCM_FMTBIT_S24_LE |
  7819. SNDRV_PCM_FMTBIT_S32_LE,
  7820. .channels_min = 1,
  7821. .channels_max = 8,
  7822. .rate_min = 8000,
  7823. .rate_max = 352800,
  7824. },
  7825. .ops = &msm_dai_q6_tdm_ops,
  7826. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  7827. .probe = msm_dai_q6_dai_tdm_probe,
  7828. .remove = msm_dai_q6_dai_tdm_remove,
  7829. },
  7830. {
  7831. .playback = {
  7832. .stream_name = "Tertiary TDM3 Playback",
  7833. .aif_name = "TERT_TDM_RX_3",
  7834. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7835. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7836. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7837. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7838. SNDRV_PCM_FMTBIT_S24_LE |
  7839. SNDRV_PCM_FMTBIT_S32_LE,
  7840. .channels_min = 1,
  7841. .channels_max = 8,
  7842. .rate_min = 8000,
  7843. .rate_max = 352800,
  7844. },
  7845. .ops = &msm_dai_q6_tdm_ops,
  7846. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  7847. .probe = msm_dai_q6_dai_tdm_probe,
  7848. .remove = msm_dai_q6_dai_tdm_remove,
  7849. },
  7850. {
  7851. .playback = {
  7852. .stream_name = "Tertiary TDM4 Playback",
  7853. .aif_name = "TERT_TDM_RX_4",
  7854. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7855. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7856. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7857. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7858. SNDRV_PCM_FMTBIT_S24_LE |
  7859. SNDRV_PCM_FMTBIT_S32_LE,
  7860. .channels_min = 1,
  7861. .channels_max = 8,
  7862. .rate_min = 8000,
  7863. .rate_max = 352800,
  7864. },
  7865. .ops = &msm_dai_q6_tdm_ops,
  7866. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  7867. .probe = msm_dai_q6_dai_tdm_probe,
  7868. .remove = msm_dai_q6_dai_tdm_remove,
  7869. },
  7870. {
  7871. .playback = {
  7872. .stream_name = "Tertiary TDM5 Playback",
  7873. .aif_name = "TERT_TDM_RX_5",
  7874. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7875. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7876. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7877. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7878. SNDRV_PCM_FMTBIT_S24_LE |
  7879. SNDRV_PCM_FMTBIT_S32_LE,
  7880. .channels_min = 1,
  7881. .channels_max = 8,
  7882. .rate_min = 8000,
  7883. .rate_max = 352800,
  7884. },
  7885. .ops = &msm_dai_q6_tdm_ops,
  7886. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  7887. .probe = msm_dai_q6_dai_tdm_probe,
  7888. .remove = msm_dai_q6_dai_tdm_remove,
  7889. },
  7890. {
  7891. .playback = {
  7892. .stream_name = "Tertiary TDM6 Playback",
  7893. .aif_name = "TERT_TDM_RX_6",
  7894. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7895. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7896. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7897. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7898. SNDRV_PCM_FMTBIT_S24_LE |
  7899. SNDRV_PCM_FMTBIT_S32_LE,
  7900. .channels_min = 1,
  7901. .channels_max = 8,
  7902. .rate_min = 8000,
  7903. .rate_max = 352800,
  7904. },
  7905. .ops = &msm_dai_q6_tdm_ops,
  7906. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  7907. .probe = msm_dai_q6_dai_tdm_probe,
  7908. .remove = msm_dai_q6_dai_tdm_remove,
  7909. },
  7910. {
  7911. .playback = {
  7912. .stream_name = "Tertiary TDM7 Playback",
  7913. .aif_name = "TERT_TDM_RX_7",
  7914. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7915. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7916. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7917. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7918. SNDRV_PCM_FMTBIT_S24_LE |
  7919. SNDRV_PCM_FMTBIT_S32_LE,
  7920. .channels_min = 1,
  7921. .channels_max = 8,
  7922. .rate_min = 8000,
  7923. .rate_max = 352800,
  7924. },
  7925. .ops = &msm_dai_q6_tdm_ops,
  7926. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  7927. .probe = msm_dai_q6_dai_tdm_probe,
  7928. .remove = msm_dai_q6_dai_tdm_remove,
  7929. },
  7930. {
  7931. .capture = {
  7932. .stream_name = "Tertiary TDM0 Capture",
  7933. .aif_name = "TERT_TDM_TX_0",
  7934. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7935. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7936. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7937. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7938. SNDRV_PCM_FMTBIT_S24_LE |
  7939. SNDRV_PCM_FMTBIT_S32_LE,
  7940. .channels_min = 1,
  7941. .channels_max = 8,
  7942. .rate_min = 8000,
  7943. .rate_max = 352800,
  7944. },
  7945. .ops = &msm_dai_q6_tdm_ops,
  7946. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  7947. .probe = msm_dai_q6_dai_tdm_probe,
  7948. .remove = msm_dai_q6_dai_tdm_remove,
  7949. },
  7950. {
  7951. .capture = {
  7952. .stream_name = "Tertiary TDM1 Capture",
  7953. .aif_name = "TERT_TDM_TX_1",
  7954. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7955. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7956. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7957. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7958. SNDRV_PCM_FMTBIT_S24_LE |
  7959. SNDRV_PCM_FMTBIT_S32_LE,
  7960. .channels_min = 1,
  7961. .channels_max = 8,
  7962. .rate_min = 8000,
  7963. .rate_max = 352800,
  7964. },
  7965. .ops = &msm_dai_q6_tdm_ops,
  7966. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  7967. .probe = msm_dai_q6_dai_tdm_probe,
  7968. .remove = msm_dai_q6_dai_tdm_remove,
  7969. },
  7970. {
  7971. .capture = {
  7972. .stream_name = "Tertiary TDM2 Capture",
  7973. .aif_name = "TERT_TDM_TX_2",
  7974. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7975. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7976. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7977. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7978. SNDRV_PCM_FMTBIT_S24_LE |
  7979. SNDRV_PCM_FMTBIT_S32_LE,
  7980. .channels_min = 1,
  7981. .channels_max = 8,
  7982. .rate_min = 8000,
  7983. .rate_max = 352800,
  7984. },
  7985. .ops = &msm_dai_q6_tdm_ops,
  7986. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  7987. .probe = msm_dai_q6_dai_tdm_probe,
  7988. .remove = msm_dai_q6_dai_tdm_remove,
  7989. },
  7990. {
  7991. .capture = {
  7992. .stream_name = "Tertiary TDM3 Capture",
  7993. .aif_name = "TERT_TDM_TX_3",
  7994. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7995. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7996. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7997. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7998. SNDRV_PCM_FMTBIT_S24_LE |
  7999. SNDRV_PCM_FMTBIT_S32_LE,
  8000. .channels_min = 1,
  8001. .channels_max = 8,
  8002. .rate_min = 8000,
  8003. .rate_max = 352800,
  8004. },
  8005. .ops = &msm_dai_q6_tdm_ops,
  8006. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  8007. .probe = msm_dai_q6_dai_tdm_probe,
  8008. .remove = msm_dai_q6_dai_tdm_remove,
  8009. },
  8010. {
  8011. .capture = {
  8012. .stream_name = "Tertiary TDM4 Capture",
  8013. .aif_name = "TERT_TDM_TX_4",
  8014. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8015. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8016. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8017. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8018. SNDRV_PCM_FMTBIT_S24_LE |
  8019. SNDRV_PCM_FMTBIT_S32_LE,
  8020. .channels_min = 1,
  8021. .channels_max = 8,
  8022. .rate_min = 8000,
  8023. .rate_max = 352800,
  8024. },
  8025. .ops = &msm_dai_q6_tdm_ops,
  8026. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  8027. .probe = msm_dai_q6_dai_tdm_probe,
  8028. .remove = msm_dai_q6_dai_tdm_remove,
  8029. },
  8030. {
  8031. .capture = {
  8032. .stream_name = "Tertiary TDM5 Capture",
  8033. .aif_name = "TERT_TDM_TX_5",
  8034. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8035. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8036. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8037. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8038. SNDRV_PCM_FMTBIT_S24_LE |
  8039. SNDRV_PCM_FMTBIT_S32_LE,
  8040. .channels_min = 1,
  8041. .channels_max = 8,
  8042. .rate_min = 8000,
  8043. .rate_max = 352800,
  8044. },
  8045. .ops = &msm_dai_q6_tdm_ops,
  8046. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  8047. .probe = msm_dai_q6_dai_tdm_probe,
  8048. .remove = msm_dai_q6_dai_tdm_remove,
  8049. },
  8050. {
  8051. .capture = {
  8052. .stream_name = "Tertiary TDM6 Capture",
  8053. .aif_name = "TERT_TDM_TX_6",
  8054. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8055. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8056. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8057. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8058. SNDRV_PCM_FMTBIT_S24_LE |
  8059. SNDRV_PCM_FMTBIT_S32_LE,
  8060. .channels_min = 1,
  8061. .channels_max = 8,
  8062. .rate_min = 8000,
  8063. .rate_max = 352800,
  8064. },
  8065. .ops = &msm_dai_q6_tdm_ops,
  8066. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  8067. .probe = msm_dai_q6_dai_tdm_probe,
  8068. .remove = msm_dai_q6_dai_tdm_remove,
  8069. },
  8070. {
  8071. .capture = {
  8072. .stream_name = "Tertiary TDM7 Capture",
  8073. .aif_name = "TERT_TDM_TX_7",
  8074. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8075. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8076. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8077. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8078. SNDRV_PCM_FMTBIT_S24_LE |
  8079. SNDRV_PCM_FMTBIT_S32_LE,
  8080. .channels_min = 1,
  8081. .channels_max = 8,
  8082. .rate_min = 8000,
  8083. .rate_max = 352800,
  8084. },
  8085. .ops = &msm_dai_q6_tdm_ops,
  8086. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  8087. .probe = msm_dai_q6_dai_tdm_probe,
  8088. .remove = msm_dai_q6_dai_tdm_remove,
  8089. },
  8090. {
  8091. .playback = {
  8092. .stream_name = "Quaternary TDM0 Playback",
  8093. .aif_name = "QUAT_TDM_RX_0",
  8094. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8095. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8096. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8097. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8098. SNDRV_PCM_FMTBIT_S24_LE |
  8099. SNDRV_PCM_FMTBIT_S32_LE,
  8100. .channels_min = 1,
  8101. .channels_max = 8,
  8102. .rate_min = 8000,
  8103. .rate_max = 352800,
  8104. },
  8105. .ops = &msm_dai_q6_tdm_ops,
  8106. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  8107. .probe = msm_dai_q6_dai_tdm_probe,
  8108. .remove = msm_dai_q6_dai_tdm_remove,
  8109. },
  8110. {
  8111. .playback = {
  8112. .stream_name = "Quaternary TDM1 Playback",
  8113. .aif_name = "QUAT_TDM_RX_1",
  8114. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8115. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8116. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8117. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8118. SNDRV_PCM_FMTBIT_S24_LE |
  8119. SNDRV_PCM_FMTBIT_S32_LE,
  8120. .channels_min = 1,
  8121. .channels_max = 8,
  8122. .rate_min = 8000,
  8123. .rate_max = 352800,
  8124. },
  8125. .ops = &msm_dai_q6_tdm_ops,
  8126. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  8127. .probe = msm_dai_q6_dai_tdm_probe,
  8128. .remove = msm_dai_q6_dai_tdm_remove,
  8129. },
  8130. {
  8131. .playback = {
  8132. .stream_name = "Quaternary TDM2 Playback",
  8133. .aif_name = "QUAT_TDM_RX_2",
  8134. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8135. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8136. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8137. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8138. SNDRV_PCM_FMTBIT_S24_LE |
  8139. SNDRV_PCM_FMTBIT_S32_LE,
  8140. .channels_min = 1,
  8141. .channels_max = 8,
  8142. .rate_min = 8000,
  8143. .rate_max = 352800,
  8144. },
  8145. .ops = &msm_dai_q6_tdm_ops,
  8146. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  8147. .probe = msm_dai_q6_dai_tdm_probe,
  8148. .remove = msm_dai_q6_dai_tdm_remove,
  8149. },
  8150. {
  8151. .playback = {
  8152. .stream_name = "Quaternary TDM3 Playback",
  8153. .aif_name = "QUAT_TDM_RX_3",
  8154. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8155. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8156. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8157. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8158. SNDRV_PCM_FMTBIT_S24_LE |
  8159. SNDRV_PCM_FMTBIT_S32_LE,
  8160. .channels_min = 1,
  8161. .channels_max = 8,
  8162. .rate_min = 8000,
  8163. .rate_max = 352800,
  8164. },
  8165. .ops = &msm_dai_q6_tdm_ops,
  8166. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  8167. .probe = msm_dai_q6_dai_tdm_probe,
  8168. .remove = msm_dai_q6_dai_tdm_remove,
  8169. },
  8170. {
  8171. .playback = {
  8172. .stream_name = "Quaternary TDM4 Playback",
  8173. .aif_name = "QUAT_TDM_RX_4",
  8174. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8175. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8176. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8177. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8178. SNDRV_PCM_FMTBIT_S24_LE |
  8179. SNDRV_PCM_FMTBIT_S32_LE,
  8180. .channels_min = 1,
  8181. .channels_max = 8,
  8182. .rate_min = 8000,
  8183. .rate_max = 352800,
  8184. },
  8185. .ops = &msm_dai_q6_tdm_ops,
  8186. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  8187. .probe = msm_dai_q6_dai_tdm_probe,
  8188. .remove = msm_dai_q6_dai_tdm_remove,
  8189. },
  8190. {
  8191. .playback = {
  8192. .stream_name = "Quaternary TDM5 Playback",
  8193. .aif_name = "QUAT_TDM_RX_5",
  8194. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8195. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8196. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8197. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8198. SNDRV_PCM_FMTBIT_S24_LE |
  8199. SNDRV_PCM_FMTBIT_S32_LE,
  8200. .channels_min = 1,
  8201. .channels_max = 8,
  8202. .rate_min = 8000,
  8203. .rate_max = 352800,
  8204. },
  8205. .ops = &msm_dai_q6_tdm_ops,
  8206. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  8207. .probe = msm_dai_q6_dai_tdm_probe,
  8208. .remove = msm_dai_q6_dai_tdm_remove,
  8209. },
  8210. {
  8211. .playback = {
  8212. .stream_name = "Quaternary TDM6 Playback",
  8213. .aif_name = "QUAT_TDM_RX_6",
  8214. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8215. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8216. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8217. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8218. SNDRV_PCM_FMTBIT_S24_LE |
  8219. SNDRV_PCM_FMTBIT_S32_LE,
  8220. .channels_min = 1,
  8221. .channels_max = 8,
  8222. .rate_min = 8000,
  8223. .rate_max = 352800,
  8224. },
  8225. .ops = &msm_dai_q6_tdm_ops,
  8226. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  8227. .probe = msm_dai_q6_dai_tdm_probe,
  8228. .remove = msm_dai_q6_dai_tdm_remove,
  8229. },
  8230. {
  8231. .playback = {
  8232. .stream_name = "Quaternary TDM7 Playback",
  8233. .aif_name = "QUAT_TDM_RX_7",
  8234. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8235. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8236. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8237. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8238. SNDRV_PCM_FMTBIT_S24_LE |
  8239. SNDRV_PCM_FMTBIT_S32_LE,
  8240. .channels_min = 1,
  8241. .channels_max = 8,
  8242. .rate_min = 8000,
  8243. .rate_max = 352800,
  8244. },
  8245. .ops = &msm_dai_q6_tdm_ops,
  8246. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  8247. .probe = msm_dai_q6_dai_tdm_probe,
  8248. .remove = msm_dai_q6_dai_tdm_remove,
  8249. },
  8250. {
  8251. .capture = {
  8252. .stream_name = "Quaternary TDM0 Capture",
  8253. .aif_name = "QUAT_TDM_TX_0",
  8254. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8255. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8256. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8257. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8258. SNDRV_PCM_FMTBIT_S24_LE |
  8259. SNDRV_PCM_FMTBIT_S32_LE,
  8260. .channels_min = 1,
  8261. .channels_max = 8,
  8262. .rate_min = 8000,
  8263. .rate_max = 352800,
  8264. },
  8265. .ops = &msm_dai_q6_tdm_ops,
  8266. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  8267. .probe = msm_dai_q6_dai_tdm_probe,
  8268. .remove = msm_dai_q6_dai_tdm_remove,
  8269. },
  8270. {
  8271. .capture = {
  8272. .stream_name = "Quaternary TDM1 Capture",
  8273. .aif_name = "QUAT_TDM_TX_1",
  8274. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8275. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8276. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8277. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8278. SNDRV_PCM_FMTBIT_S24_LE |
  8279. SNDRV_PCM_FMTBIT_S32_LE,
  8280. .channels_min = 1,
  8281. .channels_max = 8,
  8282. .rate_min = 8000,
  8283. .rate_max = 352800,
  8284. },
  8285. .ops = &msm_dai_q6_tdm_ops,
  8286. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  8287. .probe = msm_dai_q6_dai_tdm_probe,
  8288. .remove = msm_dai_q6_dai_tdm_remove,
  8289. },
  8290. {
  8291. .capture = {
  8292. .stream_name = "Quaternary TDM2 Capture",
  8293. .aif_name = "QUAT_TDM_TX_2",
  8294. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8295. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8296. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8297. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8298. SNDRV_PCM_FMTBIT_S24_LE |
  8299. SNDRV_PCM_FMTBIT_S32_LE,
  8300. .channels_min = 1,
  8301. .channels_max = 8,
  8302. .rate_min = 8000,
  8303. .rate_max = 352800,
  8304. },
  8305. .ops = &msm_dai_q6_tdm_ops,
  8306. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  8307. .probe = msm_dai_q6_dai_tdm_probe,
  8308. .remove = msm_dai_q6_dai_tdm_remove,
  8309. },
  8310. {
  8311. .capture = {
  8312. .stream_name = "Quaternary TDM3 Capture",
  8313. .aif_name = "QUAT_TDM_TX_3",
  8314. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8315. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8316. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8317. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8318. SNDRV_PCM_FMTBIT_S24_LE |
  8319. SNDRV_PCM_FMTBIT_S32_LE,
  8320. .channels_min = 1,
  8321. .channels_max = 8,
  8322. .rate_min = 8000,
  8323. .rate_max = 352800,
  8324. },
  8325. .ops = &msm_dai_q6_tdm_ops,
  8326. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  8327. .probe = msm_dai_q6_dai_tdm_probe,
  8328. .remove = msm_dai_q6_dai_tdm_remove,
  8329. },
  8330. {
  8331. .capture = {
  8332. .stream_name = "Quaternary TDM4 Capture",
  8333. .aif_name = "QUAT_TDM_TX_4",
  8334. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8335. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8336. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8337. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8338. SNDRV_PCM_FMTBIT_S24_LE |
  8339. SNDRV_PCM_FMTBIT_S32_LE,
  8340. .channels_min = 1,
  8341. .channels_max = 8,
  8342. .rate_min = 8000,
  8343. .rate_max = 352800,
  8344. },
  8345. .ops = &msm_dai_q6_tdm_ops,
  8346. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  8347. .probe = msm_dai_q6_dai_tdm_probe,
  8348. .remove = msm_dai_q6_dai_tdm_remove,
  8349. },
  8350. {
  8351. .capture = {
  8352. .stream_name = "Quaternary TDM5 Capture",
  8353. .aif_name = "QUAT_TDM_TX_5",
  8354. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8355. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8356. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8357. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8358. SNDRV_PCM_FMTBIT_S24_LE |
  8359. SNDRV_PCM_FMTBIT_S32_LE,
  8360. .channels_min = 1,
  8361. .channels_max = 8,
  8362. .rate_min = 8000,
  8363. .rate_max = 352800,
  8364. },
  8365. .ops = &msm_dai_q6_tdm_ops,
  8366. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  8367. .probe = msm_dai_q6_dai_tdm_probe,
  8368. .remove = msm_dai_q6_dai_tdm_remove,
  8369. },
  8370. {
  8371. .capture = {
  8372. .stream_name = "Quaternary TDM6 Capture",
  8373. .aif_name = "QUAT_TDM_TX_6",
  8374. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8375. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8376. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8377. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8378. SNDRV_PCM_FMTBIT_S24_LE |
  8379. SNDRV_PCM_FMTBIT_S32_LE,
  8380. .channels_min = 1,
  8381. .channels_max = 8,
  8382. .rate_min = 8000,
  8383. .rate_max = 352800,
  8384. },
  8385. .ops = &msm_dai_q6_tdm_ops,
  8386. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  8387. .probe = msm_dai_q6_dai_tdm_probe,
  8388. .remove = msm_dai_q6_dai_tdm_remove,
  8389. },
  8390. {
  8391. .capture = {
  8392. .stream_name = "Quaternary TDM7 Capture",
  8393. .aif_name = "QUAT_TDM_TX_7",
  8394. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8395. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8396. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8397. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8398. SNDRV_PCM_FMTBIT_S24_LE |
  8399. SNDRV_PCM_FMTBIT_S32_LE,
  8400. .channels_min = 1,
  8401. .channels_max = 8,
  8402. .rate_min = 8000,
  8403. .rate_max = 352800,
  8404. },
  8405. .ops = &msm_dai_q6_tdm_ops,
  8406. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  8407. .probe = msm_dai_q6_dai_tdm_probe,
  8408. .remove = msm_dai_q6_dai_tdm_remove,
  8409. },
  8410. {
  8411. .playback = {
  8412. .stream_name = "Quinary TDM0 Playback",
  8413. .aif_name = "QUIN_TDM_RX_0",
  8414. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8415. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8416. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8417. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8418. SNDRV_PCM_FMTBIT_S24_LE |
  8419. SNDRV_PCM_FMTBIT_S32_LE,
  8420. .channels_min = 1,
  8421. .channels_max = 8,
  8422. .rate_min = 8000,
  8423. .rate_max = 352800,
  8424. },
  8425. .ops = &msm_dai_q6_tdm_ops,
  8426. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  8427. .probe = msm_dai_q6_dai_tdm_probe,
  8428. .remove = msm_dai_q6_dai_tdm_remove,
  8429. },
  8430. {
  8431. .playback = {
  8432. .stream_name = "Quinary TDM1 Playback",
  8433. .aif_name = "QUIN_TDM_RX_1",
  8434. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8435. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8436. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8437. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8438. SNDRV_PCM_FMTBIT_S24_LE |
  8439. SNDRV_PCM_FMTBIT_S32_LE,
  8440. .channels_min = 1,
  8441. .channels_max = 8,
  8442. .rate_min = 8000,
  8443. .rate_max = 352800,
  8444. },
  8445. .ops = &msm_dai_q6_tdm_ops,
  8446. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  8447. .probe = msm_dai_q6_dai_tdm_probe,
  8448. .remove = msm_dai_q6_dai_tdm_remove,
  8449. },
  8450. {
  8451. .playback = {
  8452. .stream_name = "Quinary TDM2 Playback",
  8453. .aif_name = "QUIN_TDM_RX_2",
  8454. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8455. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8456. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8457. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8458. SNDRV_PCM_FMTBIT_S24_LE |
  8459. SNDRV_PCM_FMTBIT_S32_LE,
  8460. .channels_min = 1,
  8461. .channels_max = 8,
  8462. .rate_min = 8000,
  8463. .rate_max = 352800,
  8464. },
  8465. .ops = &msm_dai_q6_tdm_ops,
  8466. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  8467. .probe = msm_dai_q6_dai_tdm_probe,
  8468. .remove = msm_dai_q6_dai_tdm_remove,
  8469. },
  8470. {
  8471. .playback = {
  8472. .stream_name = "Quinary TDM3 Playback",
  8473. .aif_name = "QUIN_TDM_RX_3",
  8474. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8475. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8476. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8477. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8478. SNDRV_PCM_FMTBIT_S24_LE |
  8479. SNDRV_PCM_FMTBIT_S32_LE,
  8480. .channels_min = 1,
  8481. .channels_max = 8,
  8482. .rate_min = 8000,
  8483. .rate_max = 352800,
  8484. },
  8485. .ops = &msm_dai_q6_tdm_ops,
  8486. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  8487. .probe = msm_dai_q6_dai_tdm_probe,
  8488. .remove = msm_dai_q6_dai_tdm_remove,
  8489. },
  8490. {
  8491. .playback = {
  8492. .stream_name = "Quinary TDM4 Playback",
  8493. .aif_name = "QUIN_TDM_RX_4",
  8494. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8495. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8496. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8497. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8498. SNDRV_PCM_FMTBIT_S24_LE |
  8499. SNDRV_PCM_FMTBIT_S32_LE,
  8500. .channels_min = 1,
  8501. .channels_max = 8,
  8502. .rate_min = 8000,
  8503. .rate_max = 352800,
  8504. },
  8505. .ops = &msm_dai_q6_tdm_ops,
  8506. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  8507. .probe = msm_dai_q6_dai_tdm_probe,
  8508. .remove = msm_dai_q6_dai_tdm_remove,
  8509. },
  8510. {
  8511. .playback = {
  8512. .stream_name = "Quinary TDM5 Playback",
  8513. .aif_name = "QUIN_TDM_RX_5",
  8514. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8515. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8516. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8517. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8518. SNDRV_PCM_FMTBIT_S24_LE |
  8519. SNDRV_PCM_FMTBIT_S32_LE,
  8520. .channels_min = 1,
  8521. .channels_max = 8,
  8522. .rate_min = 8000,
  8523. .rate_max = 352800,
  8524. },
  8525. .ops = &msm_dai_q6_tdm_ops,
  8526. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  8527. .probe = msm_dai_q6_dai_tdm_probe,
  8528. .remove = msm_dai_q6_dai_tdm_remove,
  8529. },
  8530. {
  8531. .playback = {
  8532. .stream_name = "Quinary TDM6 Playback",
  8533. .aif_name = "QUIN_TDM_RX_6",
  8534. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8535. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8536. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8537. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8538. SNDRV_PCM_FMTBIT_S24_LE |
  8539. SNDRV_PCM_FMTBIT_S32_LE,
  8540. .channels_min = 1,
  8541. .channels_max = 8,
  8542. .rate_min = 8000,
  8543. .rate_max = 352800,
  8544. },
  8545. .ops = &msm_dai_q6_tdm_ops,
  8546. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  8547. .probe = msm_dai_q6_dai_tdm_probe,
  8548. .remove = msm_dai_q6_dai_tdm_remove,
  8549. },
  8550. {
  8551. .playback = {
  8552. .stream_name = "Quinary TDM7 Playback",
  8553. .aif_name = "QUIN_TDM_RX_7",
  8554. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8555. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8556. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8557. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8558. SNDRV_PCM_FMTBIT_S24_LE |
  8559. SNDRV_PCM_FMTBIT_S32_LE,
  8560. .channels_min = 1,
  8561. .channels_max = 8,
  8562. .rate_min = 8000,
  8563. .rate_max = 352800,
  8564. },
  8565. .ops = &msm_dai_q6_tdm_ops,
  8566. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  8567. .probe = msm_dai_q6_dai_tdm_probe,
  8568. .remove = msm_dai_q6_dai_tdm_remove,
  8569. },
  8570. {
  8571. .capture = {
  8572. .stream_name = "Quinary TDM0 Capture",
  8573. .aif_name = "QUIN_TDM_TX_0",
  8574. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8575. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8576. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8577. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8578. SNDRV_PCM_FMTBIT_S24_LE |
  8579. SNDRV_PCM_FMTBIT_S32_LE,
  8580. .channels_min = 1,
  8581. .channels_max = 8,
  8582. .rate_min = 8000,
  8583. .rate_max = 352800,
  8584. },
  8585. .ops = &msm_dai_q6_tdm_ops,
  8586. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  8587. .probe = msm_dai_q6_dai_tdm_probe,
  8588. .remove = msm_dai_q6_dai_tdm_remove,
  8589. },
  8590. {
  8591. .capture = {
  8592. .stream_name = "Quinary TDM1 Capture",
  8593. .aif_name = "QUIN_TDM_TX_1",
  8594. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8595. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8596. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8597. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8598. SNDRV_PCM_FMTBIT_S24_LE |
  8599. SNDRV_PCM_FMTBIT_S32_LE,
  8600. .channels_min = 1,
  8601. .channels_max = 8,
  8602. .rate_min = 8000,
  8603. .rate_max = 352800,
  8604. },
  8605. .ops = &msm_dai_q6_tdm_ops,
  8606. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  8607. .probe = msm_dai_q6_dai_tdm_probe,
  8608. .remove = msm_dai_q6_dai_tdm_remove,
  8609. },
  8610. {
  8611. .capture = {
  8612. .stream_name = "Quinary TDM2 Capture",
  8613. .aif_name = "QUIN_TDM_TX_2",
  8614. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8615. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8616. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8617. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8618. SNDRV_PCM_FMTBIT_S24_LE |
  8619. SNDRV_PCM_FMTBIT_S32_LE,
  8620. .channels_min = 1,
  8621. .channels_max = 8,
  8622. .rate_min = 8000,
  8623. .rate_max = 352800,
  8624. },
  8625. .ops = &msm_dai_q6_tdm_ops,
  8626. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  8627. .probe = msm_dai_q6_dai_tdm_probe,
  8628. .remove = msm_dai_q6_dai_tdm_remove,
  8629. },
  8630. {
  8631. .capture = {
  8632. .stream_name = "Quinary TDM3 Capture",
  8633. .aif_name = "QUIN_TDM_TX_3",
  8634. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8635. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8636. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8637. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8638. SNDRV_PCM_FMTBIT_S24_LE |
  8639. SNDRV_PCM_FMTBIT_S32_LE,
  8640. .channels_min = 1,
  8641. .channels_max = 8,
  8642. .rate_min = 8000,
  8643. .rate_max = 352800,
  8644. },
  8645. .ops = &msm_dai_q6_tdm_ops,
  8646. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  8647. .probe = msm_dai_q6_dai_tdm_probe,
  8648. .remove = msm_dai_q6_dai_tdm_remove,
  8649. },
  8650. {
  8651. .capture = {
  8652. .stream_name = "Quinary TDM4 Capture",
  8653. .aif_name = "QUIN_TDM_TX_4",
  8654. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8655. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8656. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8657. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8658. SNDRV_PCM_FMTBIT_S24_LE |
  8659. SNDRV_PCM_FMTBIT_S32_LE,
  8660. .channels_min = 1,
  8661. .channels_max = 8,
  8662. .rate_min = 8000,
  8663. .rate_max = 352800,
  8664. },
  8665. .ops = &msm_dai_q6_tdm_ops,
  8666. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  8667. .probe = msm_dai_q6_dai_tdm_probe,
  8668. .remove = msm_dai_q6_dai_tdm_remove,
  8669. },
  8670. {
  8671. .capture = {
  8672. .stream_name = "Quinary TDM5 Capture",
  8673. .aif_name = "QUIN_TDM_TX_5",
  8674. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8675. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8676. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8677. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8678. SNDRV_PCM_FMTBIT_S24_LE |
  8679. SNDRV_PCM_FMTBIT_S32_LE,
  8680. .channels_min = 1,
  8681. .channels_max = 8,
  8682. .rate_min = 8000,
  8683. .rate_max = 352800,
  8684. },
  8685. .ops = &msm_dai_q6_tdm_ops,
  8686. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  8687. .probe = msm_dai_q6_dai_tdm_probe,
  8688. .remove = msm_dai_q6_dai_tdm_remove,
  8689. },
  8690. {
  8691. .capture = {
  8692. .stream_name = "Quinary TDM6 Capture",
  8693. .aif_name = "QUIN_TDM_TX_6",
  8694. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8695. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8696. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8697. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8698. SNDRV_PCM_FMTBIT_S24_LE |
  8699. SNDRV_PCM_FMTBIT_S32_LE,
  8700. .channels_min = 1,
  8701. .channels_max = 8,
  8702. .rate_min = 8000,
  8703. .rate_max = 352800,
  8704. },
  8705. .ops = &msm_dai_q6_tdm_ops,
  8706. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  8707. .probe = msm_dai_q6_dai_tdm_probe,
  8708. .remove = msm_dai_q6_dai_tdm_remove,
  8709. },
  8710. {
  8711. .capture = {
  8712. .stream_name = "Quinary TDM7 Capture",
  8713. .aif_name = "QUIN_TDM_TX_7",
  8714. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8715. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8716. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8717. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8718. SNDRV_PCM_FMTBIT_S24_LE |
  8719. SNDRV_PCM_FMTBIT_S32_LE,
  8720. .channels_min = 1,
  8721. .channels_max = 8,
  8722. .rate_min = 8000,
  8723. .rate_max = 352800,
  8724. },
  8725. .ops = &msm_dai_q6_tdm_ops,
  8726. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  8727. .probe = msm_dai_q6_dai_tdm_probe,
  8728. .remove = msm_dai_q6_dai_tdm_remove,
  8729. },
  8730. };
  8731. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  8732. .name = "msm-dai-q6-tdm",
  8733. };
  8734. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  8735. {
  8736. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  8737. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  8738. int rc = 0;
  8739. u32 tdm_dev_id = 0;
  8740. int port_idx = 0;
  8741. struct device_node *tdm_parent_node = NULL;
  8742. /* retrieve device/afe id */
  8743. rc = of_property_read_u32(pdev->dev.of_node,
  8744. "qcom,msm-cpudai-tdm-dev-id",
  8745. &tdm_dev_id);
  8746. if (rc) {
  8747. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  8748. __func__);
  8749. goto rtn;
  8750. }
  8751. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  8752. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  8753. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  8754. __func__, tdm_dev_id);
  8755. rc = -ENXIO;
  8756. goto rtn;
  8757. }
  8758. pdev->id = tdm_dev_id;
  8759. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  8760. GFP_KERNEL);
  8761. if (!dai_data) {
  8762. rc = -ENOMEM;
  8763. dev_err(&pdev->dev,
  8764. "%s Failed to allocate memory for tdm dai_data\n",
  8765. __func__);
  8766. goto rtn;
  8767. }
  8768. memset(dai_data, 0, sizeof(*dai_data));
  8769. rc = of_property_read_u32(pdev->dev.of_node,
  8770. "qcom,msm-dai-is-island-supported",
  8771. &dai_data->is_island_dai);
  8772. if (rc)
  8773. dev_dbg(&pdev->dev, "island supported entry not found\n");
  8774. /* TDM CFG */
  8775. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  8776. rc = of_property_read_u32(tdm_parent_node,
  8777. "qcom,msm-cpudai-tdm-sync-mode",
  8778. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  8779. if (rc) {
  8780. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  8781. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  8782. goto free_dai_data;
  8783. }
  8784. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  8785. __func__, dai_data->port_cfg.tdm.sync_mode);
  8786. rc = of_property_read_u32(tdm_parent_node,
  8787. "qcom,msm-cpudai-tdm-sync-src",
  8788. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  8789. if (rc) {
  8790. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  8791. __func__, "qcom,msm-cpudai-tdm-sync-src");
  8792. goto free_dai_data;
  8793. }
  8794. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  8795. __func__, dai_data->port_cfg.tdm.sync_src);
  8796. rc = of_property_read_u32(tdm_parent_node,
  8797. "qcom,msm-cpudai-tdm-data-out",
  8798. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8799. if (rc) {
  8800. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  8801. __func__, "qcom,msm-cpudai-tdm-data-out");
  8802. goto free_dai_data;
  8803. }
  8804. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  8805. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8806. rc = of_property_read_u32(tdm_parent_node,
  8807. "qcom,msm-cpudai-tdm-invert-sync",
  8808. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8809. if (rc) {
  8810. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  8811. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  8812. goto free_dai_data;
  8813. }
  8814. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  8815. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8816. rc = of_property_read_u32(tdm_parent_node,
  8817. "qcom,msm-cpudai-tdm-data-delay",
  8818. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8819. if (rc) {
  8820. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  8821. __func__, "qcom,msm-cpudai-tdm-data-delay");
  8822. goto free_dai_data;
  8823. }
  8824. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  8825. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8826. /* TDM CFG -- set default */
  8827. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  8828. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  8829. AFE_API_VERSION_TDM_CONFIG;
  8830. /* TDM SLOT MAPPING CFG */
  8831. rc = of_property_read_u32(pdev->dev.of_node,
  8832. "qcom,msm-cpudai-tdm-data-align",
  8833. &dai_data->port_cfg.slot_mapping.data_align_type);
  8834. if (rc) {
  8835. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  8836. __func__,
  8837. "qcom,msm-cpudai-tdm-data-align");
  8838. goto free_dai_data;
  8839. }
  8840. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  8841. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  8842. /* TDM SLOT MAPPING CFG -- set default */
  8843. dai_data->port_cfg.slot_mapping.minor_version =
  8844. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  8845. /* CUSTOM TDM HEADER CFG */
  8846. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  8847. if (of_find_property(pdev->dev.of_node,
  8848. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  8849. of_find_property(pdev->dev.of_node,
  8850. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  8851. of_find_property(pdev->dev.of_node,
  8852. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  8853. /* if the property exist */
  8854. rc = of_property_read_u32(pdev->dev.of_node,
  8855. "qcom,msm-cpudai-tdm-header-start-offset",
  8856. (u32 *)&custom_tdm_header->start_offset);
  8857. if (rc) {
  8858. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  8859. __func__,
  8860. "qcom,msm-cpudai-tdm-header-start-offset");
  8861. goto free_dai_data;
  8862. }
  8863. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  8864. __func__, custom_tdm_header->start_offset);
  8865. rc = of_property_read_u32(pdev->dev.of_node,
  8866. "qcom,msm-cpudai-tdm-header-width",
  8867. (u32 *)&custom_tdm_header->header_width);
  8868. if (rc) {
  8869. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  8870. __func__, "qcom,msm-cpudai-tdm-header-width");
  8871. goto free_dai_data;
  8872. }
  8873. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  8874. __func__, custom_tdm_header->header_width);
  8875. rc = of_property_read_u32(pdev->dev.of_node,
  8876. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  8877. (u32 *)&custom_tdm_header->num_frame_repeat);
  8878. if (rc) {
  8879. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  8880. __func__,
  8881. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  8882. goto free_dai_data;
  8883. }
  8884. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  8885. __func__, custom_tdm_header->num_frame_repeat);
  8886. /* CUSTOM TDM HEADER CFG -- set default */
  8887. custom_tdm_header->minor_version =
  8888. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  8889. custom_tdm_header->header_type =
  8890. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8891. } else {
  8892. /* CUSTOM TDM HEADER CFG -- set default */
  8893. custom_tdm_header->header_type =
  8894. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8895. /* proceed with probe */
  8896. }
  8897. /* copy static clk per parent node */
  8898. dai_data->clk_set = tdm_clk_set;
  8899. /* copy static group cfg per parent node */
  8900. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  8901. /* copy static num group ports per parent node */
  8902. dai_data->num_group_ports = num_tdm_group_ports;
  8903. dev_set_drvdata(&pdev->dev, dai_data);
  8904. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  8905. if (port_idx < 0) {
  8906. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  8907. __func__, tdm_dev_id);
  8908. rc = -EINVAL;
  8909. goto free_dai_data;
  8910. }
  8911. rc = snd_soc_register_component(&pdev->dev,
  8912. &msm_q6_tdm_dai_component,
  8913. &msm_dai_q6_tdm_dai[port_idx], 1);
  8914. if (rc) {
  8915. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  8916. __func__, tdm_dev_id, rc);
  8917. goto err_register;
  8918. }
  8919. return 0;
  8920. err_register:
  8921. free_dai_data:
  8922. kfree(dai_data);
  8923. rtn:
  8924. return rc;
  8925. }
  8926. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  8927. {
  8928. struct msm_dai_q6_tdm_dai_data *dai_data =
  8929. dev_get_drvdata(&pdev->dev);
  8930. snd_soc_unregister_component(&pdev->dev);
  8931. kfree(dai_data);
  8932. return 0;
  8933. }
  8934. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  8935. { .compatible = "qcom,msm-dai-q6-tdm", },
  8936. {}
  8937. };
  8938. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  8939. static struct platform_driver msm_dai_q6_tdm_driver = {
  8940. .probe = msm_dai_q6_tdm_dev_probe,
  8941. .remove = msm_dai_q6_tdm_dev_remove,
  8942. .driver = {
  8943. .name = "msm-dai-q6-tdm",
  8944. .owner = THIS_MODULE,
  8945. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  8946. },
  8947. };
  8948. static int msm_dai_q6_cdc_dma_format_put(struct snd_kcontrol *kcontrol,
  8949. struct snd_ctl_elem_value *ucontrol)
  8950. {
  8951. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  8952. int value = ucontrol->value.integer.value[0];
  8953. dai_data->port_config.cdc_dma.data_format = value;
  8954. pr_debug("%s: format = %d\n", __func__, value);
  8955. return 0;
  8956. }
  8957. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  8958. struct snd_ctl_elem_value *ucontrol)
  8959. {
  8960. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  8961. ucontrol->value.integer.value[0] =
  8962. dai_data->port_config.cdc_dma.data_format;
  8963. return 0;
  8964. }
  8965. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  8966. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  8967. msm_dai_q6_cdc_dma_format_get,
  8968. msm_dai_q6_cdc_dma_format_put),
  8969. };
  8970. /* SOC probe for codec DMA interface */
  8971. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  8972. {
  8973. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  8974. int rc = 0;
  8975. if (!dai) {
  8976. pr_err("%s: Invalid params dai\n", __func__);
  8977. return -EINVAL;
  8978. }
  8979. if (!dai->dev) {
  8980. pr_err("%s: Invalid params dai dev\n", __func__);
  8981. return -EINVAL;
  8982. }
  8983. msm_dai_q6_set_dai_id(dai);
  8984. dai_data = dev_get_drvdata(dai->dev);
  8985. switch (dai->id) {
  8986. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  8987. rc = snd_ctl_add(dai->component->card->snd_card,
  8988. snd_ctl_new1(&cdc_dma_config_controls[0],
  8989. dai_data));
  8990. break;
  8991. default:
  8992. break;
  8993. }
  8994. if (rc < 0)
  8995. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  8996. __func__, dai->name);
  8997. if (dai_data->is_island_dai)
  8998. rc = msm_dai_q6_add_island_mx_ctls(
  8999. dai->component->card->snd_card,
  9000. dai->name, dai->id,
  9001. (void *)dai_data);
  9002. rc = msm_dai_q6_dai_add_route(dai);
  9003. return rc;
  9004. }
  9005. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  9006. {
  9007. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  9008. dev_get_drvdata(dai->dev);
  9009. int rc = 0;
  9010. /* If AFE port is still up, close it */
  9011. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  9012. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  9013. dai->id);
  9014. rc = afe_close(dai->id); /* can block */
  9015. if (rc < 0)
  9016. dev_err(dai->dev, "fail to close AFE port\n");
  9017. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  9018. }
  9019. return rc;
  9020. }
  9021. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  9022. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  9023. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  9024. {
  9025. int rc = 0;
  9026. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  9027. dev_get_drvdata(dai->dev);
  9028. unsigned int ch_mask = 0, ch_num = 0;
  9029. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  9030. switch (dai->id) {
  9031. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  9032. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  9033. case AFE_PORT_ID_RX_CODEC_DMA_RX_0:
  9034. case AFE_PORT_ID_RX_CODEC_DMA_RX_1:
  9035. case AFE_PORT_ID_RX_CODEC_DMA_RX_2:
  9036. case AFE_PORT_ID_RX_CODEC_DMA_RX_3:
  9037. case AFE_PORT_ID_RX_CODEC_DMA_RX_4:
  9038. case AFE_PORT_ID_RX_CODEC_DMA_RX_5:
  9039. case AFE_PORT_ID_RX_CODEC_DMA_RX_6:
  9040. case AFE_PORT_ID_RX_CODEC_DMA_RX_7:
  9041. if (!rx_ch_mask) {
  9042. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  9043. return -EINVAL;
  9044. }
  9045. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  9046. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  9047. __func__, rx_num_ch);
  9048. return -EINVAL;
  9049. }
  9050. ch_mask = *rx_ch_mask;
  9051. ch_num = rx_num_ch;
  9052. break;
  9053. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  9054. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  9055. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  9056. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  9057. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  9058. case AFE_PORT_ID_TX_CODEC_DMA_TX_0:
  9059. case AFE_PORT_ID_TX_CODEC_DMA_TX_1:
  9060. case AFE_PORT_ID_TX_CODEC_DMA_TX_2:
  9061. case AFE_PORT_ID_TX_CODEC_DMA_TX_3:
  9062. case AFE_PORT_ID_TX_CODEC_DMA_TX_4:
  9063. case AFE_PORT_ID_TX_CODEC_DMA_TX_5:
  9064. if (!tx_ch_mask) {
  9065. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  9066. return -EINVAL;
  9067. }
  9068. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  9069. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  9070. __func__, tx_num_ch);
  9071. return -EINVAL;
  9072. }
  9073. ch_mask = *tx_ch_mask;
  9074. ch_num = tx_num_ch;
  9075. break;
  9076. default:
  9077. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  9078. return -EINVAL;
  9079. }
  9080. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  9081. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  9082. dai->id, ch_num, ch_mask);
  9083. return rc;
  9084. }
  9085. static int msm_dai_q6_cdc_dma_hw_params(
  9086. struct snd_pcm_substream *substream,
  9087. struct snd_pcm_hw_params *params,
  9088. struct snd_soc_dai *dai)
  9089. {
  9090. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  9091. dev_get_drvdata(dai->dev);
  9092. switch (params_format(params)) {
  9093. case SNDRV_PCM_FORMAT_S16_LE:
  9094. case SNDRV_PCM_FORMAT_SPECIAL:
  9095. dai_data->port_config.cdc_dma.bit_width = 16;
  9096. break;
  9097. case SNDRV_PCM_FORMAT_S24_LE:
  9098. case SNDRV_PCM_FORMAT_S24_3LE:
  9099. dai_data->port_config.cdc_dma.bit_width = 24;
  9100. break;
  9101. case SNDRV_PCM_FORMAT_S32_LE:
  9102. dai_data->port_config.cdc_dma.bit_width = 32;
  9103. break;
  9104. default:
  9105. dev_err(dai->dev, "%s: format %d\n",
  9106. __func__, params_format(params));
  9107. return -EINVAL;
  9108. }
  9109. dai_data->rate = params_rate(params);
  9110. dai_data->channels = params_channels(params);
  9111. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  9112. AFE_API_VERSION_CODEC_DMA_CONFIG;
  9113. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  9114. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  9115. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  9116. "num_channel %hu sample_rate %d\n", __func__,
  9117. dai_data->port_config.cdc_dma.bit_width,
  9118. dai_data->port_config.cdc_dma.data_format,
  9119. dai_data->port_config.cdc_dma.num_channels,
  9120. dai_data->rate);
  9121. return 0;
  9122. }
  9123. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  9124. struct snd_soc_dai *dai)
  9125. {
  9126. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  9127. dev_get_drvdata(dai->dev);
  9128. int rc = 0;
  9129. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  9130. if (q6core_get_avcs_api_version_per_service(
  9131. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  9132. /*
  9133. * send island mode config.
  9134. * This should be the first configuration
  9135. */
  9136. rc = afe_send_port_island_mode(dai->id);
  9137. if (rc)
  9138. pr_err("%s: afe send island mode failed %d\n",
  9139. __func__, rc);
  9140. }
  9141. if ((dai->id == AFE_PORT_ID_WSA_CODEC_DMA_TX_0) &&
  9142. (dai_data->port_config.cdc_dma.data_format == 1))
  9143. dai_data->port_config.cdc_dma.data_format =
  9144. AFE_LINEAR_PCM_DATA_PACKED_16BIT;
  9145. rc = afe_port_start(dai->id, &dai_data->port_config,
  9146. dai_data->rate);
  9147. if (rc < 0)
  9148. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  9149. dai->id);
  9150. else
  9151. set_bit(STATUS_PORT_STARTED,
  9152. dai_data->status_mask);
  9153. }
  9154. return rc;
  9155. }
  9156. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  9157. struct snd_soc_dai *dai)
  9158. {
  9159. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  9160. int rc = 0;
  9161. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  9162. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  9163. dai->id);
  9164. rc = afe_close(dai->id); /* can block */
  9165. if (rc < 0)
  9166. dev_err(dai->dev, "fail to close AFE port\n");
  9167. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  9168. *dai_data->status_mask);
  9169. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  9170. }
  9171. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  9172. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  9173. }
  9174. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  9175. .prepare = msm_dai_q6_cdc_dma_prepare,
  9176. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  9177. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  9178. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  9179. };
  9180. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  9181. {
  9182. .playback = {
  9183. .stream_name = "WSA CDC DMA0 Playback",
  9184. .aif_name = "WSA_CDC_DMA_RX_0",
  9185. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9186. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9187. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9188. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9189. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9190. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9191. SNDRV_PCM_RATE_384000,
  9192. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9193. SNDRV_PCM_FMTBIT_S24_LE |
  9194. SNDRV_PCM_FMTBIT_S24_3LE |
  9195. SNDRV_PCM_FMTBIT_S32_LE,
  9196. .channels_min = 1,
  9197. .channels_max = 4,
  9198. .rate_min = 8000,
  9199. .rate_max = 384000,
  9200. },
  9201. .name = "WSA_CDC_DMA_RX_0",
  9202. .ops = &msm_dai_q6_cdc_dma_ops,
  9203. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  9204. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9205. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9206. },
  9207. {
  9208. .capture = {
  9209. .stream_name = "WSA CDC DMA0 Capture",
  9210. .aif_name = "WSA_CDC_DMA_TX_0",
  9211. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9212. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9213. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9214. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9215. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9216. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9217. SNDRV_PCM_RATE_384000,
  9218. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9219. SNDRV_PCM_FMTBIT_S24_LE |
  9220. SNDRV_PCM_FMTBIT_S24_3LE |
  9221. SNDRV_PCM_FMTBIT_S32_LE,
  9222. .channels_min = 1,
  9223. .channels_max = 4,
  9224. .rate_min = 8000,
  9225. .rate_max = 384000,
  9226. },
  9227. .name = "WSA_CDC_DMA_TX_0",
  9228. .ops = &msm_dai_q6_cdc_dma_ops,
  9229. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  9230. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9231. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9232. },
  9233. {
  9234. .playback = {
  9235. .stream_name = "WSA CDC DMA1 Playback",
  9236. .aif_name = "WSA_CDC_DMA_RX_1",
  9237. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9238. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9239. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9240. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9241. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9242. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9243. SNDRV_PCM_RATE_384000,
  9244. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9245. SNDRV_PCM_FMTBIT_S24_LE |
  9246. SNDRV_PCM_FMTBIT_S24_3LE |
  9247. SNDRV_PCM_FMTBIT_S32_LE,
  9248. .channels_min = 1,
  9249. .channels_max = 2,
  9250. .rate_min = 8000,
  9251. .rate_max = 384000,
  9252. },
  9253. .name = "WSA_CDC_DMA_RX_1",
  9254. .ops = &msm_dai_q6_cdc_dma_ops,
  9255. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  9256. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9257. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9258. },
  9259. {
  9260. .capture = {
  9261. .stream_name = "WSA CDC DMA1 Capture",
  9262. .aif_name = "WSA_CDC_DMA_TX_1",
  9263. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9264. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9265. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9266. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9267. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9268. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9269. SNDRV_PCM_RATE_384000,
  9270. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9271. SNDRV_PCM_FMTBIT_S24_LE |
  9272. SNDRV_PCM_FMTBIT_S24_3LE |
  9273. SNDRV_PCM_FMTBIT_S32_LE,
  9274. .channels_min = 1,
  9275. .channels_max = 2,
  9276. .rate_min = 8000,
  9277. .rate_max = 384000,
  9278. },
  9279. .name = "WSA_CDC_DMA_TX_1",
  9280. .ops = &msm_dai_q6_cdc_dma_ops,
  9281. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  9282. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9283. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9284. },
  9285. {
  9286. .capture = {
  9287. .stream_name = "WSA CDC DMA2 Capture",
  9288. .aif_name = "WSA_CDC_DMA_TX_2",
  9289. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9290. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9291. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9292. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9293. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9294. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9295. SNDRV_PCM_RATE_384000,
  9296. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9297. SNDRV_PCM_FMTBIT_S24_LE |
  9298. SNDRV_PCM_FMTBIT_S24_3LE |
  9299. SNDRV_PCM_FMTBIT_S32_LE,
  9300. .channels_min = 1,
  9301. .channels_max = 1,
  9302. .rate_min = 8000,
  9303. .rate_max = 384000,
  9304. },
  9305. .name = "WSA_CDC_DMA_TX_2",
  9306. .ops = &msm_dai_q6_cdc_dma_ops,
  9307. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  9308. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9309. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9310. },
  9311. {
  9312. .capture = {
  9313. .stream_name = "VA CDC DMA0 Capture",
  9314. .aif_name = "VA_CDC_DMA_TX_0",
  9315. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9316. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9317. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9318. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9319. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9320. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9321. SNDRV_PCM_RATE_384000,
  9322. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9323. SNDRV_PCM_FMTBIT_S24_LE |
  9324. SNDRV_PCM_FMTBIT_S24_3LE,
  9325. .channels_min = 1,
  9326. .channels_max = 8,
  9327. .rate_min = 8000,
  9328. .rate_max = 384000,
  9329. },
  9330. .name = "VA_CDC_DMA_TX_0",
  9331. .ops = &msm_dai_q6_cdc_dma_ops,
  9332. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  9333. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9334. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9335. },
  9336. {
  9337. .capture = {
  9338. .stream_name = "VA CDC DMA1 Capture",
  9339. .aif_name = "VA_CDC_DMA_TX_1",
  9340. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9341. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9342. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9343. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9344. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9345. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9346. SNDRV_PCM_RATE_384000,
  9347. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9348. SNDRV_PCM_FMTBIT_S24_LE |
  9349. SNDRV_PCM_FMTBIT_S24_3LE,
  9350. .channels_min = 1,
  9351. .channels_max = 8,
  9352. .rate_min = 8000,
  9353. .rate_max = 384000,
  9354. },
  9355. .name = "VA_CDC_DMA_TX_1",
  9356. .ops = &msm_dai_q6_cdc_dma_ops,
  9357. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  9358. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9359. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9360. },
  9361. {
  9362. .playback = {
  9363. .stream_name = "RX CDC DMA0 Playback",
  9364. .aif_name = "RX_CDC_DMA_RX_0",
  9365. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9366. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9367. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9368. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9369. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9370. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9371. SNDRV_PCM_RATE_384000,
  9372. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9373. SNDRV_PCM_FMTBIT_S24_LE |
  9374. SNDRV_PCM_FMTBIT_S24_3LE |
  9375. SNDRV_PCM_FMTBIT_S32_LE,
  9376. .channels_min = 1,
  9377. .channels_max = 2,
  9378. .rate_min = 8000,
  9379. .rate_max = 384000,
  9380. },
  9381. .ops = &msm_dai_q6_cdc_dma_ops,
  9382. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  9383. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9384. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9385. },
  9386. {
  9387. .capture = {
  9388. .stream_name = "TX CDC DMA0 Capture",
  9389. .aif_name = "TX_CDC_DMA_TX_0",
  9390. .rates = SNDRV_PCM_RATE_8000 |
  9391. SNDRV_PCM_RATE_16000 |
  9392. SNDRV_PCM_RATE_32000 |
  9393. SNDRV_PCM_RATE_48000 |
  9394. SNDRV_PCM_RATE_96000 |
  9395. SNDRV_PCM_RATE_192000 |
  9396. SNDRV_PCM_RATE_384000,
  9397. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9398. SNDRV_PCM_FMTBIT_S24_LE |
  9399. SNDRV_PCM_FMTBIT_S24_3LE |
  9400. SNDRV_PCM_FMTBIT_S32_LE,
  9401. .channels_min = 1,
  9402. .channels_max = 3,
  9403. .rate_min = 8000,
  9404. .rate_max = 384000,
  9405. },
  9406. .ops = &msm_dai_q6_cdc_dma_ops,
  9407. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  9408. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9409. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9410. },
  9411. {
  9412. .playback = {
  9413. .stream_name = "RX CDC DMA1 Playback",
  9414. .aif_name = "RX_CDC_DMA_RX_1",
  9415. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9416. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9417. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9418. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9419. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9420. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9421. SNDRV_PCM_RATE_384000,
  9422. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9423. SNDRV_PCM_FMTBIT_S24_LE |
  9424. SNDRV_PCM_FMTBIT_S24_3LE |
  9425. SNDRV_PCM_FMTBIT_S32_LE,
  9426. .channels_min = 1,
  9427. .channels_max = 2,
  9428. .rate_min = 8000,
  9429. .rate_max = 384000,
  9430. },
  9431. .ops = &msm_dai_q6_cdc_dma_ops,
  9432. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  9433. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9434. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9435. },
  9436. {
  9437. .capture = {
  9438. .stream_name = "TX CDC DMA1 Capture",
  9439. .aif_name = "TX_CDC_DMA_TX_1",
  9440. .rates = SNDRV_PCM_RATE_8000 |
  9441. SNDRV_PCM_RATE_16000 |
  9442. SNDRV_PCM_RATE_32000 |
  9443. SNDRV_PCM_RATE_48000 |
  9444. SNDRV_PCM_RATE_96000 |
  9445. SNDRV_PCM_RATE_192000 |
  9446. SNDRV_PCM_RATE_384000,
  9447. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9448. SNDRV_PCM_FMTBIT_S24_LE |
  9449. SNDRV_PCM_FMTBIT_S24_3LE |
  9450. SNDRV_PCM_FMTBIT_S32_LE,
  9451. .channels_min = 1,
  9452. .channels_max = 3,
  9453. .rate_min = 8000,
  9454. .rate_max = 384000,
  9455. },
  9456. .ops = &msm_dai_q6_cdc_dma_ops,
  9457. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  9458. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9459. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9460. },
  9461. {
  9462. .playback = {
  9463. .stream_name = "RX CDC DMA2 Playback",
  9464. .aif_name = "RX_CDC_DMA_RX_2",
  9465. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9466. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9467. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9468. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9469. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9470. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9471. SNDRV_PCM_RATE_384000,
  9472. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9473. SNDRV_PCM_FMTBIT_S24_LE |
  9474. SNDRV_PCM_FMTBIT_S24_3LE |
  9475. SNDRV_PCM_FMTBIT_S32_LE,
  9476. .channels_min = 1,
  9477. .channels_max = 1,
  9478. .rate_min = 8000,
  9479. .rate_max = 384000,
  9480. },
  9481. .ops = &msm_dai_q6_cdc_dma_ops,
  9482. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  9483. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9484. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9485. },
  9486. {
  9487. .capture = {
  9488. .stream_name = "TX CDC DMA2 Capture",
  9489. .aif_name = "TX_CDC_DMA_TX_2",
  9490. .rates = SNDRV_PCM_RATE_8000 |
  9491. SNDRV_PCM_RATE_16000 |
  9492. SNDRV_PCM_RATE_32000 |
  9493. SNDRV_PCM_RATE_48000 |
  9494. SNDRV_PCM_RATE_96000 |
  9495. SNDRV_PCM_RATE_192000 |
  9496. SNDRV_PCM_RATE_384000,
  9497. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9498. SNDRV_PCM_FMTBIT_S24_LE |
  9499. SNDRV_PCM_FMTBIT_S24_3LE |
  9500. SNDRV_PCM_FMTBIT_S32_LE,
  9501. .channels_min = 1,
  9502. .channels_max = 4,
  9503. .rate_min = 8000,
  9504. .rate_max = 384000,
  9505. },
  9506. .ops = &msm_dai_q6_cdc_dma_ops,
  9507. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  9508. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9509. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9510. }, {
  9511. .playback = {
  9512. .stream_name = "RX CDC DMA3 Playback",
  9513. .aif_name = "RX_CDC_DMA_RX_3",
  9514. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9515. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9516. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9517. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9518. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9519. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9520. SNDRV_PCM_RATE_384000,
  9521. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9522. SNDRV_PCM_FMTBIT_S24_LE |
  9523. SNDRV_PCM_FMTBIT_S24_3LE |
  9524. SNDRV_PCM_FMTBIT_S32_LE,
  9525. .channels_min = 1,
  9526. .channels_max = 1,
  9527. .rate_min = 8000,
  9528. .rate_max = 384000,
  9529. },
  9530. .ops = &msm_dai_q6_cdc_dma_ops,
  9531. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  9532. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9533. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9534. },
  9535. {
  9536. .capture = {
  9537. .stream_name = "TX CDC DMA3 Capture",
  9538. .aif_name = "TX_CDC_DMA_TX_3",
  9539. .rates = SNDRV_PCM_RATE_8000 |
  9540. SNDRV_PCM_RATE_16000 |
  9541. SNDRV_PCM_RATE_32000 |
  9542. SNDRV_PCM_RATE_48000 |
  9543. SNDRV_PCM_RATE_96000 |
  9544. SNDRV_PCM_RATE_192000 |
  9545. SNDRV_PCM_RATE_384000,
  9546. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9547. SNDRV_PCM_FMTBIT_S24_LE |
  9548. SNDRV_PCM_FMTBIT_S24_3LE |
  9549. SNDRV_PCM_FMTBIT_S32_LE,
  9550. .channels_min = 1,
  9551. .channels_max = 8,
  9552. .rate_min = 8000,
  9553. .rate_max = 384000,
  9554. },
  9555. .ops = &msm_dai_q6_cdc_dma_ops,
  9556. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  9557. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9558. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9559. },
  9560. {
  9561. .playback = {
  9562. .stream_name = "RX CDC DMA4 Playback",
  9563. .aif_name = "RX_CDC_DMA_RX_4",
  9564. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9565. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9566. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9567. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9568. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9569. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9570. SNDRV_PCM_RATE_384000,
  9571. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9572. SNDRV_PCM_FMTBIT_S24_LE |
  9573. SNDRV_PCM_FMTBIT_S24_3LE |
  9574. SNDRV_PCM_FMTBIT_S32_LE,
  9575. .channels_min = 1,
  9576. .channels_max = 6,
  9577. .rate_min = 8000,
  9578. .rate_max = 384000,
  9579. },
  9580. .ops = &msm_dai_q6_cdc_dma_ops,
  9581. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  9582. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9583. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9584. },
  9585. {
  9586. .capture = {
  9587. .stream_name = "TX CDC DMA4 Capture",
  9588. .aif_name = "TX_CDC_DMA_TX_4",
  9589. .rates = SNDRV_PCM_RATE_8000 |
  9590. SNDRV_PCM_RATE_16000 |
  9591. SNDRV_PCM_RATE_32000 |
  9592. SNDRV_PCM_RATE_48000 |
  9593. SNDRV_PCM_RATE_96000 |
  9594. SNDRV_PCM_RATE_192000 |
  9595. SNDRV_PCM_RATE_384000,
  9596. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9597. SNDRV_PCM_FMTBIT_S24_LE |
  9598. SNDRV_PCM_FMTBIT_S24_3LE |
  9599. SNDRV_PCM_FMTBIT_S32_LE,
  9600. .channels_min = 1,
  9601. .channels_max = 8,
  9602. .rate_min = 8000,
  9603. .rate_max = 384000,
  9604. },
  9605. .ops = &msm_dai_q6_cdc_dma_ops,
  9606. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  9607. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9608. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9609. },
  9610. {
  9611. .playback = {
  9612. .stream_name = "RX CDC DMA5 Playback",
  9613. .aif_name = "RX_CDC_DMA_RX_5",
  9614. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9615. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9616. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9617. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9618. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9619. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9620. SNDRV_PCM_RATE_384000,
  9621. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9622. SNDRV_PCM_FMTBIT_S24_LE |
  9623. SNDRV_PCM_FMTBIT_S24_3LE |
  9624. SNDRV_PCM_FMTBIT_S32_LE,
  9625. .channels_min = 1,
  9626. .channels_max = 1,
  9627. .rate_min = 8000,
  9628. .rate_max = 384000,
  9629. },
  9630. .ops = &msm_dai_q6_cdc_dma_ops,
  9631. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  9632. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9633. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9634. },
  9635. {
  9636. .capture = {
  9637. .stream_name = "TX CDC DMA5 Capture",
  9638. .aif_name = "TX_CDC_DMA_TX_5",
  9639. .rates = SNDRV_PCM_RATE_8000 |
  9640. SNDRV_PCM_RATE_16000 |
  9641. SNDRV_PCM_RATE_32000 |
  9642. SNDRV_PCM_RATE_48000 |
  9643. SNDRV_PCM_RATE_96000 |
  9644. SNDRV_PCM_RATE_192000 |
  9645. SNDRV_PCM_RATE_384000,
  9646. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9647. SNDRV_PCM_FMTBIT_S24_LE |
  9648. SNDRV_PCM_FMTBIT_S24_3LE |
  9649. SNDRV_PCM_FMTBIT_S32_LE,
  9650. .channels_min = 1,
  9651. .channels_max = 4,
  9652. .rate_min = 8000,
  9653. .rate_max = 384000,
  9654. },
  9655. .ops = &msm_dai_q6_cdc_dma_ops,
  9656. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  9657. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9658. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9659. },
  9660. {
  9661. .playback = {
  9662. .stream_name = "RX CDC DMA6 Playback",
  9663. .aif_name = "RX_CDC_DMA_RX_6",
  9664. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9665. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9666. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9667. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9668. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9669. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9670. SNDRV_PCM_RATE_384000,
  9671. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9672. SNDRV_PCM_FMTBIT_S24_LE |
  9673. SNDRV_PCM_FMTBIT_S24_3LE |
  9674. SNDRV_PCM_FMTBIT_S32_LE,
  9675. .channels_min = 1,
  9676. .channels_max = 4,
  9677. .rate_min = 8000,
  9678. .rate_max = 384000,
  9679. },
  9680. .ops = &msm_dai_q6_cdc_dma_ops,
  9681. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  9682. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9683. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9684. },
  9685. {
  9686. .playback = {
  9687. .stream_name = "RX CDC DMA7 Playback",
  9688. .aif_name = "RX_CDC_DMA_RX_7",
  9689. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9690. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9691. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9692. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9693. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9694. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9695. SNDRV_PCM_RATE_384000,
  9696. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9697. SNDRV_PCM_FMTBIT_S24_LE |
  9698. SNDRV_PCM_FMTBIT_S24_3LE |
  9699. SNDRV_PCM_FMTBIT_S32_LE,
  9700. .channels_min = 1,
  9701. .channels_max = 2,
  9702. .rate_min = 8000,
  9703. .rate_max = 384000,
  9704. },
  9705. .ops = &msm_dai_q6_cdc_dma_ops,
  9706. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  9707. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9708. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9709. },
  9710. };
  9711. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  9712. .name = "msm-dai-cdc-dma-dev",
  9713. };
  9714. /* DT related probe for each codec DMA interface device */
  9715. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  9716. {
  9717. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  9718. u32 cdc_dma_id = 0;
  9719. int i;
  9720. int rc = 0;
  9721. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  9722. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  9723. &cdc_dma_id);
  9724. if (rc) {
  9725. dev_err(&pdev->dev,
  9726. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  9727. return rc;
  9728. }
  9729. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  9730. dev_name(&pdev->dev), cdc_dma_id);
  9731. pdev->id = cdc_dma_id;
  9732. dai_data = devm_kzalloc(&pdev->dev,
  9733. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  9734. GFP_KERNEL);
  9735. if (!dai_data)
  9736. return -ENOMEM;
  9737. rc = of_property_read_u32(pdev->dev.of_node,
  9738. "qcom,msm-dai-is-island-supported",
  9739. &dai_data->is_island_dai);
  9740. if (rc)
  9741. dev_dbg(&pdev->dev, "island supported entry not found\n");
  9742. dev_set_drvdata(&pdev->dev, dai_data);
  9743. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  9744. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  9745. return snd_soc_register_component(&pdev->dev,
  9746. &msm_q6_cdc_dma_dai_component,
  9747. &msm_dai_q6_cdc_dma_dai[i], 1);
  9748. }
  9749. }
  9750. return -ENODEV;
  9751. }
  9752. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  9753. {
  9754. snd_soc_unregister_component(&pdev->dev);
  9755. return 0;
  9756. }
  9757. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  9758. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  9759. { }
  9760. };
  9761. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  9762. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  9763. .probe = msm_dai_q6_cdc_dma_dev_probe,
  9764. .remove = msm_dai_q6_cdc_dma_dev_remove,
  9765. .driver = {
  9766. .name = "msm-dai-cdc-dma-dev",
  9767. .owner = THIS_MODULE,
  9768. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  9769. },
  9770. };
  9771. /* DT related probe for codec DMA interface device group */
  9772. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  9773. {
  9774. int rc;
  9775. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  9776. if (rc) {
  9777. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  9778. __func__, rc);
  9779. } else
  9780. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  9781. return rc;
  9782. }
  9783. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  9784. {
  9785. of_platform_depopulate(&pdev->dev);
  9786. return 0;
  9787. }
  9788. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  9789. { .compatible = "qcom,msm-dai-cdc-dma", },
  9790. { }
  9791. };
  9792. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  9793. static struct platform_driver msm_dai_cdc_dma_q6 = {
  9794. .probe = msm_dai_cdc_dma_q6_probe,
  9795. .remove = msm_dai_cdc_dma_q6_remove,
  9796. .driver = {
  9797. .name = "msm-dai-cdc-dma",
  9798. .owner = THIS_MODULE,
  9799. .of_match_table = msm_dai_cdc_dma_dt_match,
  9800. },
  9801. };
  9802. int __init msm_dai_q6_init(void)
  9803. {
  9804. int rc;
  9805. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  9806. if (rc) {
  9807. pr_err("%s: fail to register auxpcm dev driver", __func__);
  9808. goto fail;
  9809. }
  9810. rc = platform_driver_register(&msm_dai_q6);
  9811. if (rc) {
  9812. pr_err("%s: fail to register dai q6 driver", __func__);
  9813. goto dai_q6_fail;
  9814. }
  9815. rc = platform_driver_register(&msm_dai_q6_dev);
  9816. if (rc) {
  9817. pr_err("%s: fail to register dai q6 dev driver", __func__);
  9818. goto dai_q6_dev_fail;
  9819. }
  9820. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  9821. if (rc) {
  9822. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  9823. goto dai_q6_mi2s_drv_fail;
  9824. }
  9825. rc = platform_driver_register(&msm_dai_mi2s_q6);
  9826. if (rc) {
  9827. pr_err("%s: fail to register dai MI2S\n", __func__);
  9828. goto dai_mi2s_q6_fail;
  9829. }
  9830. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  9831. if (rc) {
  9832. pr_err("%s: fail to register dai SPDIF\n", __func__);
  9833. goto dai_spdif_q6_fail;
  9834. }
  9835. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  9836. if (rc) {
  9837. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  9838. goto dai_q6_tdm_drv_fail;
  9839. }
  9840. rc = platform_driver_register(&msm_dai_tdm_q6);
  9841. if (rc) {
  9842. pr_err("%s: fail to register dai TDM\n", __func__);
  9843. goto dai_tdm_q6_fail;
  9844. }
  9845. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  9846. if (rc) {
  9847. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  9848. goto dai_cdc_dma_q6_dev_fail;
  9849. }
  9850. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  9851. if (rc) {
  9852. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  9853. goto dai_cdc_dma_q6_fail;
  9854. }
  9855. return rc;
  9856. dai_cdc_dma_q6_fail:
  9857. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  9858. dai_cdc_dma_q6_dev_fail:
  9859. platform_driver_unregister(&msm_dai_tdm_q6);
  9860. dai_tdm_q6_fail:
  9861. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  9862. dai_q6_tdm_drv_fail:
  9863. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  9864. dai_spdif_q6_fail:
  9865. platform_driver_unregister(&msm_dai_mi2s_q6);
  9866. dai_mi2s_q6_fail:
  9867. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  9868. dai_q6_mi2s_drv_fail:
  9869. platform_driver_unregister(&msm_dai_q6_dev);
  9870. dai_q6_dev_fail:
  9871. platform_driver_unregister(&msm_dai_q6);
  9872. dai_q6_fail:
  9873. platform_driver_unregister(&msm_auxpcm_dev_driver);
  9874. fail:
  9875. return rc;
  9876. }
  9877. void msm_dai_q6_exit(void)
  9878. {
  9879. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  9880. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  9881. platform_driver_unregister(&msm_dai_tdm_q6);
  9882. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  9883. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  9884. platform_driver_unregister(&msm_dai_mi2s_q6);
  9885. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  9886. platform_driver_unregister(&msm_dai_q6_dev);
  9887. platform_driver_unregister(&msm_dai_q6);
  9888. platform_driver_unregister(&msm_auxpcm_dev_driver);
  9889. }
  9890. /* Module information */
  9891. MODULE_DESCRIPTION("MSM DSP DAI driver");
  9892. MODULE_LICENSE("GPL v2");