msm-dai-q6-v2.c 310 KB

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