msm-dai-q6-v2.c 380 KB

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