msm-dai-q6-v2.c 382 KB

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