msm-dai-q6-v2.c 380 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110
  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("SENARY MI2S RX Format", mi2s_config_enum[0],
  4540. msm_dai_q6_mi2s_format_get,
  4541. msm_dai_q6_mi2s_format_put),
  4542. SOC_ENUM_EXT("PRI 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("SEC 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("TERT 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("QUAT 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("QUIN 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("SENARY MI2S TX Format", mi2s_config_enum[0],
  4558. msm_dai_q6_mi2s_format_get,
  4559. msm_dai_q6_mi2s_format_put),
  4560. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  4561. msm_dai_q6_mi2s_format_get,
  4562. msm_dai_q6_mi2s_format_put),
  4563. };
  4564. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  4565. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  4566. msm_dai_q6_mi2s_vi_feed_mono_get,
  4567. msm_dai_q6_mi2s_vi_feed_mono_put),
  4568. };
  4569. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  4570. {
  4571. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4572. dev_get_drvdata(dai->dev);
  4573. struct msm_mi2s_pdata *mi2s_pdata =
  4574. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  4575. struct snd_kcontrol *kcontrol = NULL;
  4576. int rc = 0;
  4577. const struct snd_kcontrol_new *ctrl = NULL;
  4578. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  4579. u16 dai_id = 0;
  4580. dai->id = mi2s_pdata->intf_id;
  4581. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4582. if (dai->id == MSM_PRIM_MI2S)
  4583. ctrl = &mi2s_config_controls[0];
  4584. if (dai->id == MSM_SEC_MI2S)
  4585. ctrl = &mi2s_config_controls[1];
  4586. if (dai->id == MSM_TERT_MI2S)
  4587. ctrl = &mi2s_config_controls[2];
  4588. if (dai->id == MSM_QUAT_MI2S)
  4589. ctrl = &mi2s_config_controls[3];
  4590. if (dai->id == MSM_QUIN_MI2S)
  4591. ctrl = &mi2s_config_controls[4];
  4592. if (dai->id == MSM_SENARY_MI2S)
  4593. ctrl = &mi2s_config_controls[5];
  4594. }
  4595. if (ctrl) {
  4596. kcontrol = snd_ctl_new1(ctrl,
  4597. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  4598. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  4599. if (rc < 0) {
  4600. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  4601. __func__, dai->name);
  4602. goto rtn;
  4603. }
  4604. }
  4605. ctrl = NULL;
  4606. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4607. if (dai->id == MSM_PRIM_MI2S)
  4608. ctrl = &mi2s_config_controls[6];
  4609. if (dai->id == MSM_SEC_MI2S)
  4610. ctrl = &mi2s_config_controls[7];
  4611. if (dai->id == MSM_TERT_MI2S)
  4612. ctrl = &mi2s_config_controls[8];
  4613. if (dai->id == MSM_QUAT_MI2S)
  4614. ctrl = &mi2s_config_controls[9];
  4615. if (dai->id == MSM_QUIN_MI2S)
  4616. ctrl = &mi2s_config_controls[10];
  4617. if (dai->id == MSM_SENARY_MI2S)
  4618. ctrl = &mi2s_config_controls[11];
  4619. if (dai->id == MSM_INT5_MI2S)
  4620. ctrl = &mi2s_config_controls[12];
  4621. }
  4622. if (ctrl) {
  4623. rc = snd_ctl_add(dai->component->card->snd_card,
  4624. snd_ctl_new1(ctrl,
  4625. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4626. if (rc < 0) {
  4627. if (kcontrol)
  4628. snd_ctl_remove(dai->component->card->snd_card,
  4629. kcontrol);
  4630. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  4631. __func__, dai->name);
  4632. }
  4633. }
  4634. if (dai->id == MSM_INT5_MI2S)
  4635. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  4636. if (vi_feed_ctrl) {
  4637. rc = snd_ctl_add(dai->component->card->snd_card,
  4638. snd_ctl_new1(vi_feed_ctrl,
  4639. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4640. if (rc < 0) {
  4641. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  4642. __func__, dai->name);
  4643. }
  4644. }
  4645. if (mi2s_dai_data->is_island_dai) {
  4646. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  4647. &dai_id);
  4648. rc = msm_dai_q6_add_island_mx_ctls(
  4649. dai->component->card->snd_card,
  4650. dai->name, dai_id,
  4651. (void *)mi2s_dai_data);
  4652. }
  4653. rc = msm_dai_q6_dai_add_route(dai);
  4654. rtn:
  4655. return rc;
  4656. }
  4657. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  4658. {
  4659. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4660. dev_get_drvdata(dai->dev);
  4661. int rc;
  4662. /* If AFE port is still up, close it */
  4663. if (test_bit(STATUS_PORT_STARTED,
  4664. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  4665. rc = afe_close(MI2S_RX); /* can block */
  4666. if (rc < 0)
  4667. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  4668. clear_bit(STATUS_PORT_STARTED,
  4669. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  4670. }
  4671. if (test_bit(STATUS_PORT_STARTED,
  4672. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4673. rc = afe_close(MI2S_TX); /* can block */
  4674. if (rc < 0)
  4675. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  4676. clear_bit(STATUS_PORT_STARTED,
  4677. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  4678. }
  4679. return 0;
  4680. }
  4681. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  4682. struct snd_soc_dai *dai)
  4683. {
  4684. return 0;
  4685. }
  4686. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  4687. {
  4688. int ret = 0;
  4689. switch (stream) {
  4690. case SNDRV_PCM_STREAM_PLAYBACK:
  4691. switch (mi2s_id) {
  4692. case MSM_PRIM_MI2S:
  4693. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  4694. break;
  4695. case MSM_SEC_MI2S:
  4696. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  4697. break;
  4698. case MSM_TERT_MI2S:
  4699. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  4700. break;
  4701. case MSM_QUAT_MI2S:
  4702. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  4703. break;
  4704. case MSM_SEC_MI2S_SD1:
  4705. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  4706. break;
  4707. case MSM_QUIN_MI2S:
  4708. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  4709. break;
  4710. case MSM_SENARY_MI2S:
  4711. *port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  4712. break;
  4713. case MSM_INT0_MI2S:
  4714. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  4715. break;
  4716. case MSM_INT1_MI2S:
  4717. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  4718. break;
  4719. case MSM_INT2_MI2S:
  4720. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  4721. break;
  4722. case MSM_INT3_MI2S:
  4723. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  4724. break;
  4725. case MSM_INT4_MI2S:
  4726. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  4727. break;
  4728. case MSM_INT5_MI2S:
  4729. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  4730. break;
  4731. case MSM_INT6_MI2S:
  4732. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  4733. break;
  4734. default:
  4735. pr_err("%s: playback err id 0x%x\n",
  4736. __func__, mi2s_id);
  4737. ret = -1;
  4738. break;
  4739. }
  4740. break;
  4741. case SNDRV_PCM_STREAM_CAPTURE:
  4742. switch (mi2s_id) {
  4743. case MSM_PRIM_MI2S:
  4744. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  4745. break;
  4746. case MSM_SEC_MI2S:
  4747. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  4748. break;
  4749. case MSM_TERT_MI2S:
  4750. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  4751. break;
  4752. case MSM_QUAT_MI2S:
  4753. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  4754. break;
  4755. case MSM_QUIN_MI2S:
  4756. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  4757. break;
  4758. case MSM_SENARY_MI2S:
  4759. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  4760. break;
  4761. case MSM_INT0_MI2S:
  4762. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  4763. break;
  4764. case MSM_INT1_MI2S:
  4765. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  4766. break;
  4767. case MSM_INT2_MI2S:
  4768. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  4769. break;
  4770. case MSM_INT3_MI2S:
  4771. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  4772. break;
  4773. case MSM_INT4_MI2S:
  4774. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  4775. break;
  4776. case MSM_INT5_MI2S:
  4777. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  4778. break;
  4779. case MSM_INT6_MI2S:
  4780. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  4781. break;
  4782. default:
  4783. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  4784. ret = -1;
  4785. break;
  4786. }
  4787. break;
  4788. default:
  4789. pr_err("%s: default err %d\n", __func__, stream);
  4790. ret = -1;
  4791. break;
  4792. }
  4793. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  4794. return ret;
  4795. }
  4796. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  4797. struct snd_soc_dai *dai)
  4798. {
  4799. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4800. dev_get_drvdata(dai->dev);
  4801. struct msm_dai_q6_dai_data *dai_data =
  4802. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4803. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4804. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4805. u16 port_id = 0;
  4806. int rc = 0;
  4807. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4808. &port_id) != 0) {
  4809. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4810. __func__, port_id);
  4811. return -EINVAL;
  4812. }
  4813. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  4814. "dai_data->channels = %u sample_rate = %u\n", __func__,
  4815. dai->id, port_id, dai_data->channels, dai_data->rate);
  4816. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4817. /* PORT START should be set if prepare called
  4818. * in active state.
  4819. */
  4820. rc = afe_port_start(port_id, &dai_data->port_config,
  4821. dai_data->rate);
  4822. if (rc < 0)
  4823. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  4824. dai->id);
  4825. else
  4826. set_bit(STATUS_PORT_STARTED,
  4827. dai_data->status_mask);
  4828. }
  4829. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4830. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4831. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  4832. __func__);
  4833. }
  4834. return rc;
  4835. }
  4836. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  4837. struct snd_pcm_hw_params *params,
  4838. struct snd_soc_dai *dai)
  4839. {
  4840. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4841. dev_get_drvdata(dai->dev);
  4842. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  4843. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4844. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  4845. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  4846. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  4847. dai_data->channels = params_channels(params);
  4848. switch (dai_data->channels) {
  4849. case 15:
  4850. case 16:
  4851. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4852. case AFE_PORT_I2S_16CHS:
  4853. dai_data->port_config.i2s.channel_mode
  4854. = AFE_PORT_I2S_16CHS;
  4855. break;
  4856. default:
  4857. goto error_invalid_data;
  4858. };
  4859. break;
  4860. case 13:
  4861. case 14:
  4862. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4863. case AFE_PORT_I2S_14CHS:
  4864. case AFE_PORT_I2S_16CHS:
  4865. dai_data->port_config.i2s.channel_mode
  4866. = AFE_PORT_I2S_14CHS;
  4867. break;
  4868. default:
  4869. goto error_invalid_data;
  4870. };
  4871. break;
  4872. case 11:
  4873. case 12:
  4874. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4875. case AFE_PORT_I2S_12CHS:
  4876. case AFE_PORT_I2S_14CHS:
  4877. case AFE_PORT_I2S_16CHS:
  4878. dai_data->port_config.i2s.channel_mode
  4879. = AFE_PORT_I2S_12CHS;
  4880. break;
  4881. default:
  4882. goto error_invalid_data;
  4883. };
  4884. break;
  4885. case 9:
  4886. case 10:
  4887. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4888. case AFE_PORT_I2S_10CHS:
  4889. case AFE_PORT_I2S_12CHS:
  4890. case AFE_PORT_I2S_14CHS:
  4891. case AFE_PORT_I2S_16CHS:
  4892. dai_data->port_config.i2s.channel_mode
  4893. = AFE_PORT_I2S_10CHS;
  4894. break;
  4895. default:
  4896. goto error_invalid_data;
  4897. };
  4898. break;
  4899. case 8:
  4900. case 7:
  4901. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  4902. goto error_invalid_data;
  4903. else
  4904. if (mi2s_dai_config->pdata_mi2s_lines
  4905. == AFE_PORT_I2S_8CHS_2)
  4906. dai_data->port_config.i2s.channel_mode =
  4907. AFE_PORT_I2S_8CHS_2;
  4908. else
  4909. dai_data->port_config.i2s.channel_mode =
  4910. AFE_PORT_I2S_8CHS;
  4911. break;
  4912. case 6:
  4913. case 5:
  4914. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  4915. goto error_invalid_data;
  4916. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  4917. break;
  4918. case 4:
  4919. case 3:
  4920. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4921. case AFE_PORT_I2S_SD0:
  4922. case AFE_PORT_I2S_SD1:
  4923. case AFE_PORT_I2S_SD2:
  4924. case AFE_PORT_I2S_SD3:
  4925. case AFE_PORT_I2S_SD4:
  4926. case AFE_PORT_I2S_SD5:
  4927. case AFE_PORT_I2S_SD6:
  4928. case AFE_PORT_I2S_SD7:
  4929. goto error_invalid_data;
  4930. break;
  4931. case AFE_PORT_I2S_QUAD01:
  4932. case AFE_PORT_I2S_QUAD23:
  4933. case AFE_PORT_I2S_QUAD45:
  4934. case AFE_PORT_I2S_QUAD67:
  4935. dai_data->port_config.i2s.channel_mode =
  4936. mi2s_dai_config->pdata_mi2s_lines;
  4937. break;
  4938. case AFE_PORT_I2S_8CHS_2:
  4939. dai_data->port_config.i2s.channel_mode =
  4940. AFE_PORT_I2S_QUAD45;
  4941. break;
  4942. default:
  4943. dai_data->port_config.i2s.channel_mode =
  4944. AFE_PORT_I2S_QUAD01;
  4945. break;
  4946. };
  4947. break;
  4948. case 2:
  4949. case 1:
  4950. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  4951. goto error_invalid_data;
  4952. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4953. case AFE_PORT_I2S_SD0:
  4954. case AFE_PORT_I2S_SD1:
  4955. case AFE_PORT_I2S_SD2:
  4956. case AFE_PORT_I2S_SD3:
  4957. case AFE_PORT_I2S_SD4:
  4958. case AFE_PORT_I2S_SD5:
  4959. case AFE_PORT_I2S_SD6:
  4960. case AFE_PORT_I2S_SD7:
  4961. dai_data->port_config.i2s.channel_mode =
  4962. mi2s_dai_config->pdata_mi2s_lines;
  4963. break;
  4964. case AFE_PORT_I2S_QUAD01:
  4965. case AFE_PORT_I2S_6CHS:
  4966. case AFE_PORT_I2S_8CHS:
  4967. case AFE_PORT_I2S_10CHS:
  4968. case AFE_PORT_I2S_12CHS:
  4969. case AFE_PORT_I2S_14CHS:
  4970. case AFE_PORT_I2S_16CHS:
  4971. if (dai_data->vi_feed_mono == SPKR_1)
  4972. dai_data->port_config.i2s.channel_mode =
  4973. AFE_PORT_I2S_SD0;
  4974. else
  4975. dai_data->port_config.i2s.channel_mode =
  4976. AFE_PORT_I2S_SD1;
  4977. break;
  4978. case AFE_PORT_I2S_QUAD23:
  4979. dai_data->port_config.i2s.channel_mode =
  4980. AFE_PORT_I2S_SD2;
  4981. break;
  4982. case AFE_PORT_I2S_QUAD45:
  4983. dai_data->port_config.i2s.channel_mode =
  4984. AFE_PORT_I2S_SD4;
  4985. break;
  4986. case AFE_PORT_I2S_QUAD67:
  4987. dai_data->port_config.i2s.channel_mode =
  4988. AFE_PORT_I2S_SD6;
  4989. break;
  4990. }
  4991. if (dai_data->channels == 2)
  4992. dai_data->port_config.i2s.mono_stereo =
  4993. MSM_AFE_CH_STEREO;
  4994. else
  4995. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  4996. break;
  4997. default:
  4998. pr_err("%s: default err channels %d\n",
  4999. __func__, dai_data->channels);
  5000. goto error_invalid_data;
  5001. }
  5002. dai_data->rate = params_rate(params);
  5003. switch (params_format(params)) {
  5004. case SNDRV_PCM_FORMAT_S16_LE:
  5005. case SNDRV_PCM_FORMAT_SPECIAL:
  5006. dai_data->port_config.i2s.bit_width = 16;
  5007. dai_data->bitwidth = 16;
  5008. break;
  5009. case SNDRV_PCM_FORMAT_S24_LE:
  5010. case SNDRV_PCM_FORMAT_S24_3LE:
  5011. dai_data->port_config.i2s.bit_width = 24;
  5012. dai_data->bitwidth = 24;
  5013. break;
  5014. case SNDRV_PCM_FORMAT_S32_LE:
  5015. dai_data->port_config.i2s.bit_width = 32;
  5016. dai_data->bitwidth = 32;
  5017. break;
  5018. default:
  5019. pr_err("%s: format %d\n",
  5020. __func__, params_format(params));
  5021. return -EINVAL;
  5022. }
  5023. dai_data->port_config.i2s.i2s_cfg_minor_version =
  5024. AFE_API_VERSION_I2S_CONFIG;
  5025. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  5026. if ((test_bit(STATUS_PORT_STARTED,
  5027. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  5028. test_bit(STATUS_PORT_STARTED,
  5029. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  5030. (test_bit(STATUS_PORT_STARTED,
  5031. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  5032. test_bit(STATUS_PORT_STARTED,
  5033. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  5034. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  5035. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  5036. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  5037. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  5038. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  5039. "Tx sample_rate = %u bit_width = %hu\n"
  5040. "Rx sample_rate = %u bit_width = %hu\n"
  5041. , __func__,
  5042. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  5043. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  5044. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  5045. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  5046. return -EINVAL;
  5047. }
  5048. }
  5049. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  5050. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  5051. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  5052. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  5053. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  5054. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  5055. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  5056. i2s->sample_rate, i2s->data_format, i2s->reserved);
  5057. return 0;
  5058. error_invalid_data:
  5059. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  5060. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  5061. return -EINVAL;
  5062. }
  5063. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  5064. {
  5065. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5066. dev_get_drvdata(dai->dev);
  5067. if (test_bit(STATUS_PORT_STARTED,
  5068. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  5069. test_bit(STATUS_PORT_STARTED,
  5070. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  5071. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  5072. __func__);
  5073. return -EPERM;
  5074. }
  5075. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  5076. case SND_SOC_DAIFMT_CBS_CFS:
  5077. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5078. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5079. break;
  5080. case SND_SOC_DAIFMT_CBM_CFM:
  5081. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5082. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5083. break;
  5084. default:
  5085. pr_err("%s: fmt %d\n",
  5086. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  5087. return -EINVAL;
  5088. }
  5089. return 0;
  5090. }
  5091. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  5092. struct snd_soc_dai *dai)
  5093. {
  5094. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5095. dev_get_drvdata(dai->dev);
  5096. struct msm_dai_q6_dai_data *dai_data =
  5097. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5098. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5099. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5100. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  5101. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5102. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  5103. }
  5104. return 0;
  5105. }
  5106. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  5107. struct snd_soc_dai *dai)
  5108. {
  5109. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5110. dev_get_drvdata(dai->dev);
  5111. struct msm_dai_q6_dai_data *dai_data =
  5112. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5113. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5114. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5115. u16 port_id = 0;
  5116. int rc = 0;
  5117. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  5118. &port_id) != 0) {
  5119. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5120. __func__, port_id);
  5121. }
  5122. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  5123. __func__, port_id);
  5124. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5125. rc = afe_close(port_id);
  5126. if (rc < 0)
  5127. dev_err(dai->dev, "fail to close AFE port\n");
  5128. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  5129. }
  5130. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  5131. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5132. }
  5133. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  5134. .startup = msm_dai_q6_mi2s_startup,
  5135. .prepare = msm_dai_q6_mi2s_prepare,
  5136. .hw_params = msm_dai_q6_mi2s_hw_params,
  5137. .hw_free = msm_dai_q6_mi2s_hw_free,
  5138. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  5139. .shutdown = msm_dai_q6_mi2s_shutdown,
  5140. };
  5141. /* Channel min and max are initialized base on platform data */
  5142. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  5143. {
  5144. .playback = {
  5145. .stream_name = "Primary MI2S Playback",
  5146. .aif_name = "PRI_MI2S_RX",
  5147. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5148. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5149. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5150. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5151. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5152. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5153. SNDRV_PCM_RATE_384000,
  5154. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5155. SNDRV_PCM_FMTBIT_S24_LE |
  5156. SNDRV_PCM_FMTBIT_S24_3LE,
  5157. .rate_min = 8000,
  5158. .rate_max = 384000,
  5159. },
  5160. .capture = {
  5161. .stream_name = "Primary MI2S Capture",
  5162. .aif_name = "PRI_MI2S_TX",
  5163. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5164. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5165. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5166. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5167. SNDRV_PCM_RATE_192000,
  5168. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5169. .rate_min = 8000,
  5170. .rate_max = 192000,
  5171. },
  5172. .ops = &msm_dai_q6_mi2s_ops,
  5173. .name = "Primary MI2S",
  5174. .id = MSM_PRIM_MI2S,
  5175. .probe = msm_dai_q6_dai_mi2s_probe,
  5176. .remove = msm_dai_q6_dai_mi2s_remove,
  5177. },
  5178. {
  5179. .playback = {
  5180. .stream_name = "Secondary MI2S Playback",
  5181. .aif_name = "SEC_MI2S_RX",
  5182. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5183. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5184. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5185. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5186. SNDRV_PCM_RATE_192000,
  5187. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5188. .rate_min = 8000,
  5189. .rate_max = 192000,
  5190. },
  5191. .capture = {
  5192. .stream_name = "Secondary MI2S Capture",
  5193. .aif_name = "SEC_MI2S_TX",
  5194. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5195. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5196. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5197. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5198. SNDRV_PCM_RATE_192000,
  5199. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5200. .rate_min = 8000,
  5201. .rate_max = 192000,
  5202. },
  5203. .ops = &msm_dai_q6_mi2s_ops,
  5204. .name = "Secondary MI2S",
  5205. .id = MSM_SEC_MI2S,
  5206. .probe = msm_dai_q6_dai_mi2s_probe,
  5207. .remove = msm_dai_q6_dai_mi2s_remove,
  5208. },
  5209. {
  5210. .playback = {
  5211. .stream_name = "Tertiary MI2S Playback",
  5212. .aif_name = "TERT_MI2S_RX",
  5213. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5214. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5215. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5216. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5217. SNDRV_PCM_RATE_192000,
  5218. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5219. .rate_min = 8000,
  5220. .rate_max = 192000,
  5221. },
  5222. .capture = {
  5223. .stream_name = "Tertiary MI2S Capture",
  5224. .aif_name = "TERT_MI2S_TX",
  5225. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5226. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5227. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5228. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5229. SNDRV_PCM_RATE_192000,
  5230. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5231. .rate_min = 8000,
  5232. .rate_max = 192000,
  5233. },
  5234. .ops = &msm_dai_q6_mi2s_ops,
  5235. .name = "Tertiary MI2S",
  5236. .id = MSM_TERT_MI2S,
  5237. .probe = msm_dai_q6_dai_mi2s_probe,
  5238. .remove = msm_dai_q6_dai_mi2s_remove,
  5239. },
  5240. {
  5241. .playback = {
  5242. .stream_name = "Quaternary MI2S Playback",
  5243. .aif_name = "QUAT_MI2S_RX",
  5244. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5245. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5246. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5247. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5248. SNDRV_PCM_RATE_192000,
  5249. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5250. .rate_min = 8000,
  5251. .rate_max = 192000,
  5252. },
  5253. .capture = {
  5254. .stream_name = "Quaternary MI2S Capture",
  5255. .aif_name = "QUAT_MI2S_TX",
  5256. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5257. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5258. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5259. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5260. SNDRV_PCM_RATE_192000,
  5261. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5262. .rate_min = 8000,
  5263. .rate_max = 192000,
  5264. },
  5265. .ops = &msm_dai_q6_mi2s_ops,
  5266. .name = "Quaternary MI2S",
  5267. .id = MSM_QUAT_MI2S,
  5268. .probe = msm_dai_q6_dai_mi2s_probe,
  5269. .remove = msm_dai_q6_dai_mi2s_remove,
  5270. },
  5271. {
  5272. .playback = {
  5273. .stream_name = "Quinary MI2S Playback",
  5274. .aif_name = "QUIN_MI2S_RX",
  5275. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5276. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5277. SNDRV_PCM_RATE_192000,
  5278. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5279. .rate_min = 8000,
  5280. .rate_max = 192000,
  5281. },
  5282. .capture = {
  5283. .stream_name = "Quinary MI2S Capture",
  5284. .aif_name = "QUIN_MI2S_TX",
  5285. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5286. SNDRV_PCM_RATE_16000,
  5287. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5288. .rate_min = 8000,
  5289. .rate_max = 48000,
  5290. },
  5291. .ops = &msm_dai_q6_mi2s_ops,
  5292. .name = "Quinary MI2S",
  5293. .id = MSM_QUIN_MI2S,
  5294. .probe = msm_dai_q6_dai_mi2s_probe,
  5295. .remove = msm_dai_q6_dai_mi2s_remove,
  5296. },
  5297. {
  5298. .playback = {
  5299. .stream_name = "Senary MI2S Playback",
  5300. .aif_name = "SEN_MI2S_RX",
  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. .capture = {
  5308. .stream_name = "Senary MI2S Capture",
  5309. .aif_name = "SENARY_MI2S_TX",
  5310. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5311. SNDRV_PCM_RATE_16000,
  5312. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5313. .rate_min = 8000,
  5314. .rate_max = 48000,
  5315. },
  5316. .ops = &msm_dai_q6_mi2s_ops,
  5317. .name = "Senary MI2S",
  5318. .id = MSM_SENARY_MI2S,
  5319. .probe = msm_dai_q6_dai_mi2s_probe,
  5320. .remove = msm_dai_q6_dai_mi2s_remove,
  5321. },
  5322. {
  5323. .playback = {
  5324. .stream_name = "Secondary MI2S Playback SD1",
  5325. .aif_name = "SEC_MI2S_RX_SD1",
  5326. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5327. SNDRV_PCM_RATE_16000,
  5328. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5329. .rate_min = 8000,
  5330. .rate_max = 48000,
  5331. },
  5332. .id = MSM_SEC_MI2S_SD1,
  5333. },
  5334. {
  5335. .playback = {
  5336. .stream_name = "INT0 MI2S Playback",
  5337. .aif_name = "INT0_MI2S_RX",
  5338. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5339. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  5340. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  5341. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5342. SNDRV_PCM_FMTBIT_S24_LE |
  5343. SNDRV_PCM_FMTBIT_S24_3LE,
  5344. .rate_min = 8000,
  5345. .rate_max = 192000,
  5346. },
  5347. .capture = {
  5348. .stream_name = "INT0 MI2S Capture",
  5349. .aif_name = "INT0_MI2S_TX",
  5350. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5351. SNDRV_PCM_RATE_16000,
  5352. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5353. .rate_min = 8000,
  5354. .rate_max = 48000,
  5355. },
  5356. .ops = &msm_dai_q6_mi2s_ops,
  5357. .name = "INT0 MI2S",
  5358. .id = MSM_INT0_MI2S,
  5359. .probe = msm_dai_q6_dai_mi2s_probe,
  5360. .remove = msm_dai_q6_dai_mi2s_remove,
  5361. },
  5362. {
  5363. .playback = {
  5364. .stream_name = "INT1 MI2S Playback",
  5365. .aif_name = "INT1_MI2S_RX",
  5366. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5367. SNDRV_PCM_RATE_16000,
  5368. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5369. SNDRV_PCM_FMTBIT_S24_LE |
  5370. SNDRV_PCM_FMTBIT_S24_3LE,
  5371. .rate_min = 8000,
  5372. .rate_max = 48000,
  5373. },
  5374. .capture = {
  5375. .stream_name = "INT1 MI2S Capture",
  5376. .aif_name = "INT1_MI2S_TX",
  5377. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5378. SNDRV_PCM_RATE_16000,
  5379. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5380. .rate_min = 8000,
  5381. .rate_max = 48000,
  5382. },
  5383. .ops = &msm_dai_q6_mi2s_ops,
  5384. .name = "INT1 MI2S",
  5385. .id = MSM_INT1_MI2S,
  5386. .probe = msm_dai_q6_dai_mi2s_probe,
  5387. .remove = msm_dai_q6_dai_mi2s_remove,
  5388. },
  5389. {
  5390. .playback = {
  5391. .stream_name = "INT2 MI2S Playback",
  5392. .aif_name = "INT2_MI2S_RX",
  5393. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5394. SNDRV_PCM_RATE_16000,
  5395. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5396. SNDRV_PCM_FMTBIT_S24_LE |
  5397. SNDRV_PCM_FMTBIT_S24_3LE,
  5398. .rate_min = 8000,
  5399. .rate_max = 48000,
  5400. },
  5401. .capture = {
  5402. .stream_name = "INT2 MI2S Capture",
  5403. .aif_name = "INT2_MI2S_TX",
  5404. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5405. SNDRV_PCM_RATE_16000,
  5406. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5407. .rate_min = 8000,
  5408. .rate_max = 48000,
  5409. },
  5410. .ops = &msm_dai_q6_mi2s_ops,
  5411. .name = "INT2 MI2S",
  5412. .id = MSM_INT2_MI2S,
  5413. .probe = msm_dai_q6_dai_mi2s_probe,
  5414. .remove = msm_dai_q6_dai_mi2s_remove,
  5415. },
  5416. {
  5417. .playback = {
  5418. .stream_name = "INT3 MI2S Playback",
  5419. .aif_name = "INT3_MI2S_RX",
  5420. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5421. SNDRV_PCM_RATE_16000,
  5422. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5423. SNDRV_PCM_FMTBIT_S24_LE |
  5424. SNDRV_PCM_FMTBIT_S24_3LE,
  5425. .rate_min = 8000,
  5426. .rate_max = 48000,
  5427. },
  5428. .capture = {
  5429. .stream_name = "INT3 MI2S Capture",
  5430. .aif_name = "INT3_MI2S_TX",
  5431. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5432. SNDRV_PCM_RATE_16000,
  5433. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5434. .rate_min = 8000,
  5435. .rate_max = 48000,
  5436. },
  5437. .ops = &msm_dai_q6_mi2s_ops,
  5438. .name = "INT3 MI2S",
  5439. .id = MSM_INT3_MI2S,
  5440. .probe = msm_dai_q6_dai_mi2s_probe,
  5441. .remove = msm_dai_q6_dai_mi2s_remove,
  5442. },
  5443. {
  5444. .playback = {
  5445. .stream_name = "INT4 MI2S Playback",
  5446. .aif_name = "INT4_MI2S_RX",
  5447. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5448. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5449. SNDRV_PCM_RATE_192000,
  5450. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5451. SNDRV_PCM_FMTBIT_S24_LE |
  5452. SNDRV_PCM_FMTBIT_S24_3LE,
  5453. .rate_min = 8000,
  5454. .rate_max = 192000,
  5455. },
  5456. .capture = {
  5457. .stream_name = "INT4 MI2S Capture",
  5458. .aif_name = "INT4_MI2S_TX",
  5459. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5460. SNDRV_PCM_RATE_16000,
  5461. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5462. .rate_min = 8000,
  5463. .rate_max = 48000,
  5464. },
  5465. .ops = &msm_dai_q6_mi2s_ops,
  5466. .name = "INT4 MI2S",
  5467. .id = MSM_INT4_MI2S,
  5468. .probe = msm_dai_q6_dai_mi2s_probe,
  5469. .remove = msm_dai_q6_dai_mi2s_remove,
  5470. },
  5471. {
  5472. .playback = {
  5473. .stream_name = "INT5 MI2S Playback",
  5474. .aif_name = "INT5_MI2S_RX",
  5475. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5476. SNDRV_PCM_RATE_16000,
  5477. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5478. SNDRV_PCM_FMTBIT_S24_LE |
  5479. SNDRV_PCM_FMTBIT_S24_3LE,
  5480. .rate_min = 8000,
  5481. .rate_max = 48000,
  5482. },
  5483. .capture = {
  5484. .stream_name = "INT5 MI2S Capture",
  5485. .aif_name = "INT5_MI2S_TX",
  5486. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5487. SNDRV_PCM_RATE_16000,
  5488. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5489. .rate_min = 8000,
  5490. .rate_max = 48000,
  5491. },
  5492. .ops = &msm_dai_q6_mi2s_ops,
  5493. .name = "INT5 MI2S",
  5494. .id = MSM_INT5_MI2S,
  5495. .probe = msm_dai_q6_dai_mi2s_probe,
  5496. .remove = msm_dai_q6_dai_mi2s_remove,
  5497. },
  5498. {
  5499. .playback = {
  5500. .stream_name = "INT6 MI2S Playback",
  5501. .aif_name = "INT6_MI2S_RX",
  5502. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5503. SNDRV_PCM_RATE_16000,
  5504. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5505. SNDRV_PCM_FMTBIT_S24_LE |
  5506. SNDRV_PCM_FMTBIT_S24_3LE,
  5507. .rate_min = 8000,
  5508. .rate_max = 48000,
  5509. },
  5510. .capture = {
  5511. .stream_name = "INT6 MI2S Capture",
  5512. .aif_name = "INT6_MI2S_TX",
  5513. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5514. SNDRV_PCM_RATE_16000,
  5515. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5516. .rate_min = 8000,
  5517. .rate_max = 48000,
  5518. },
  5519. .ops = &msm_dai_q6_mi2s_ops,
  5520. .name = "INT6 MI2S",
  5521. .id = MSM_INT6_MI2S,
  5522. .probe = msm_dai_q6_dai_mi2s_probe,
  5523. .remove = msm_dai_q6_dai_mi2s_remove,
  5524. },
  5525. };
  5526. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  5527. unsigned int *ch_cnt)
  5528. {
  5529. u8 num_of_sd_lines;
  5530. num_of_sd_lines = num_of_bits_set(sd_lines);
  5531. switch (num_of_sd_lines) {
  5532. case 0:
  5533. pr_debug("%s: no line is assigned\n", __func__);
  5534. break;
  5535. case 1:
  5536. switch (sd_lines) {
  5537. case MSM_MI2S_SD0:
  5538. *config_ptr = AFE_PORT_I2S_SD0;
  5539. break;
  5540. case MSM_MI2S_SD1:
  5541. *config_ptr = AFE_PORT_I2S_SD1;
  5542. break;
  5543. case MSM_MI2S_SD2:
  5544. *config_ptr = AFE_PORT_I2S_SD2;
  5545. break;
  5546. case MSM_MI2S_SD3:
  5547. *config_ptr = AFE_PORT_I2S_SD3;
  5548. break;
  5549. case MSM_MI2S_SD4:
  5550. *config_ptr = AFE_PORT_I2S_SD4;
  5551. break;
  5552. case MSM_MI2S_SD5:
  5553. *config_ptr = AFE_PORT_I2S_SD5;
  5554. break;
  5555. case MSM_MI2S_SD6:
  5556. *config_ptr = AFE_PORT_I2S_SD6;
  5557. break;
  5558. case MSM_MI2S_SD7:
  5559. *config_ptr = AFE_PORT_I2S_SD7;
  5560. break;
  5561. default:
  5562. pr_err("%s: invalid SD lines %d\n",
  5563. __func__, sd_lines);
  5564. goto error_invalid_data;
  5565. }
  5566. break;
  5567. case 2:
  5568. switch (sd_lines) {
  5569. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  5570. *config_ptr = AFE_PORT_I2S_QUAD01;
  5571. break;
  5572. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5573. *config_ptr = AFE_PORT_I2S_QUAD23;
  5574. break;
  5575. case MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5576. *config_ptr = AFE_PORT_I2S_QUAD45;
  5577. break;
  5578. case MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5579. *config_ptr = AFE_PORT_I2S_QUAD67;
  5580. break;
  5581. default:
  5582. pr_err("%s: invalid SD lines %d\n",
  5583. __func__, sd_lines);
  5584. goto error_invalid_data;
  5585. }
  5586. break;
  5587. case 3:
  5588. switch (sd_lines) {
  5589. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  5590. *config_ptr = AFE_PORT_I2S_6CHS;
  5591. break;
  5592. default:
  5593. pr_err("%s: invalid SD lines %d\n",
  5594. __func__, sd_lines);
  5595. goto error_invalid_data;
  5596. }
  5597. break;
  5598. case 4:
  5599. switch (sd_lines) {
  5600. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5601. *config_ptr = AFE_PORT_I2S_8CHS;
  5602. break;
  5603. case MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5604. *config_ptr = AFE_PORT_I2S_8CHS_2;
  5605. break;
  5606. default:
  5607. pr_err("%s: invalid SD lines %d\n",
  5608. __func__, sd_lines);
  5609. goto error_invalid_data;
  5610. }
  5611. break;
  5612. case 5:
  5613. switch (sd_lines) {
  5614. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5615. | MSM_MI2S_SD3 | MSM_MI2S_SD4:
  5616. *config_ptr = AFE_PORT_I2S_10CHS;
  5617. break;
  5618. default:
  5619. pr_err("%s: invalid SD lines %d\n",
  5620. __func__, sd_lines);
  5621. goto error_invalid_data;
  5622. }
  5623. break;
  5624. case 6:
  5625. switch (sd_lines) {
  5626. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5627. | MSM_MI2S_SD3 | MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5628. *config_ptr = AFE_PORT_I2S_12CHS;
  5629. break;
  5630. default:
  5631. pr_err("%s: invalid SD lines %d\n",
  5632. __func__, sd_lines);
  5633. goto error_invalid_data;
  5634. }
  5635. break;
  5636. case 7:
  5637. switch (sd_lines) {
  5638. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5639. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6:
  5640. *config_ptr = AFE_PORT_I2S_14CHS;
  5641. break;
  5642. default:
  5643. pr_err("%s: invalid SD lines %d\n",
  5644. __func__, sd_lines);
  5645. goto error_invalid_data;
  5646. }
  5647. break;
  5648. case 8:
  5649. switch (sd_lines) {
  5650. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5651. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5652. *config_ptr = AFE_PORT_I2S_16CHS;
  5653. break;
  5654. default:
  5655. pr_err("%s: invalid SD lines %d\n",
  5656. __func__, sd_lines);
  5657. goto error_invalid_data;
  5658. }
  5659. break;
  5660. default:
  5661. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  5662. goto error_invalid_data;
  5663. }
  5664. *ch_cnt = num_of_sd_lines;
  5665. return 0;
  5666. error_invalid_data:
  5667. pr_err("%s: invalid data\n", __func__);
  5668. return -EINVAL;
  5669. }
  5670. static u16 msm_dai_q6_mi2s_get_num_channels(u16 config)
  5671. {
  5672. switch (config) {
  5673. case AFE_PORT_I2S_SD0:
  5674. case AFE_PORT_I2S_SD1:
  5675. case AFE_PORT_I2S_SD2:
  5676. case AFE_PORT_I2S_SD3:
  5677. case AFE_PORT_I2S_SD4:
  5678. case AFE_PORT_I2S_SD5:
  5679. case AFE_PORT_I2S_SD6:
  5680. case AFE_PORT_I2S_SD7:
  5681. return 2;
  5682. case AFE_PORT_I2S_QUAD01:
  5683. case AFE_PORT_I2S_QUAD23:
  5684. case AFE_PORT_I2S_QUAD45:
  5685. case AFE_PORT_I2S_QUAD67:
  5686. return 4;
  5687. case AFE_PORT_I2S_6CHS:
  5688. return 6;
  5689. case AFE_PORT_I2S_8CHS:
  5690. case AFE_PORT_I2S_8CHS_2:
  5691. return 8;
  5692. case AFE_PORT_I2S_10CHS:
  5693. return 10;
  5694. case AFE_PORT_I2S_12CHS:
  5695. return 12;
  5696. case AFE_PORT_I2S_14CHS:
  5697. return 14;
  5698. case AFE_PORT_I2S_16CHS:
  5699. return 16;
  5700. default:
  5701. pr_err("%s: invalid config\n", __func__);
  5702. return 0;
  5703. }
  5704. }
  5705. static int msm_dai_q6_mi2s_platform_data_validation(
  5706. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  5707. {
  5708. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  5709. struct msm_mi2s_pdata *mi2s_pdata =
  5710. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  5711. unsigned int ch_cnt;
  5712. int rc = 0;
  5713. u16 sd_line;
  5714. if (mi2s_pdata == NULL) {
  5715. pr_err("%s: mi2s_pdata NULL", __func__);
  5716. return -EINVAL;
  5717. }
  5718. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  5719. &sd_line, &ch_cnt);
  5720. if (rc < 0) {
  5721. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  5722. goto rtn;
  5723. }
  5724. if (ch_cnt) {
  5725. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5726. sd_line;
  5727. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  5728. dai_driver->playback.channels_min = 1;
  5729. dai_driver->playback.channels_max = ch_cnt << 1;
  5730. } else {
  5731. dai_driver->playback.channels_min = 0;
  5732. dai_driver->playback.channels_max = 0;
  5733. }
  5734. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  5735. &sd_line, &ch_cnt);
  5736. if (rc < 0) {
  5737. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  5738. goto rtn;
  5739. }
  5740. if (ch_cnt) {
  5741. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5742. sd_line;
  5743. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  5744. dai_driver->capture.channels_min = 1;
  5745. dai_driver->capture.channels_max = ch_cnt << 1;
  5746. } else {
  5747. dai_driver->capture.channels_min = 0;
  5748. dai_driver->capture.channels_max = 0;
  5749. }
  5750. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  5751. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  5752. dai_data->tx_dai.pdata_mi2s_lines);
  5753. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  5754. __func__, dai_driver->playback.channels_max,
  5755. dai_driver->capture.channels_max);
  5756. rtn:
  5757. return rc;
  5758. }
  5759. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  5760. .name = "msm-dai-q6-mi2s",
  5761. };
  5762. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  5763. {
  5764. struct msm_dai_q6_mi2s_dai_data *dai_data;
  5765. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  5766. u32 tx_line = 0;
  5767. u32 rx_line = 0;
  5768. u32 mi2s_intf = 0;
  5769. struct msm_mi2s_pdata *mi2s_pdata;
  5770. int rc;
  5771. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  5772. &mi2s_intf);
  5773. if (rc) {
  5774. dev_err(&pdev->dev,
  5775. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  5776. goto rtn;
  5777. }
  5778. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  5779. mi2s_intf);
  5780. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  5781. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  5782. dev_err(&pdev->dev,
  5783. "%s: Invalid MI2S ID %u from Device Tree\n",
  5784. __func__, mi2s_intf);
  5785. rc = -ENXIO;
  5786. goto rtn;
  5787. }
  5788. pdev->id = mi2s_intf;
  5789. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  5790. if (!mi2s_pdata) {
  5791. rc = -ENOMEM;
  5792. goto rtn;
  5793. }
  5794. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  5795. &rx_line);
  5796. if (rc) {
  5797. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  5798. "qcom,msm-mi2s-rx-lines");
  5799. goto free_pdata;
  5800. }
  5801. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  5802. &tx_line);
  5803. if (rc) {
  5804. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  5805. "qcom,msm-mi2s-tx-lines");
  5806. goto free_pdata;
  5807. }
  5808. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  5809. dev_name(&pdev->dev), rx_line, tx_line);
  5810. mi2s_pdata->rx_sd_lines = rx_line;
  5811. mi2s_pdata->tx_sd_lines = tx_line;
  5812. mi2s_pdata->intf_id = mi2s_intf;
  5813. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  5814. GFP_KERNEL);
  5815. if (!dai_data) {
  5816. rc = -ENOMEM;
  5817. goto free_pdata;
  5818. } else
  5819. dev_set_drvdata(&pdev->dev, dai_data);
  5820. rc = of_property_read_u32(pdev->dev.of_node,
  5821. "qcom,msm-dai-is-island-supported",
  5822. &dai_data->is_island_dai);
  5823. if (rc)
  5824. dev_dbg(&pdev->dev, "island supported entry not found\n");
  5825. pdev->dev.platform_data = mi2s_pdata;
  5826. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  5827. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  5828. if (rc < 0)
  5829. goto free_dai_data;
  5830. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  5831. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  5832. if (rc < 0)
  5833. goto err_register;
  5834. return 0;
  5835. err_register:
  5836. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  5837. free_dai_data:
  5838. kfree(dai_data);
  5839. free_pdata:
  5840. kfree(mi2s_pdata);
  5841. rtn:
  5842. return rc;
  5843. }
  5844. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  5845. {
  5846. snd_soc_unregister_component(&pdev->dev);
  5847. return 0;
  5848. }
  5849. static int msm_dai_q6_dai_meta_mi2s_probe(struct snd_soc_dai *dai)
  5850. {
  5851. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  5852. (struct msm_meta_mi2s_pdata *) dai->dev->platform_data;
  5853. int rc = 0;
  5854. dai->id = meta_mi2s_pdata->intf_id;
  5855. rc = msm_dai_q6_dai_add_route(dai);
  5856. return rc;
  5857. }
  5858. static int msm_dai_q6_dai_meta_mi2s_remove(struct snd_soc_dai *dai)
  5859. {
  5860. return 0;
  5861. }
  5862. static int msm_dai_q6_meta_mi2s_startup(struct snd_pcm_substream *substream,
  5863. struct snd_soc_dai *dai)
  5864. {
  5865. return 0;
  5866. }
  5867. static int msm_meta_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  5868. {
  5869. int ret = 0;
  5870. switch (stream) {
  5871. case SNDRV_PCM_STREAM_PLAYBACK:
  5872. switch (mi2s_id) {
  5873. case MSM_PRIM_META_MI2S:
  5874. *port_id = AFE_PORT_ID_PRIMARY_META_MI2S_RX;
  5875. break;
  5876. case MSM_SEC_META_MI2S:
  5877. *port_id = AFE_PORT_ID_SECONDARY_META_MI2S_RX;
  5878. break;
  5879. default:
  5880. pr_err("%s: playback err id 0x%x\n",
  5881. __func__, mi2s_id);
  5882. ret = -1;
  5883. break;
  5884. }
  5885. break;
  5886. case SNDRV_PCM_STREAM_CAPTURE:
  5887. switch (mi2s_id) {
  5888. default:
  5889. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  5890. ret = -1;
  5891. break;
  5892. }
  5893. break;
  5894. default:
  5895. pr_err("%s: default err %d\n", __func__, stream);
  5896. ret = -1;
  5897. break;
  5898. }
  5899. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  5900. return ret;
  5901. }
  5902. static int msm_dai_q6_meta_mi2s_prepare(struct snd_pcm_substream *substream,
  5903. struct snd_soc_dai *dai)
  5904. {
  5905. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  5906. dev_get_drvdata(dai->dev);
  5907. u16 port_id = 0;
  5908. int rc = 0;
  5909. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  5910. &port_id) != 0) {
  5911. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5912. __func__, port_id);
  5913. return -EINVAL;
  5914. }
  5915. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  5916. "dai_data->channels = %u sample_rate = %u\n", __func__,
  5917. dai->id, port_id, dai_data->channels, dai_data->rate);
  5918. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5919. /* PORT START should be set if prepare called
  5920. * in active state.
  5921. */
  5922. rc = afe_port_start(port_id, &dai_data->port_config,
  5923. dai_data->rate);
  5924. if (rc < 0)
  5925. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  5926. dai->id);
  5927. else
  5928. set_bit(STATUS_PORT_STARTED,
  5929. dai_data->status_mask);
  5930. }
  5931. return rc;
  5932. }
  5933. static int msm_dai_q6_meta_mi2s_hw_params(struct snd_pcm_substream *substream,
  5934. struct snd_pcm_hw_params *params,
  5935. struct snd_soc_dai *dai)
  5936. {
  5937. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  5938. dev_get_drvdata(dai->dev);
  5939. struct afe_param_id_meta_i2s_cfg *port_cfg =
  5940. &dai_data->port_config.meta_i2s;
  5941. int idx = 0;
  5942. u16 port_channels = 0;
  5943. u16 channels_left = 0;
  5944. dai_data->channels = params_channels(params);
  5945. channels_left = dai_data->channels;
  5946. /* map requested channels to channels that member ports provide */
  5947. for (idx = 0; idx < dai_data->num_member_ports; idx++) {
  5948. port_channels = msm_dai_q6_mi2s_get_num_channels(
  5949. dai_data->channel_mode[idx]);
  5950. if (channels_left >= port_channels) {
  5951. port_cfg->member_port_id[idx] =
  5952. dai_data->member_port_id[idx];
  5953. port_cfg->member_port_channel_mode[idx] =
  5954. dai_data->channel_mode[idx];
  5955. channels_left -= port_channels;
  5956. } else {
  5957. switch (channels_left) {
  5958. case 15:
  5959. case 16:
  5960. switch (dai_data->channel_mode[idx]) {
  5961. case AFE_PORT_I2S_16CHS:
  5962. port_cfg->member_port_channel_mode[idx]
  5963. = AFE_PORT_I2S_16CHS;
  5964. break;
  5965. default:
  5966. goto error_invalid_data;
  5967. };
  5968. break;
  5969. case 13:
  5970. case 14:
  5971. switch (dai_data->channel_mode[idx]) {
  5972. case AFE_PORT_I2S_14CHS:
  5973. case AFE_PORT_I2S_16CHS:
  5974. port_cfg->member_port_channel_mode[idx]
  5975. = AFE_PORT_I2S_14CHS;
  5976. break;
  5977. default:
  5978. goto error_invalid_data;
  5979. };
  5980. break;
  5981. case 11:
  5982. case 12:
  5983. switch (dai_data->channel_mode[idx]) {
  5984. case AFE_PORT_I2S_12CHS:
  5985. case AFE_PORT_I2S_14CHS:
  5986. case AFE_PORT_I2S_16CHS:
  5987. port_cfg->member_port_channel_mode[idx]
  5988. = AFE_PORT_I2S_12CHS;
  5989. break;
  5990. default:
  5991. goto error_invalid_data;
  5992. };
  5993. break;
  5994. case 9:
  5995. case 10:
  5996. switch (dai_data->channel_mode[idx]) {
  5997. case AFE_PORT_I2S_10CHS:
  5998. case AFE_PORT_I2S_12CHS:
  5999. case AFE_PORT_I2S_14CHS:
  6000. case AFE_PORT_I2S_16CHS:
  6001. port_cfg->member_port_channel_mode[idx]
  6002. = AFE_PORT_I2S_10CHS;
  6003. break;
  6004. default:
  6005. goto error_invalid_data;
  6006. };
  6007. break;
  6008. case 8:
  6009. case 7:
  6010. switch (dai_data->channel_mode[idx]) {
  6011. case AFE_PORT_I2S_8CHS:
  6012. case AFE_PORT_I2S_10CHS:
  6013. case AFE_PORT_I2S_12CHS:
  6014. case AFE_PORT_I2S_14CHS:
  6015. case AFE_PORT_I2S_16CHS:
  6016. port_cfg->member_port_channel_mode[idx]
  6017. = AFE_PORT_I2S_8CHS;
  6018. break;
  6019. case AFE_PORT_I2S_8CHS_2:
  6020. port_cfg->member_port_channel_mode[idx]
  6021. = AFE_PORT_I2S_8CHS_2;
  6022. break;
  6023. default:
  6024. goto error_invalid_data;
  6025. };
  6026. break;
  6027. case 6:
  6028. case 5:
  6029. switch (dai_data->channel_mode[idx]) {
  6030. case AFE_PORT_I2S_6CHS:
  6031. case AFE_PORT_I2S_8CHS:
  6032. case AFE_PORT_I2S_10CHS:
  6033. case AFE_PORT_I2S_12CHS:
  6034. case AFE_PORT_I2S_14CHS:
  6035. case AFE_PORT_I2S_16CHS:
  6036. port_cfg->member_port_channel_mode[idx]
  6037. = AFE_PORT_I2S_6CHS;
  6038. break;
  6039. default:
  6040. goto error_invalid_data;
  6041. };
  6042. break;
  6043. case 4:
  6044. case 3:
  6045. switch (dai_data->channel_mode[idx]) {
  6046. case AFE_PORT_I2S_SD0:
  6047. case AFE_PORT_I2S_SD1:
  6048. case AFE_PORT_I2S_SD2:
  6049. case AFE_PORT_I2S_SD3:
  6050. case AFE_PORT_I2S_SD4:
  6051. case AFE_PORT_I2S_SD5:
  6052. case AFE_PORT_I2S_SD6:
  6053. case AFE_PORT_I2S_SD7:
  6054. goto error_invalid_data;
  6055. case AFE_PORT_I2S_QUAD01:
  6056. case AFE_PORT_I2S_QUAD23:
  6057. case AFE_PORT_I2S_QUAD45:
  6058. case AFE_PORT_I2S_QUAD67:
  6059. port_cfg->member_port_channel_mode[idx]
  6060. = dai_data->channel_mode[idx];
  6061. break;
  6062. case AFE_PORT_I2S_8CHS_2:
  6063. port_cfg->member_port_channel_mode[idx]
  6064. = AFE_PORT_I2S_QUAD45;
  6065. break;
  6066. default:
  6067. port_cfg->member_port_channel_mode[idx]
  6068. = AFE_PORT_I2S_QUAD01;
  6069. };
  6070. break;
  6071. case 2:
  6072. case 1:
  6073. if (dai_data->channel_mode[idx] <
  6074. AFE_PORT_I2S_SD0)
  6075. goto error_invalid_data;
  6076. switch (dai_data->channel_mode[idx]) {
  6077. case AFE_PORT_I2S_SD0:
  6078. case AFE_PORT_I2S_SD1:
  6079. case AFE_PORT_I2S_SD2:
  6080. case AFE_PORT_I2S_SD3:
  6081. case AFE_PORT_I2S_SD4:
  6082. case AFE_PORT_I2S_SD5:
  6083. case AFE_PORT_I2S_SD6:
  6084. case AFE_PORT_I2S_SD7:
  6085. port_cfg->member_port_channel_mode[idx]
  6086. = dai_data->channel_mode[idx];
  6087. break;
  6088. case AFE_PORT_I2S_QUAD01:
  6089. case AFE_PORT_I2S_6CHS:
  6090. case AFE_PORT_I2S_8CHS:
  6091. case AFE_PORT_I2S_10CHS:
  6092. case AFE_PORT_I2S_12CHS:
  6093. case AFE_PORT_I2S_14CHS:
  6094. case AFE_PORT_I2S_16CHS:
  6095. port_cfg->member_port_channel_mode[idx]
  6096. = AFE_PORT_I2S_SD0;
  6097. break;
  6098. case AFE_PORT_I2S_QUAD23:
  6099. port_cfg->member_port_channel_mode[idx]
  6100. = AFE_PORT_I2S_SD2;
  6101. break;
  6102. case AFE_PORT_I2S_QUAD45:
  6103. case AFE_PORT_I2S_8CHS_2:
  6104. port_cfg->member_port_channel_mode[idx]
  6105. = AFE_PORT_I2S_SD4;
  6106. break;
  6107. case AFE_PORT_I2S_QUAD67:
  6108. port_cfg->member_port_channel_mode[idx]
  6109. = AFE_PORT_I2S_SD6;
  6110. break;
  6111. }
  6112. break;
  6113. case 0:
  6114. port_cfg->member_port_channel_mode[idx] = 0;
  6115. }
  6116. if (port_cfg->member_port_channel_mode[idx] == 0) {
  6117. port_cfg->member_port_id[idx] =
  6118. AFE_PORT_ID_INVALID;
  6119. } else {
  6120. port_cfg->member_port_id[idx] =
  6121. dai_data->member_port_id[idx];
  6122. channels_left -=
  6123. msm_dai_q6_mi2s_get_num_channels(
  6124. port_cfg->member_port_channel_mode[idx]);
  6125. }
  6126. }
  6127. }
  6128. if (channels_left > 0) {
  6129. pr_err("%s: too many channels %d\n",
  6130. __func__, dai_data->channels);
  6131. return -EINVAL;
  6132. }
  6133. dai_data->rate = params_rate(params);
  6134. port_cfg->sample_rate = dai_data->rate;
  6135. switch (params_format(params)) {
  6136. case SNDRV_PCM_FORMAT_S16_LE:
  6137. case SNDRV_PCM_FORMAT_SPECIAL:
  6138. port_cfg->bit_width = 16;
  6139. dai_data->bitwidth = 16;
  6140. break;
  6141. case SNDRV_PCM_FORMAT_S24_LE:
  6142. case SNDRV_PCM_FORMAT_S24_3LE:
  6143. port_cfg->bit_width = 24;
  6144. dai_data->bitwidth = 24;
  6145. break;
  6146. default:
  6147. pr_err("%s: format %d\n",
  6148. __func__, params_format(params));
  6149. return -EINVAL;
  6150. }
  6151. port_cfg->minor_version = AFE_API_VERSION_META_I2S_CONFIG;
  6152. port_cfg->data_format = AFE_LINEAR_PCM_DATA;
  6153. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  6154. "bit_width = %hu ws_src = 0x%x sample_rate = %u\n"
  6155. "member_ports 0x%x 0x%x 0x%x 0x%x\n"
  6156. "sd_lines 0x%x 0x%x 0x%x 0x%x\n",
  6157. __func__, dai->id, dai_data->channels,
  6158. port_cfg->bit_width, port_cfg->ws_src, port_cfg->sample_rate,
  6159. port_cfg->member_port_id[0],
  6160. port_cfg->member_port_id[1],
  6161. port_cfg->member_port_id[2],
  6162. port_cfg->member_port_id[3],
  6163. port_cfg->member_port_channel_mode[0],
  6164. port_cfg->member_port_channel_mode[1],
  6165. port_cfg->member_port_channel_mode[2],
  6166. port_cfg->member_port_channel_mode[3]);
  6167. return 0;
  6168. error_invalid_data:
  6169. pr_err("%s: error when assigning member port %d channels (channels_left %d)\n",
  6170. __func__, idx, channels_left);
  6171. return -EINVAL;
  6172. }
  6173. static int msm_dai_q6_meta_mi2s_set_fmt(struct snd_soc_dai *dai,
  6174. unsigned int fmt)
  6175. {
  6176. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6177. dev_get_drvdata(dai->dev);
  6178. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6179. dev_err(dai->dev, "%s: err chg meta i2s mode while dai running",
  6180. __func__);
  6181. return -EPERM;
  6182. }
  6183. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  6184. case SND_SOC_DAIFMT_CBS_CFS:
  6185. dai_data->port_config.meta_i2s.ws_src = 1;
  6186. break;
  6187. case SND_SOC_DAIFMT_CBM_CFM:
  6188. dai_data->port_config.meta_i2s.ws_src = 0;
  6189. break;
  6190. default:
  6191. pr_err("%s: fmt %d\n",
  6192. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  6193. return -EINVAL;
  6194. }
  6195. return 0;
  6196. }
  6197. static void msm_dai_q6_meta_mi2s_shutdown(struct snd_pcm_substream *substream,
  6198. struct snd_soc_dai *dai)
  6199. {
  6200. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6201. dev_get_drvdata(dai->dev);
  6202. u16 port_id = 0;
  6203. int rc = 0;
  6204. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  6205. &port_id) != 0) {
  6206. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  6207. __func__, port_id);
  6208. }
  6209. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  6210. __func__, port_id);
  6211. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6212. rc = afe_close(port_id);
  6213. if (rc < 0)
  6214. dev_err(dai->dev, "fail to close AFE port\n");
  6215. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  6216. }
  6217. }
  6218. static struct snd_soc_dai_ops msm_dai_q6_meta_mi2s_ops = {
  6219. .startup = msm_dai_q6_meta_mi2s_startup,
  6220. .prepare = msm_dai_q6_meta_mi2s_prepare,
  6221. .hw_params = msm_dai_q6_meta_mi2s_hw_params,
  6222. .set_fmt = msm_dai_q6_meta_mi2s_set_fmt,
  6223. .shutdown = msm_dai_q6_meta_mi2s_shutdown,
  6224. };
  6225. /* Channel min and max are initialized base on platform data */
  6226. static struct snd_soc_dai_driver msm_dai_q6_meta_mi2s_dai[] = {
  6227. {
  6228. .playback = {
  6229. .stream_name = "Primary META MI2S Playback",
  6230. .aif_name = "PRI_META_MI2S_RX",
  6231. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6232. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6233. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6234. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  6235. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  6236. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  6237. SNDRV_PCM_RATE_384000,
  6238. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6239. SNDRV_PCM_FMTBIT_S24_LE |
  6240. SNDRV_PCM_FMTBIT_S24_3LE,
  6241. .rate_min = 8000,
  6242. .rate_max = 384000,
  6243. },
  6244. .ops = &msm_dai_q6_meta_mi2s_ops,
  6245. .name = "Primary META MI2S",
  6246. .id = AFE_PORT_ID_PRIMARY_META_MI2S_RX,
  6247. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6248. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6249. },
  6250. {
  6251. .playback = {
  6252. .stream_name = "Secondary META MI2S Playback",
  6253. .aif_name = "SEC_META_MI2S_RX",
  6254. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6255. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6256. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6257. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  6258. SNDRV_PCM_RATE_192000,
  6259. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  6260. .rate_min = 8000,
  6261. .rate_max = 192000,
  6262. },
  6263. .ops = &msm_dai_q6_meta_mi2s_ops,
  6264. .name = "Secondary META MI2S",
  6265. .id = AFE_PORT_ID_SECONDARY_META_MI2S_RX,
  6266. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6267. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6268. },
  6269. };
  6270. static int msm_dai_q6_meta_mi2s_platform_data_validation(
  6271. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  6272. {
  6273. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6274. dev_get_drvdata(&pdev->dev);
  6275. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  6276. (struct msm_meta_mi2s_pdata *) pdev->dev.platform_data;
  6277. int rc = 0;
  6278. int idx = 0;
  6279. u16 channel_mode = 0;
  6280. unsigned int ch_cnt = 0;
  6281. unsigned int ch_cnt_sum = 0;
  6282. struct afe_param_id_meta_i2s_cfg *port_cfg =
  6283. &dai_data->port_config.meta_i2s;
  6284. if (meta_mi2s_pdata == NULL) {
  6285. pr_err("%s: meta_mi2s_pdata NULL", __func__);
  6286. return -EINVAL;
  6287. }
  6288. dai_data->num_member_ports = meta_mi2s_pdata->num_member_ports;
  6289. for (idx = 0; idx < meta_mi2s_pdata->num_member_ports; idx++) {
  6290. rc = msm_dai_q6_mi2s_get_lineconfig(
  6291. meta_mi2s_pdata->sd_lines[idx],
  6292. &channel_mode,
  6293. &ch_cnt);
  6294. if (rc < 0) {
  6295. dev_err(&pdev->dev, "invalid META MI2S RX sd line config\n");
  6296. goto rtn;
  6297. }
  6298. if (ch_cnt) {
  6299. msm_mi2s_get_port_id(meta_mi2s_pdata->member_port[idx],
  6300. SNDRV_PCM_STREAM_PLAYBACK,
  6301. &dai_data->member_port_id[idx]);
  6302. dai_data->channel_mode[idx] = channel_mode;
  6303. port_cfg->member_port_id[idx] =
  6304. dai_data->member_port_id[idx];
  6305. port_cfg->member_port_channel_mode[idx] = channel_mode;
  6306. }
  6307. ch_cnt_sum += ch_cnt;
  6308. }
  6309. if (ch_cnt_sum) {
  6310. dai_driver->playback.channels_min = 1;
  6311. dai_driver->playback.channels_max = ch_cnt_sum << 1;
  6312. } else {
  6313. dai_driver->playback.channels_min = 0;
  6314. dai_driver->playback.channels_max = 0;
  6315. }
  6316. dev_dbg(&pdev->dev, "%s: sdline 0x%x 0x%x 0x%x 0x%x\n", __func__,
  6317. dai_data->channel_mode[0], dai_data->channel_mode[1],
  6318. dai_data->channel_mode[2], dai_data->channel_mode[3]);
  6319. dev_dbg(&pdev->dev, "%s: playback ch_max %d\n",
  6320. __func__, dai_driver->playback.channels_max);
  6321. rtn:
  6322. return rc;
  6323. }
  6324. static const struct snd_soc_component_driver msm_q6_meta_mi2s_dai_component = {
  6325. .name = "msm-dai-q6-meta-mi2s",
  6326. };
  6327. static int msm_dai_q6_meta_mi2s_dev_probe(struct platform_device *pdev)
  6328. {
  6329. struct msm_dai_q6_meta_mi2s_dai_data *dai_data;
  6330. const char *q6_meta_mi2s_dev_id = "qcom,msm-dai-q6-meta-mi2s-dev-id";
  6331. u32 dev_id = 0;
  6332. u32 meta_mi2s_intf = 0;
  6333. struct msm_meta_mi2s_pdata *meta_mi2s_pdata;
  6334. int rc;
  6335. rc = of_property_read_u32(pdev->dev.of_node, q6_meta_mi2s_dev_id,
  6336. &dev_id);
  6337. if (rc) {
  6338. dev_err(&pdev->dev,
  6339. "%s: missing %s in dt node\n", __func__,
  6340. q6_meta_mi2s_dev_id);
  6341. goto rtn;
  6342. }
  6343. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  6344. dev_id);
  6345. switch (dev_id) {
  6346. case AFE_PORT_ID_PRIMARY_META_MI2S_RX:
  6347. meta_mi2s_intf = 0;
  6348. break;
  6349. case AFE_PORT_ID_SECONDARY_META_MI2S_RX:
  6350. meta_mi2s_intf = 1;
  6351. break;
  6352. default:
  6353. dev_err(&pdev->dev,
  6354. "%s: Invalid META MI2S ID 0x%x from Device Tree\n",
  6355. __func__, dev_id);
  6356. rc = -ENXIO;
  6357. goto rtn;
  6358. }
  6359. pdev->id = dev_id;
  6360. meta_mi2s_pdata = kzalloc(sizeof(struct msm_meta_mi2s_pdata),
  6361. GFP_KERNEL);
  6362. if (!meta_mi2s_pdata) {
  6363. rc = -ENOMEM;
  6364. goto rtn;
  6365. }
  6366. rc = of_property_read_u32(pdev->dev.of_node,
  6367. "qcom,msm-mi2s-num-members",
  6368. &meta_mi2s_pdata->num_member_ports);
  6369. if (rc) {
  6370. dev_err(&pdev->dev, "%s: invalid num from DT file %s\n",
  6371. __func__, "qcom,msm-mi2s-num-members");
  6372. goto free_pdata;
  6373. }
  6374. if (meta_mi2s_pdata->num_member_ports >
  6375. MAX_NUM_I2S_META_PORT_MEMBER_PORTS) {
  6376. dev_err(&pdev->dev, "%s: num-members %d too large from DT file\n",
  6377. __func__, meta_mi2s_pdata->num_member_ports);
  6378. goto free_pdata;
  6379. }
  6380. rc = of_property_read_u32_array(pdev->dev.of_node,
  6381. "qcom,msm-mi2s-member-id",
  6382. meta_mi2s_pdata->member_port,
  6383. meta_mi2s_pdata->num_member_ports);
  6384. if (rc) {
  6385. dev_err(&pdev->dev, "%s: member-id from DT file %s\n",
  6386. __func__, "qcom,msm-mi2s-member-id");
  6387. goto free_pdata;
  6388. }
  6389. rc = of_property_read_u32_array(pdev->dev.of_node,
  6390. "qcom,msm-mi2s-rx-lines",
  6391. meta_mi2s_pdata->sd_lines,
  6392. meta_mi2s_pdata->num_member_ports);
  6393. if (rc) {
  6394. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n",
  6395. __func__, "qcom,msm-mi2s-rx-lines");
  6396. goto free_pdata;
  6397. }
  6398. dev_dbg(&pdev->dev, "dev name %s num-members=%d\n",
  6399. dev_name(&pdev->dev), meta_mi2s_pdata->num_member_ports);
  6400. dev_dbg(&pdev->dev, "member array (%d, %d, %d, %d)\n",
  6401. meta_mi2s_pdata->member_port[0],
  6402. meta_mi2s_pdata->member_port[1],
  6403. meta_mi2s_pdata->member_port[2],
  6404. meta_mi2s_pdata->member_port[3]);
  6405. dev_dbg(&pdev->dev, "sd-lines array (0x%x, 0x%x, 0x%x, 0x%x)\n",
  6406. meta_mi2s_pdata->sd_lines[0],
  6407. meta_mi2s_pdata->sd_lines[1],
  6408. meta_mi2s_pdata->sd_lines[2],
  6409. meta_mi2s_pdata->sd_lines[3]);
  6410. meta_mi2s_pdata->intf_id = meta_mi2s_intf;
  6411. dai_data = kzalloc(sizeof(struct msm_dai_q6_meta_mi2s_dai_data),
  6412. GFP_KERNEL);
  6413. if (!dai_data) {
  6414. rc = -ENOMEM;
  6415. goto free_pdata;
  6416. } else
  6417. dev_set_drvdata(&pdev->dev, dai_data);
  6418. pdev->dev.platform_data = meta_mi2s_pdata;
  6419. rc = msm_dai_q6_meta_mi2s_platform_data_validation(pdev,
  6420. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf]);
  6421. if (rc < 0)
  6422. goto free_dai_data;
  6423. rc = snd_soc_register_component(&pdev->dev,
  6424. &msm_q6_meta_mi2s_dai_component,
  6425. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf], 1);
  6426. if (rc < 0)
  6427. goto err_register;
  6428. return 0;
  6429. err_register:
  6430. dev_err(&pdev->dev, "fail to %s\n", __func__);
  6431. free_dai_data:
  6432. kfree(dai_data);
  6433. free_pdata:
  6434. kfree(meta_mi2s_pdata);
  6435. rtn:
  6436. return rc;
  6437. }
  6438. static int msm_dai_q6_meta_mi2s_dev_remove(struct platform_device *pdev)
  6439. {
  6440. snd_soc_unregister_component(&pdev->dev);
  6441. return 0;
  6442. }
  6443. static const struct snd_soc_component_driver msm_dai_q6_component = {
  6444. .name = "msm-dai-q6-dev",
  6445. };
  6446. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  6447. {
  6448. int rc, id, i, len;
  6449. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6450. char stream_name[80];
  6451. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6452. if (rc) {
  6453. dev_err(&pdev->dev,
  6454. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6455. return rc;
  6456. }
  6457. pdev->id = id;
  6458. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6459. dev_name(&pdev->dev), pdev->id);
  6460. switch (id) {
  6461. case SLIMBUS_0_RX:
  6462. strlcpy(stream_name, "Slimbus Playback", 80);
  6463. goto register_slim_playback;
  6464. case SLIMBUS_2_RX:
  6465. strlcpy(stream_name, "Slimbus2 Playback", 80);
  6466. goto register_slim_playback;
  6467. case SLIMBUS_1_RX:
  6468. strlcpy(stream_name, "Slimbus1 Playback", 80);
  6469. goto register_slim_playback;
  6470. case SLIMBUS_3_RX:
  6471. strlcpy(stream_name, "Slimbus3 Playback", 80);
  6472. goto register_slim_playback;
  6473. case SLIMBUS_4_RX:
  6474. strlcpy(stream_name, "Slimbus4 Playback", 80);
  6475. goto register_slim_playback;
  6476. case SLIMBUS_5_RX:
  6477. strlcpy(stream_name, "Slimbus5 Playback", 80);
  6478. goto register_slim_playback;
  6479. case SLIMBUS_6_RX:
  6480. strlcpy(stream_name, "Slimbus6 Playback", 80);
  6481. goto register_slim_playback;
  6482. case SLIMBUS_7_RX:
  6483. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  6484. goto register_slim_playback;
  6485. case SLIMBUS_8_RX:
  6486. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  6487. goto register_slim_playback;
  6488. case SLIMBUS_9_RX:
  6489. strlcpy(stream_name, "Slimbus9 Playback", sizeof(stream_name));
  6490. goto register_slim_playback;
  6491. register_slim_playback:
  6492. rc = -ENODEV;
  6493. len = strnlen(stream_name, 80);
  6494. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  6495. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  6496. !strcmp(stream_name,
  6497. msm_dai_q6_slimbus_rx_dai[i]
  6498. .playback.stream_name)) {
  6499. rc = snd_soc_register_component(&pdev->dev,
  6500. &msm_dai_q6_component,
  6501. &msm_dai_q6_slimbus_rx_dai[i], 1);
  6502. break;
  6503. }
  6504. }
  6505. if (rc)
  6506. pr_err("%s: Device not found stream name %s\n",
  6507. __func__, stream_name);
  6508. break;
  6509. case SLIMBUS_0_TX:
  6510. strlcpy(stream_name, "Slimbus Capture", 80);
  6511. goto register_slim_capture;
  6512. case SLIMBUS_1_TX:
  6513. strlcpy(stream_name, "Slimbus1 Capture", 80);
  6514. goto register_slim_capture;
  6515. case SLIMBUS_2_TX:
  6516. strlcpy(stream_name, "Slimbus2 Capture", 80);
  6517. goto register_slim_capture;
  6518. case SLIMBUS_3_TX:
  6519. strlcpy(stream_name, "Slimbus3 Capture", 80);
  6520. goto register_slim_capture;
  6521. case SLIMBUS_4_TX:
  6522. strlcpy(stream_name, "Slimbus4 Capture", 80);
  6523. goto register_slim_capture;
  6524. case SLIMBUS_5_TX:
  6525. strlcpy(stream_name, "Slimbus5 Capture", 80);
  6526. goto register_slim_capture;
  6527. case SLIMBUS_6_TX:
  6528. strlcpy(stream_name, "Slimbus6 Capture", 80);
  6529. goto register_slim_capture;
  6530. case SLIMBUS_7_TX:
  6531. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  6532. goto register_slim_capture;
  6533. case SLIMBUS_8_TX:
  6534. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  6535. goto register_slim_capture;
  6536. case SLIMBUS_9_TX:
  6537. strlcpy(stream_name, "Slimbus9 Capture", sizeof(stream_name));
  6538. goto register_slim_capture;
  6539. register_slim_capture:
  6540. rc = -ENODEV;
  6541. len = strnlen(stream_name, 80);
  6542. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  6543. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  6544. !strcmp(stream_name,
  6545. msm_dai_q6_slimbus_tx_dai[i]
  6546. .capture.stream_name)) {
  6547. rc = snd_soc_register_component(&pdev->dev,
  6548. &msm_dai_q6_component,
  6549. &msm_dai_q6_slimbus_tx_dai[i], 1);
  6550. break;
  6551. }
  6552. }
  6553. if (rc)
  6554. pr_err("%s: Device not found stream name %s\n",
  6555. __func__, stream_name);
  6556. break;
  6557. case AFE_LOOPBACK_TX:
  6558. rc = snd_soc_register_component(&pdev->dev,
  6559. &msm_dai_q6_component,
  6560. &msm_dai_q6_afe_lb_tx_dai[0],
  6561. 1);
  6562. break;
  6563. case INT_BT_SCO_RX:
  6564. rc = snd_soc_register_component(&pdev->dev,
  6565. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  6566. break;
  6567. case INT_BT_SCO_TX:
  6568. rc = snd_soc_register_component(&pdev->dev,
  6569. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  6570. break;
  6571. case INT_BT_A2DP_RX:
  6572. rc = snd_soc_register_component(&pdev->dev,
  6573. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  6574. break;
  6575. case INT_FM_RX:
  6576. rc = snd_soc_register_component(&pdev->dev,
  6577. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  6578. break;
  6579. case INT_FM_TX:
  6580. rc = snd_soc_register_component(&pdev->dev,
  6581. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  6582. break;
  6583. case AFE_PORT_ID_USB_RX:
  6584. rc = snd_soc_register_component(&pdev->dev,
  6585. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  6586. break;
  6587. case AFE_PORT_ID_USB_TX:
  6588. rc = snd_soc_register_component(&pdev->dev,
  6589. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  6590. break;
  6591. case RT_PROXY_DAI_001_RX:
  6592. strlcpy(stream_name, "AFE Playback", 80);
  6593. goto register_afe_playback;
  6594. case RT_PROXY_DAI_002_RX:
  6595. strlcpy(stream_name, "AFE-PROXY RX", 80);
  6596. register_afe_playback:
  6597. rc = -ENODEV;
  6598. len = strnlen(stream_name, 80);
  6599. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  6600. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  6601. !strcmp(stream_name,
  6602. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  6603. rc = snd_soc_register_component(&pdev->dev,
  6604. &msm_dai_q6_component,
  6605. &msm_dai_q6_afe_rx_dai[i], 1);
  6606. break;
  6607. }
  6608. }
  6609. if (rc)
  6610. pr_err("%s: Device not found stream name %s\n",
  6611. __func__, stream_name);
  6612. break;
  6613. case RT_PROXY_DAI_001_TX:
  6614. strlcpy(stream_name, "AFE-PROXY TX", 80);
  6615. goto register_afe_capture;
  6616. case RT_PROXY_DAI_002_TX:
  6617. strlcpy(stream_name, "AFE Capture", 80);
  6618. register_afe_capture:
  6619. rc = -ENODEV;
  6620. len = strnlen(stream_name, 80);
  6621. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  6622. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  6623. !strcmp(stream_name,
  6624. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  6625. rc = snd_soc_register_component(&pdev->dev,
  6626. &msm_dai_q6_component,
  6627. &msm_dai_q6_afe_tx_dai[i], 1);
  6628. break;
  6629. }
  6630. }
  6631. if (rc)
  6632. pr_err("%s: Device not found stream name %s\n",
  6633. __func__, stream_name);
  6634. break;
  6635. case VOICE_PLAYBACK_TX:
  6636. strlcpy(stream_name, "Voice Farend Playback", 80);
  6637. goto register_voice_playback;
  6638. case VOICE2_PLAYBACK_TX:
  6639. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  6640. register_voice_playback:
  6641. rc = -ENODEV;
  6642. len = strnlen(stream_name, 80);
  6643. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  6644. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  6645. && !strcmp(stream_name,
  6646. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  6647. rc = snd_soc_register_component(&pdev->dev,
  6648. &msm_dai_q6_component,
  6649. &msm_dai_q6_voc_playback_dai[i], 1);
  6650. break;
  6651. }
  6652. }
  6653. if (rc)
  6654. pr_err("%s Device not found stream name %s\n",
  6655. __func__, stream_name);
  6656. break;
  6657. case VOICE_RECORD_RX:
  6658. strlcpy(stream_name, "Voice Downlink Capture", 80);
  6659. goto register_uplink_capture;
  6660. case VOICE_RECORD_TX:
  6661. strlcpy(stream_name, "Voice Uplink Capture", 80);
  6662. register_uplink_capture:
  6663. rc = -ENODEV;
  6664. len = strnlen(stream_name, 80);
  6665. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  6666. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  6667. && !strcmp(stream_name,
  6668. msm_dai_q6_incall_record_dai[i].
  6669. capture.stream_name)) {
  6670. rc = snd_soc_register_component(&pdev->dev,
  6671. &msm_dai_q6_component,
  6672. &msm_dai_q6_incall_record_dai[i], 1);
  6673. break;
  6674. }
  6675. }
  6676. if (rc)
  6677. pr_err("%s: Device not found stream name %s\n",
  6678. __func__, stream_name);
  6679. break;
  6680. default:
  6681. rc = -ENODEV;
  6682. break;
  6683. }
  6684. return rc;
  6685. }
  6686. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  6687. {
  6688. snd_soc_unregister_component(&pdev->dev);
  6689. return 0;
  6690. }
  6691. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  6692. { .compatible = "qcom,msm-dai-q6-dev", },
  6693. { }
  6694. };
  6695. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  6696. static struct platform_driver msm_dai_q6_dev = {
  6697. .probe = msm_dai_q6_dev_probe,
  6698. .remove = msm_dai_q6_dev_remove,
  6699. .driver = {
  6700. .name = "msm-dai-q6-dev",
  6701. .owner = THIS_MODULE,
  6702. .of_match_table = msm_dai_q6_dev_dt_match,
  6703. .suppress_bind_attrs = true,
  6704. },
  6705. };
  6706. static int msm_dai_q6_probe(struct platform_device *pdev)
  6707. {
  6708. int rc;
  6709. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6710. dev_name(&pdev->dev), pdev->id);
  6711. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6712. if (rc) {
  6713. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6714. __func__, rc);
  6715. } else
  6716. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6717. return rc;
  6718. }
  6719. static int msm_dai_q6_remove(struct platform_device *pdev)
  6720. {
  6721. of_platform_depopulate(&pdev->dev);
  6722. return 0;
  6723. }
  6724. static const struct of_device_id msm_dai_q6_dt_match[] = {
  6725. { .compatible = "qcom,msm-dai-q6", },
  6726. { }
  6727. };
  6728. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  6729. static struct platform_driver msm_dai_q6 = {
  6730. .probe = msm_dai_q6_probe,
  6731. .remove = msm_dai_q6_remove,
  6732. .driver = {
  6733. .name = "msm-dai-q6",
  6734. .owner = THIS_MODULE,
  6735. .of_match_table = msm_dai_q6_dt_match,
  6736. .suppress_bind_attrs = true,
  6737. },
  6738. };
  6739. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  6740. {
  6741. int rc;
  6742. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6743. if (rc) {
  6744. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6745. __func__, rc);
  6746. } else
  6747. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6748. return rc;
  6749. }
  6750. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  6751. {
  6752. return 0;
  6753. }
  6754. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  6755. { .compatible = "qcom,msm-dai-mi2s", },
  6756. { }
  6757. };
  6758. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  6759. static struct platform_driver msm_dai_mi2s_q6 = {
  6760. .probe = msm_dai_mi2s_q6_probe,
  6761. .remove = msm_dai_mi2s_q6_remove,
  6762. .driver = {
  6763. .name = "msm-dai-mi2s",
  6764. .owner = THIS_MODULE,
  6765. .of_match_table = msm_dai_mi2s_dt_match,
  6766. .suppress_bind_attrs = true,
  6767. },
  6768. };
  6769. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  6770. { .compatible = "qcom,msm-dai-q6-mi2s", },
  6771. { }
  6772. };
  6773. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  6774. static struct platform_driver msm_dai_q6_mi2s_driver = {
  6775. .probe = msm_dai_q6_mi2s_dev_probe,
  6776. .remove = msm_dai_q6_mi2s_dev_remove,
  6777. .driver = {
  6778. .name = "msm-dai-q6-mi2s",
  6779. .owner = THIS_MODULE,
  6780. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  6781. .suppress_bind_attrs = true,
  6782. },
  6783. };
  6784. static const struct of_device_id msm_dai_q6_meta_mi2s_dev_dt_match[] = {
  6785. { .compatible = "qcom,msm-dai-q6-meta-mi2s", },
  6786. { }
  6787. };
  6788. MODULE_DEVICE_TABLE(of, msm_dai_q6_meta_mi2s_dev_dt_match);
  6789. static struct platform_driver msm_dai_q6_meta_mi2s_driver = {
  6790. .probe = msm_dai_q6_meta_mi2s_dev_probe,
  6791. .remove = msm_dai_q6_meta_mi2s_dev_remove,
  6792. .driver = {
  6793. .name = "msm-dai-q6-meta-mi2s",
  6794. .owner = THIS_MODULE,
  6795. .of_match_table = msm_dai_q6_meta_mi2s_dev_dt_match,
  6796. .suppress_bind_attrs = true,
  6797. },
  6798. };
  6799. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  6800. {
  6801. int rc, id;
  6802. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6803. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6804. if (rc) {
  6805. dev_err(&pdev->dev,
  6806. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6807. return rc;
  6808. }
  6809. pdev->id = id;
  6810. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6811. dev_name(&pdev->dev), pdev->id);
  6812. switch (pdev->id) {
  6813. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  6814. rc = snd_soc_register_component(&pdev->dev,
  6815. &msm_dai_spdif_q6_component,
  6816. &msm_dai_q6_spdif_spdif_rx_dai[0], 1);
  6817. break;
  6818. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  6819. rc = snd_soc_register_component(&pdev->dev,
  6820. &msm_dai_spdif_q6_component,
  6821. &msm_dai_q6_spdif_spdif_rx_dai[1], 1);
  6822. break;
  6823. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  6824. rc = snd_soc_register_component(&pdev->dev,
  6825. &msm_dai_spdif_q6_component,
  6826. &msm_dai_q6_spdif_spdif_tx_dai[0], 1);
  6827. break;
  6828. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  6829. rc = snd_soc_register_component(&pdev->dev,
  6830. &msm_dai_spdif_q6_component,
  6831. &msm_dai_q6_spdif_spdif_tx_dai[1], 1);
  6832. break;
  6833. default:
  6834. dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
  6835. rc = -ENODEV;
  6836. break;
  6837. }
  6838. return rc;
  6839. }
  6840. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  6841. {
  6842. snd_soc_unregister_component(&pdev->dev);
  6843. return 0;
  6844. }
  6845. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  6846. {.compatible = "qcom,msm-dai-q6-spdif"},
  6847. {}
  6848. };
  6849. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  6850. static struct platform_driver msm_dai_q6_spdif_driver = {
  6851. .probe = msm_dai_q6_spdif_dev_probe,
  6852. .remove = msm_dai_q6_spdif_dev_remove,
  6853. .driver = {
  6854. .name = "msm-dai-q6-spdif",
  6855. .owner = THIS_MODULE,
  6856. .of_match_table = msm_dai_q6_spdif_dt_match,
  6857. .suppress_bind_attrs = true,
  6858. },
  6859. };
  6860. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  6861. struct afe_clk_set *clk_set, u32 mode)
  6862. {
  6863. switch (group_id) {
  6864. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  6865. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  6866. if (mode)
  6867. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  6868. else
  6869. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  6870. break;
  6871. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  6872. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  6873. if (mode)
  6874. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  6875. else
  6876. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  6877. break;
  6878. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  6879. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  6880. if (mode)
  6881. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  6882. else
  6883. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  6884. break;
  6885. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  6886. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  6887. if (mode)
  6888. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  6889. else
  6890. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  6891. break;
  6892. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  6893. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  6894. if (mode)
  6895. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  6896. else
  6897. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  6898. break;
  6899. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  6900. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  6901. if (mode)
  6902. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_IBIT;
  6903. else
  6904. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_EBIT;
  6905. break;
  6906. default:
  6907. return -EINVAL;
  6908. }
  6909. return 0;
  6910. }
  6911. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  6912. {
  6913. int rc = 0;
  6914. const uint32_t *port_id_array = NULL;
  6915. uint32_t array_length = 0;
  6916. int i = 0;
  6917. int group_idx = 0;
  6918. u32 clk_mode = 0;
  6919. /* extract tdm group info into static */
  6920. rc = of_property_read_u32(pdev->dev.of_node,
  6921. "qcom,msm-cpudai-tdm-group-id",
  6922. (u32 *)&tdm_group_cfg.group_id);
  6923. if (rc) {
  6924. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  6925. __func__, "qcom,msm-cpudai-tdm-group-id");
  6926. goto rtn;
  6927. }
  6928. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  6929. __func__, tdm_group_cfg.group_id);
  6930. rc = of_property_read_u32(pdev->dev.of_node,
  6931. "qcom,msm-cpudai-tdm-group-num-ports",
  6932. &num_tdm_group_ports);
  6933. if (rc) {
  6934. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  6935. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  6936. goto rtn;
  6937. }
  6938. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  6939. __func__, num_tdm_group_ports);
  6940. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  6941. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  6942. __func__, num_tdm_group_ports,
  6943. AFE_GROUP_DEVICE_NUM_PORTS);
  6944. rc = -EINVAL;
  6945. goto rtn;
  6946. }
  6947. port_id_array = of_get_property(pdev->dev.of_node,
  6948. "qcom,msm-cpudai-tdm-group-port-id",
  6949. &array_length);
  6950. if (port_id_array == NULL) {
  6951. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  6952. __func__);
  6953. rc = -EINVAL;
  6954. goto rtn;
  6955. }
  6956. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  6957. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  6958. __func__, array_length,
  6959. sizeof(uint32_t) * num_tdm_group_ports);
  6960. rc = -EINVAL;
  6961. goto rtn;
  6962. }
  6963. for (i = 0; i < num_tdm_group_ports; i++)
  6964. tdm_group_cfg.port_id[i] =
  6965. (u16)be32_to_cpu(port_id_array[i]);
  6966. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  6967. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  6968. tdm_group_cfg.port_id[i] =
  6969. AFE_PORT_INVALID;
  6970. /* extract tdm clk info into static */
  6971. rc = of_property_read_u32(pdev->dev.of_node,
  6972. "qcom,msm-cpudai-tdm-clk-rate",
  6973. &tdm_clk_set.clk_freq_in_hz);
  6974. if (rc) {
  6975. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  6976. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  6977. goto rtn;
  6978. }
  6979. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  6980. __func__, tdm_clk_set.clk_freq_in_hz);
  6981. /* initialize static tdm clk attribute to default value */
  6982. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  6983. /* extract tdm clk attribute into static */
  6984. if (of_find_property(pdev->dev.of_node,
  6985. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  6986. rc = of_property_read_u16(pdev->dev.of_node,
  6987. "qcom,msm-cpudai-tdm-clk-attribute",
  6988. &tdm_clk_set.clk_attri);
  6989. if (rc) {
  6990. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  6991. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  6992. goto rtn;
  6993. }
  6994. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  6995. __func__, tdm_clk_set.clk_attri);
  6996. } else
  6997. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  6998. /* extract tdm lane cfg to static */
  6999. tdm_lane_cfg.port_id = tdm_group_cfg.group_id;
  7000. tdm_lane_cfg.lane_mask = AFE_LANE_MASK_INVALID;
  7001. if (of_find_property(pdev->dev.of_node,
  7002. "qcom,msm-cpudai-tdm-lane-mask", NULL)) {
  7003. rc = of_property_read_u16(pdev->dev.of_node,
  7004. "qcom,msm-cpudai-tdm-lane-mask",
  7005. &tdm_lane_cfg.lane_mask);
  7006. if (rc) {
  7007. dev_err(&pdev->dev, "%s: value for tdm lane mask not found %s\n",
  7008. __func__, "qcom,msm-cpudai-tdm-lane-mask");
  7009. goto rtn;
  7010. }
  7011. dev_dbg(&pdev->dev, "%s: tdm lane mask from DT file %d\n",
  7012. __func__, tdm_lane_cfg.lane_mask);
  7013. } else
  7014. dev_dbg(&pdev->dev, "%s: tdm lane mask not found\n", __func__);
  7015. /* extract tdm clk src master/slave info into static */
  7016. rc = of_property_read_u32(pdev->dev.of_node,
  7017. "qcom,msm-cpudai-tdm-clk-internal",
  7018. &clk_mode);
  7019. if (rc) {
  7020. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  7021. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  7022. goto rtn;
  7023. }
  7024. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  7025. __func__, clk_mode);
  7026. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  7027. &tdm_clk_set, clk_mode);
  7028. if (rc) {
  7029. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  7030. __func__, tdm_group_cfg.group_id);
  7031. goto rtn;
  7032. }
  7033. /* other initializations within device group */
  7034. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  7035. if (group_idx < 0) {
  7036. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  7037. __func__, tdm_group_cfg.group_id);
  7038. rc = -EINVAL;
  7039. goto rtn;
  7040. }
  7041. atomic_set(&tdm_group_ref[group_idx], 0);
  7042. /* probe child node info */
  7043. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  7044. if (rc) {
  7045. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  7046. __func__, rc);
  7047. goto rtn;
  7048. } else
  7049. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  7050. rtn:
  7051. return rc;
  7052. }
  7053. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  7054. {
  7055. return 0;
  7056. }
  7057. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  7058. { .compatible = "qcom,msm-dai-tdm", },
  7059. {}
  7060. };
  7061. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  7062. static struct platform_driver msm_dai_tdm_q6 = {
  7063. .probe = msm_dai_tdm_q6_probe,
  7064. .remove = msm_dai_tdm_q6_remove,
  7065. .driver = {
  7066. .name = "msm-dai-tdm",
  7067. .owner = THIS_MODULE,
  7068. .of_match_table = msm_dai_tdm_dt_match,
  7069. .suppress_bind_attrs = true,
  7070. },
  7071. };
  7072. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  7073. struct snd_ctl_elem_value *ucontrol)
  7074. {
  7075. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7076. int value = ucontrol->value.integer.value[0];
  7077. switch (value) {
  7078. case 0:
  7079. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  7080. break;
  7081. case 1:
  7082. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  7083. break;
  7084. case 2:
  7085. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  7086. break;
  7087. default:
  7088. pr_err("%s: data_format invalid\n", __func__);
  7089. break;
  7090. }
  7091. pr_debug("%s: data_format = %d\n",
  7092. __func__, dai_data->port_cfg.tdm.data_format);
  7093. return 0;
  7094. }
  7095. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  7096. struct snd_ctl_elem_value *ucontrol)
  7097. {
  7098. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7099. ucontrol->value.integer.value[0] =
  7100. dai_data->port_cfg.tdm.data_format;
  7101. pr_debug("%s: data_format = %d\n",
  7102. __func__, dai_data->port_cfg.tdm.data_format);
  7103. return 0;
  7104. }
  7105. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  7106. struct snd_ctl_elem_value *ucontrol)
  7107. {
  7108. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7109. int value = ucontrol->value.integer.value[0];
  7110. dai_data->port_cfg.custom_tdm_header.header_type = value;
  7111. pr_debug("%s: header_type = %d\n",
  7112. __func__,
  7113. dai_data->port_cfg.custom_tdm_header.header_type);
  7114. return 0;
  7115. }
  7116. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  7117. struct snd_ctl_elem_value *ucontrol)
  7118. {
  7119. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7120. ucontrol->value.integer.value[0] =
  7121. dai_data->port_cfg.custom_tdm_header.header_type;
  7122. pr_debug("%s: header_type = %d\n",
  7123. __func__,
  7124. dai_data->port_cfg.custom_tdm_header.header_type);
  7125. return 0;
  7126. }
  7127. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  7128. struct snd_ctl_elem_value *ucontrol)
  7129. {
  7130. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7131. int i = 0;
  7132. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7133. dai_data->port_cfg.custom_tdm_header.header[i] =
  7134. (u16)ucontrol->value.integer.value[i];
  7135. pr_debug("%s: header #%d = 0x%x\n",
  7136. __func__, i,
  7137. dai_data->port_cfg.custom_tdm_header.header[i]);
  7138. }
  7139. return 0;
  7140. }
  7141. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  7142. struct snd_ctl_elem_value *ucontrol)
  7143. {
  7144. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7145. int i = 0;
  7146. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7147. ucontrol->value.integer.value[i] =
  7148. dai_data->port_cfg.custom_tdm_header.header[i];
  7149. pr_debug("%s: header #%d = 0x%x\n",
  7150. __func__, i,
  7151. dai_data->port_cfg.custom_tdm_header.header[i]);
  7152. }
  7153. return 0;
  7154. }
  7155. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  7156. SOC_ENUM_EXT("PRI_TDM_RX_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("PRI_TDM_TX_5 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("PRI_TDM_TX_6 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("PRI_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("SEC_TDM_TX_5 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("SEC_TDM_TX_6 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("SEC_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("TERT_TDM_TX_5 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("TERT_TDM_TX_6 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("TERT_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("QUAT_TDM_TX_5 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("QUAT_TDM_TX_6 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("QUAT_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("QUIN_TDM_TX_5 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("QUIN_TDM_TX_6 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("QUIN_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 Data Format", tdm_config_enum[0],
  7433. msm_dai_q6_tdm_data_format_get,
  7434. msm_dai_q6_tdm_data_format_put),
  7435. SOC_ENUM_EXT("SEN_TDM_TX_5 Data Format", tdm_config_enum[0],
  7436. msm_dai_q6_tdm_data_format_get,
  7437. msm_dai_q6_tdm_data_format_put),
  7438. SOC_ENUM_EXT("SEN_TDM_TX_6 Data Format", tdm_config_enum[0],
  7439. msm_dai_q6_tdm_data_format_get,
  7440. msm_dai_q6_tdm_data_format_put),
  7441. SOC_ENUM_EXT("SEN_TDM_TX_7 Data Format", tdm_config_enum[0],
  7442. msm_dai_q6_tdm_data_format_get,
  7443. msm_dai_q6_tdm_data_format_put),
  7444. };
  7445. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  7446. SOC_ENUM_EXT("PRI_TDM_RX_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("PRI_TDM_TX_5 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("PRI_TDM_TX_6 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("PRI_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("SEC_TDM_TX_5 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("SEC_TDM_TX_6 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("SEC_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("TERT_TDM_TX_5 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("TERT_TDM_TX_6 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("TERT_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("QUAT_TDM_TX_5 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("QUAT_TDM_TX_6 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("QUAT_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 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("QUIN_TDM_TX_5 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("QUIN_TDM_TX_6 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("QUIN_TDM_TX_7 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_0 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_1 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_2 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_3 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_4 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_RX_5 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_RX_6 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_RX_7 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_0 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_1 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_2 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_3 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_4 Header Type", tdm_config_enum[1],
  7723. msm_dai_q6_tdm_header_type_get,
  7724. msm_dai_q6_tdm_header_type_put),
  7725. SOC_ENUM_EXT("SEN_TDM_TX_5 Header Type", tdm_config_enum[1],
  7726. msm_dai_q6_tdm_header_type_get,
  7727. msm_dai_q6_tdm_header_type_put),
  7728. SOC_ENUM_EXT("SEN_TDM_TX_6 Header Type", tdm_config_enum[1],
  7729. msm_dai_q6_tdm_header_type_get,
  7730. msm_dai_q6_tdm_header_type_put),
  7731. SOC_ENUM_EXT("SEN_TDM_TX_7 Header Type", tdm_config_enum[1],
  7732. msm_dai_q6_tdm_header_type_get,
  7733. msm_dai_q6_tdm_header_type_put),
  7734. };
  7735. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  7736. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  7737. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7738. msm_dai_q6_tdm_header_get,
  7739. msm_dai_q6_tdm_header_put),
  7740. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  7741. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7742. msm_dai_q6_tdm_header_get,
  7743. msm_dai_q6_tdm_header_put),
  7744. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  7745. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7746. msm_dai_q6_tdm_header_get,
  7747. msm_dai_q6_tdm_header_put),
  7748. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  7749. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7750. msm_dai_q6_tdm_header_get,
  7751. msm_dai_q6_tdm_header_put),
  7752. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  7753. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7754. msm_dai_q6_tdm_header_get,
  7755. msm_dai_q6_tdm_header_put),
  7756. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  7757. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7758. msm_dai_q6_tdm_header_get,
  7759. msm_dai_q6_tdm_header_put),
  7760. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  7761. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7762. msm_dai_q6_tdm_header_get,
  7763. msm_dai_q6_tdm_header_put),
  7764. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  7765. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7766. msm_dai_q6_tdm_header_get,
  7767. msm_dai_q6_tdm_header_put),
  7768. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  7769. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7770. msm_dai_q6_tdm_header_get,
  7771. msm_dai_q6_tdm_header_put),
  7772. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  7773. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7774. msm_dai_q6_tdm_header_get,
  7775. msm_dai_q6_tdm_header_put),
  7776. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  7777. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7778. msm_dai_q6_tdm_header_get,
  7779. msm_dai_q6_tdm_header_put),
  7780. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  7781. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7782. msm_dai_q6_tdm_header_get,
  7783. msm_dai_q6_tdm_header_put),
  7784. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  7785. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7786. msm_dai_q6_tdm_header_get,
  7787. msm_dai_q6_tdm_header_put),
  7788. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  7789. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7790. msm_dai_q6_tdm_header_get,
  7791. msm_dai_q6_tdm_header_put),
  7792. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  7793. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7794. msm_dai_q6_tdm_header_get,
  7795. msm_dai_q6_tdm_header_put),
  7796. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  7797. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7798. msm_dai_q6_tdm_header_get,
  7799. msm_dai_q6_tdm_header_put),
  7800. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  7801. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7802. msm_dai_q6_tdm_header_get,
  7803. msm_dai_q6_tdm_header_put),
  7804. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  7805. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7806. msm_dai_q6_tdm_header_get,
  7807. msm_dai_q6_tdm_header_put),
  7808. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  7809. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7810. msm_dai_q6_tdm_header_get,
  7811. msm_dai_q6_tdm_header_put),
  7812. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  7813. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7814. msm_dai_q6_tdm_header_get,
  7815. msm_dai_q6_tdm_header_put),
  7816. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  7817. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7818. msm_dai_q6_tdm_header_get,
  7819. msm_dai_q6_tdm_header_put),
  7820. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  7821. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7822. msm_dai_q6_tdm_header_get,
  7823. msm_dai_q6_tdm_header_put),
  7824. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  7825. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7826. msm_dai_q6_tdm_header_get,
  7827. msm_dai_q6_tdm_header_put),
  7828. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  7829. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7830. msm_dai_q6_tdm_header_get,
  7831. msm_dai_q6_tdm_header_put),
  7832. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  7833. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7834. msm_dai_q6_tdm_header_get,
  7835. msm_dai_q6_tdm_header_put),
  7836. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  7837. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7838. msm_dai_q6_tdm_header_get,
  7839. msm_dai_q6_tdm_header_put),
  7840. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  7841. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7842. msm_dai_q6_tdm_header_get,
  7843. msm_dai_q6_tdm_header_put),
  7844. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  7845. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7846. msm_dai_q6_tdm_header_get,
  7847. msm_dai_q6_tdm_header_put),
  7848. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  7849. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7850. msm_dai_q6_tdm_header_get,
  7851. msm_dai_q6_tdm_header_put),
  7852. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  7853. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7854. msm_dai_q6_tdm_header_get,
  7855. msm_dai_q6_tdm_header_put),
  7856. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  7857. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7858. msm_dai_q6_tdm_header_get,
  7859. msm_dai_q6_tdm_header_put),
  7860. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  7861. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7862. msm_dai_q6_tdm_header_get,
  7863. msm_dai_q6_tdm_header_put),
  7864. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  7865. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7866. msm_dai_q6_tdm_header_get,
  7867. msm_dai_q6_tdm_header_put),
  7868. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  7869. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7870. msm_dai_q6_tdm_header_get,
  7871. msm_dai_q6_tdm_header_put),
  7872. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  7873. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7874. msm_dai_q6_tdm_header_get,
  7875. msm_dai_q6_tdm_header_put),
  7876. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  7877. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7878. msm_dai_q6_tdm_header_get,
  7879. msm_dai_q6_tdm_header_put),
  7880. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  7881. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7882. msm_dai_q6_tdm_header_get,
  7883. msm_dai_q6_tdm_header_put),
  7884. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  7885. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7886. msm_dai_q6_tdm_header_get,
  7887. msm_dai_q6_tdm_header_put),
  7888. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  7889. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7890. msm_dai_q6_tdm_header_get,
  7891. msm_dai_q6_tdm_header_put),
  7892. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  7893. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7894. msm_dai_q6_tdm_header_get,
  7895. msm_dai_q6_tdm_header_put),
  7896. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  7897. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7898. msm_dai_q6_tdm_header_get,
  7899. msm_dai_q6_tdm_header_put),
  7900. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  7901. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7902. msm_dai_q6_tdm_header_get,
  7903. msm_dai_q6_tdm_header_put),
  7904. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  7905. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7906. msm_dai_q6_tdm_header_get,
  7907. msm_dai_q6_tdm_header_put),
  7908. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  7909. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7910. msm_dai_q6_tdm_header_get,
  7911. msm_dai_q6_tdm_header_put),
  7912. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  7913. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7914. msm_dai_q6_tdm_header_get,
  7915. msm_dai_q6_tdm_header_put),
  7916. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  7917. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7918. msm_dai_q6_tdm_header_get,
  7919. msm_dai_q6_tdm_header_put),
  7920. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  7921. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7922. msm_dai_q6_tdm_header_get,
  7923. msm_dai_q6_tdm_header_put),
  7924. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  7925. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7926. msm_dai_q6_tdm_header_get,
  7927. msm_dai_q6_tdm_header_put),
  7928. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  7929. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7930. msm_dai_q6_tdm_header_get,
  7931. msm_dai_q6_tdm_header_put),
  7932. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  7933. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7934. msm_dai_q6_tdm_header_get,
  7935. msm_dai_q6_tdm_header_put),
  7936. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  7937. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7938. msm_dai_q6_tdm_header_get,
  7939. msm_dai_q6_tdm_header_put),
  7940. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  7941. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7942. msm_dai_q6_tdm_header_get,
  7943. msm_dai_q6_tdm_header_put),
  7944. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  7945. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7946. msm_dai_q6_tdm_header_get,
  7947. msm_dai_q6_tdm_header_put),
  7948. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  7949. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7950. msm_dai_q6_tdm_header_get,
  7951. msm_dai_q6_tdm_header_put),
  7952. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  7953. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7954. msm_dai_q6_tdm_header_get,
  7955. msm_dai_q6_tdm_header_put),
  7956. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  7957. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7958. msm_dai_q6_tdm_header_get,
  7959. msm_dai_q6_tdm_header_put),
  7960. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  7961. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7962. msm_dai_q6_tdm_header_get,
  7963. msm_dai_q6_tdm_header_put),
  7964. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  7965. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7966. msm_dai_q6_tdm_header_get,
  7967. msm_dai_q6_tdm_header_put),
  7968. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  7969. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7970. msm_dai_q6_tdm_header_get,
  7971. msm_dai_q6_tdm_header_put),
  7972. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  7973. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7974. msm_dai_q6_tdm_header_get,
  7975. msm_dai_q6_tdm_header_put),
  7976. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  7977. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7978. msm_dai_q6_tdm_header_get,
  7979. msm_dai_q6_tdm_header_put),
  7980. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  7981. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7982. msm_dai_q6_tdm_header_get,
  7983. msm_dai_q6_tdm_header_put),
  7984. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  7985. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7986. msm_dai_q6_tdm_header_get,
  7987. msm_dai_q6_tdm_header_put),
  7988. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  7989. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7990. msm_dai_q6_tdm_header_get,
  7991. msm_dai_q6_tdm_header_put),
  7992. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  7993. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7994. msm_dai_q6_tdm_header_get,
  7995. msm_dai_q6_tdm_header_put),
  7996. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  7997. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7998. msm_dai_q6_tdm_header_get,
  7999. msm_dai_q6_tdm_header_put),
  8000. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  8001. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8002. msm_dai_q6_tdm_header_get,
  8003. msm_dai_q6_tdm_header_put),
  8004. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  8005. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8006. msm_dai_q6_tdm_header_get,
  8007. msm_dai_q6_tdm_header_put),
  8008. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  8009. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8010. msm_dai_q6_tdm_header_get,
  8011. msm_dai_q6_tdm_header_put),
  8012. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  8013. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8014. msm_dai_q6_tdm_header_get,
  8015. msm_dai_q6_tdm_header_put),
  8016. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  8017. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8018. msm_dai_q6_tdm_header_get,
  8019. msm_dai_q6_tdm_header_put),
  8020. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  8021. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8022. msm_dai_q6_tdm_header_get,
  8023. msm_dai_q6_tdm_header_put),
  8024. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  8025. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8026. msm_dai_q6_tdm_header_get,
  8027. msm_dai_q6_tdm_header_put),
  8028. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  8029. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8030. msm_dai_q6_tdm_header_get,
  8031. msm_dai_q6_tdm_header_put),
  8032. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  8033. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8034. msm_dai_q6_tdm_header_get,
  8035. msm_dai_q6_tdm_header_put),
  8036. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  8037. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8038. msm_dai_q6_tdm_header_get,
  8039. msm_dai_q6_tdm_header_put),
  8040. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  8041. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8042. msm_dai_q6_tdm_header_get,
  8043. msm_dai_q6_tdm_header_put),
  8044. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  8045. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8046. msm_dai_q6_tdm_header_get,
  8047. msm_dai_q6_tdm_header_put),
  8048. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  8049. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8050. msm_dai_q6_tdm_header_get,
  8051. msm_dai_q6_tdm_header_put),
  8052. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  8053. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8054. msm_dai_q6_tdm_header_get,
  8055. msm_dai_q6_tdm_header_put),
  8056. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_0 Header",
  8057. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8058. msm_dai_q6_tdm_header_get,
  8059. msm_dai_q6_tdm_header_put),
  8060. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_1 Header",
  8061. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8062. msm_dai_q6_tdm_header_get,
  8063. msm_dai_q6_tdm_header_put),
  8064. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_2 Header",
  8065. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8066. msm_dai_q6_tdm_header_get,
  8067. msm_dai_q6_tdm_header_put),
  8068. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_3 Header",
  8069. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8070. msm_dai_q6_tdm_header_get,
  8071. msm_dai_q6_tdm_header_put),
  8072. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_4 Header",
  8073. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8074. msm_dai_q6_tdm_header_get,
  8075. msm_dai_q6_tdm_header_put),
  8076. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_5 Header",
  8077. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8078. msm_dai_q6_tdm_header_get,
  8079. msm_dai_q6_tdm_header_put),
  8080. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_6 Header",
  8081. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8082. msm_dai_q6_tdm_header_get,
  8083. msm_dai_q6_tdm_header_put),
  8084. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_7 Header",
  8085. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8086. msm_dai_q6_tdm_header_get,
  8087. msm_dai_q6_tdm_header_put),
  8088. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_0 Header",
  8089. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8090. msm_dai_q6_tdm_header_get,
  8091. msm_dai_q6_tdm_header_put),
  8092. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_1 Header",
  8093. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8094. msm_dai_q6_tdm_header_get,
  8095. msm_dai_q6_tdm_header_put),
  8096. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_2 Header",
  8097. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8098. msm_dai_q6_tdm_header_get,
  8099. msm_dai_q6_tdm_header_put),
  8100. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_3 Header",
  8101. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8102. msm_dai_q6_tdm_header_get,
  8103. msm_dai_q6_tdm_header_put),
  8104. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_4 Header",
  8105. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8106. msm_dai_q6_tdm_header_get,
  8107. msm_dai_q6_tdm_header_put),
  8108. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_5 Header",
  8109. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8110. msm_dai_q6_tdm_header_get,
  8111. msm_dai_q6_tdm_header_put),
  8112. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_6 Header",
  8113. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8114. msm_dai_q6_tdm_header_get,
  8115. msm_dai_q6_tdm_header_put),
  8116. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_7 Header",
  8117. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8118. msm_dai_q6_tdm_header_get,
  8119. msm_dai_q6_tdm_header_put),
  8120. };
  8121. static int msm_dai_q6_tdm_set_clk(
  8122. struct msm_dai_q6_tdm_dai_data *dai_data,
  8123. u16 port_id, bool enable)
  8124. {
  8125. int rc = 0;
  8126. dai_data->clk_set.enable = enable;
  8127. rc = afe_set_lpass_clock_v2(port_id,
  8128. &dai_data->clk_set);
  8129. if (rc < 0)
  8130. pr_err("%s: afe lpass clock failed, err:%d\n",
  8131. __func__, rc);
  8132. return rc;
  8133. }
  8134. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  8135. {
  8136. int rc = 0;
  8137. struct msm_dai_q6_tdm_dai_data *tdm_dai_data = NULL;
  8138. struct snd_kcontrol *data_format_kcontrol = NULL;
  8139. struct snd_kcontrol *header_type_kcontrol = NULL;
  8140. struct snd_kcontrol *header_kcontrol = NULL;
  8141. int port_idx = 0;
  8142. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  8143. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  8144. const struct snd_kcontrol_new *header_ctrl = NULL;
  8145. tdm_dai_data = dev_get_drvdata(dai->dev);
  8146. msm_dai_q6_set_dai_id(dai);
  8147. port_idx = msm_dai_q6_get_port_idx(dai->id);
  8148. if (port_idx < 0) {
  8149. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8150. __func__, dai->id);
  8151. rc = -EINVAL;
  8152. goto rtn;
  8153. }
  8154. data_format_ctrl =
  8155. &tdm_config_controls_data_format[port_idx];
  8156. header_type_ctrl =
  8157. &tdm_config_controls_header_type[port_idx];
  8158. header_ctrl =
  8159. &tdm_config_controls_header[port_idx];
  8160. if (data_format_ctrl) {
  8161. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  8162. tdm_dai_data);
  8163. rc = snd_ctl_add(dai->component->card->snd_card,
  8164. data_format_kcontrol);
  8165. if (rc < 0) {
  8166. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  8167. __func__, dai->name);
  8168. goto rtn;
  8169. }
  8170. }
  8171. if (header_type_ctrl) {
  8172. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  8173. tdm_dai_data);
  8174. rc = snd_ctl_add(dai->component->card->snd_card,
  8175. header_type_kcontrol);
  8176. if (rc < 0) {
  8177. if (data_format_kcontrol)
  8178. snd_ctl_remove(dai->component->card->snd_card,
  8179. data_format_kcontrol);
  8180. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  8181. __func__, dai->name);
  8182. goto rtn;
  8183. }
  8184. }
  8185. if (header_ctrl) {
  8186. header_kcontrol = snd_ctl_new1(header_ctrl,
  8187. tdm_dai_data);
  8188. rc = snd_ctl_add(dai->component->card->snd_card,
  8189. header_kcontrol);
  8190. if (rc < 0) {
  8191. if (header_type_kcontrol)
  8192. snd_ctl_remove(dai->component->card->snd_card,
  8193. header_type_kcontrol);
  8194. if (data_format_kcontrol)
  8195. snd_ctl_remove(dai->component->card->snd_card,
  8196. data_format_kcontrol);
  8197. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  8198. __func__, dai->name);
  8199. goto rtn;
  8200. }
  8201. }
  8202. if (tdm_dai_data->is_island_dai)
  8203. rc = msm_dai_q6_add_island_mx_ctls(
  8204. dai->component->card->snd_card,
  8205. dai->name,
  8206. dai->id, (void *)tdm_dai_data);
  8207. rc = msm_dai_q6_dai_add_route(dai);
  8208. rtn:
  8209. return rc;
  8210. }
  8211. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  8212. {
  8213. int rc = 0;
  8214. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  8215. dev_get_drvdata(dai->dev);
  8216. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  8217. int group_idx = 0;
  8218. atomic_t *group_ref = NULL;
  8219. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8220. if (group_idx < 0) {
  8221. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8222. __func__, dai->id);
  8223. return -EINVAL;
  8224. }
  8225. group_ref = &tdm_group_ref[group_idx];
  8226. /* If AFE port is still up, close it */
  8227. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  8228. rc = afe_close(dai->id); /* can block */
  8229. if (rc < 0) {
  8230. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8231. __func__, dai->id);
  8232. }
  8233. atomic_dec(group_ref);
  8234. clear_bit(STATUS_PORT_STARTED,
  8235. tdm_dai_data->status_mask);
  8236. if (atomic_read(group_ref) == 0) {
  8237. rc = afe_port_group_enable(group_id,
  8238. NULL, false, NULL);
  8239. if (rc < 0) {
  8240. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  8241. group_id);
  8242. }
  8243. }
  8244. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8245. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  8246. dai->id, false);
  8247. if (rc < 0) {
  8248. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  8249. __func__, dai->id);
  8250. }
  8251. }
  8252. }
  8253. return 0;
  8254. }
  8255. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  8256. unsigned int tx_mask,
  8257. unsigned int rx_mask,
  8258. int slots, int slot_width)
  8259. {
  8260. int rc = 0;
  8261. struct msm_dai_q6_tdm_dai_data *dai_data =
  8262. dev_get_drvdata(dai->dev);
  8263. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  8264. &dai_data->group_cfg.tdm_cfg;
  8265. unsigned int cap_mask;
  8266. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8267. /* HW only supports 16 and 32 bit slot width configuration */
  8268. if ((slot_width != 16) && (slot_width != 32)) {
  8269. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  8270. __func__, slot_width);
  8271. return -EINVAL;
  8272. }
  8273. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  8274. switch (slots) {
  8275. case 1:
  8276. cap_mask = 0x01;
  8277. break;
  8278. case 2:
  8279. cap_mask = 0x03;
  8280. break;
  8281. case 4:
  8282. cap_mask = 0x0F;
  8283. break;
  8284. case 8:
  8285. cap_mask = 0xFF;
  8286. break;
  8287. case 16:
  8288. cap_mask = 0xFFFF;
  8289. break;
  8290. case 32:
  8291. cap_mask = 0xFFFFFFFF;
  8292. break;
  8293. default:
  8294. dev_err(dai->dev, "%s: invalid slots %d\n",
  8295. __func__, slots);
  8296. return -EINVAL;
  8297. }
  8298. switch (dai->id) {
  8299. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8300. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8301. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8302. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8303. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8304. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8305. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8306. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8307. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8308. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8309. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8310. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8311. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8312. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8313. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8314. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8315. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8316. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8317. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8318. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8319. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8320. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8321. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8322. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8323. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8324. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8325. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8326. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8327. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8328. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8329. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8330. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8331. case AFE_PORT_ID_QUINARY_TDM_RX:
  8332. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8333. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8334. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8335. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8336. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8337. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8338. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8339. case AFE_PORT_ID_SENARY_TDM_RX:
  8340. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8341. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8342. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8343. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8344. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8345. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8346. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8347. tdm_group->nslots_per_frame = slots;
  8348. tdm_group->slot_width = slot_width;
  8349. tdm_group->slot_mask = rx_mask & cap_mask;
  8350. break;
  8351. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8352. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8353. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8354. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8355. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8356. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8357. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8358. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8359. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8360. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8361. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8362. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8363. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8364. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8365. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8366. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8367. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8368. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8369. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8370. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8371. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8372. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8373. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8374. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8375. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8376. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8377. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8378. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8379. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8380. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8381. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8382. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8383. case AFE_PORT_ID_QUINARY_TDM_TX:
  8384. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8385. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8386. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8387. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8388. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8389. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8390. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8391. case AFE_PORT_ID_SENARY_TDM_TX:
  8392. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8393. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8394. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8395. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8396. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8397. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8398. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8399. tdm_group->nslots_per_frame = slots;
  8400. tdm_group->slot_width = slot_width;
  8401. tdm_group->slot_mask = tx_mask & cap_mask;
  8402. break;
  8403. default:
  8404. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8405. __func__, dai->id);
  8406. return -EINVAL;
  8407. }
  8408. return rc;
  8409. }
  8410. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  8411. int clk_id, unsigned int freq, int dir)
  8412. {
  8413. struct msm_dai_q6_tdm_dai_data *dai_data =
  8414. dev_get_drvdata(dai->dev);
  8415. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  8416. (dai->id <= AFE_PORT_ID_SENARY_TDM_TX_7)) {
  8417. dai_data->clk_set.clk_freq_in_hz = freq;
  8418. } else {
  8419. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8420. __func__, dai->id);
  8421. return -EINVAL;
  8422. }
  8423. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  8424. __func__, dai->id, freq);
  8425. return 0;
  8426. }
  8427. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  8428. unsigned int tx_num, unsigned int *tx_slot,
  8429. unsigned int rx_num, unsigned int *rx_slot)
  8430. {
  8431. int rc = 0;
  8432. struct msm_dai_q6_tdm_dai_data *dai_data =
  8433. dev_get_drvdata(dai->dev);
  8434. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  8435. &dai_data->port_cfg.slot_mapping;
  8436. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  8437. &dai_data->port_cfg.slot_mapping_v2;
  8438. int i = 0;
  8439. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8440. switch (dai->id) {
  8441. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8442. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8443. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8444. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8445. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8446. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8447. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8448. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8449. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8450. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8451. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8452. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8453. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8454. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8455. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8456. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8457. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8458. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8459. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8460. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8461. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8462. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8463. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8464. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8465. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8466. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8467. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8468. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8469. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8470. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8471. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8472. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8473. case AFE_PORT_ID_QUINARY_TDM_RX:
  8474. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8475. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8476. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8477. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8478. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8479. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8480. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8481. case AFE_PORT_ID_SENARY_TDM_RX:
  8482. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8483. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8484. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8485. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8486. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8487. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8488. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8489. if (q6core_get_avcs_api_version_per_service(
  8490. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8491. if (!rx_slot) {
  8492. dev_err(dai->dev, "%s: rx slot not found\n",
  8493. __func__);
  8494. return -EINVAL;
  8495. }
  8496. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8497. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8498. __func__,
  8499. rx_num);
  8500. return -EINVAL;
  8501. }
  8502. for (i = 0; i < rx_num; i++)
  8503. slot_mapping_v2->offset[i] = rx_slot[i];
  8504. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8505. i++)
  8506. slot_mapping_v2->offset[i] =
  8507. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8508. slot_mapping_v2->num_channel = rx_num;
  8509. } else {
  8510. if (!rx_slot) {
  8511. dev_err(dai->dev, "%s: rx slot not found\n",
  8512. __func__);
  8513. return -EINVAL;
  8514. }
  8515. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8516. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8517. __func__,
  8518. rx_num);
  8519. return -EINVAL;
  8520. }
  8521. for (i = 0; i < rx_num; i++)
  8522. slot_mapping->offset[i] = rx_slot[i];
  8523. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8524. slot_mapping->offset[i] =
  8525. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8526. slot_mapping->num_channel = rx_num;
  8527. }
  8528. break;
  8529. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8530. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8531. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8532. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8533. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8534. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8535. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8536. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8537. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8538. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8539. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8540. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8541. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8542. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8543. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8544. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8545. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8546. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8547. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8548. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8549. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8550. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8551. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8552. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8553. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8554. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8555. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8556. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8557. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8558. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8559. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8560. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8561. case AFE_PORT_ID_QUINARY_TDM_TX:
  8562. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8563. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8564. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8565. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8566. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8567. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8568. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8569. case AFE_PORT_ID_SENARY_TDM_TX:
  8570. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8571. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8572. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8573. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8574. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8575. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8576. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8577. if (q6core_get_avcs_api_version_per_service(
  8578. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8579. if (!tx_slot) {
  8580. dev_err(dai->dev, "%s: tx slot not found\n",
  8581. __func__);
  8582. return -EINVAL;
  8583. }
  8584. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8585. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8586. __func__,
  8587. tx_num);
  8588. return -EINVAL;
  8589. }
  8590. for (i = 0; i < tx_num; i++)
  8591. slot_mapping_v2->offset[i] = tx_slot[i];
  8592. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8593. i++)
  8594. slot_mapping_v2->offset[i] =
  8595. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8596. slot_mapping_v2->num_channel = tx_num;
  8597. } else {
  8598. if (!tx_slot) {
  8599. dev_err(dai->dev, "%s: tx slot not found\n",
  8600. __func__);
  8601. return -EINVAL;
  8602. }
  8603. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8604. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8605. __func__,
  8606. tx_num);
  8607. return -EINVAL;
  8608. }
  8609. for (i = 0; i < tx_num; i++)
  8610. slot_mapping->offset[i] = tx_slot[i];
  8611. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8612. slot_mapping->offset[i] =
  8613. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8614. slot_mapping->num_channel = tx_num;
  8615. }
  8616. break;
  8617. default:
  8618. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8619. __func__, dai->id);
  8620. return -EINVAL;
  8621. }
  8622. return rc;
  8623. }
  8624. static unsigned int tdm_param_set_slot_mask(u16 *slot_offset, int slot_width,
  8625. int slots_per_frame)
  8626. {
  8627. unsigned int i = 0;
  8628. unsigned int slot_index = 0;
  8629. unsigned long slot_mask = 0;
  8630. unsigned int slot_width_bytes = slot_width / 8;
  8631. unsigned int channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT;
  8632. if (q6core_get_avcs_api_version_per_service(
  8633. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3)
  8634. channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8635. if (slot_width_bytes == 0) {
  8636. pr_err("%s: slot width is zero\n", __func__);
  8637. return slot_mask;
  8638. }
  8639. for (i = 0; i < channel_count; i++) {
  8640. if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID) {
  8641. slot_index = slot_offset[i] / slot_width_bytes;
  8642. if (slot_index < slots_per_frame)
  8643. set_bit(slot_index, &slot_mask);
  8644. else {
  8645. pr_err("%s: invalid slot map setting\n",
  8646. __func__);
  8647. return 0;
  8648. }
  8649. } else {
  8650. break;
  8651. }
  8652. }
  8653. return slot_mask;
  8654. }
  8655. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  8656. struct snd_pcm_hw_params *params,
  8657. struct snd_soc_dai *dai)
  8658. {
  8659. struct msm_dai_q6_tdm_dai_data *dai_data =
  8660. dev_get_drvdata(dai->dev);
  8661. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  8662. &dai_data->group_cfg.tdm_cfg;
  8663. struct afe_param_id_tdm_cfg *tdm =
  8664. &dai_data->port_cfg.tdm;
  8665. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  8666. &dai_data->port_cfg.slot_mapping;
  8667. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  8668. &dai_data->port_cfg.slot_mapping_v2;
  8669. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  8670. &dai_data->port_cfg.custom_tdm_header;
  8671. pr_debug("%s: dev_name: %s\n",
  8672. __func__, dev_name(dai->dev));
  8673. if ((params_channels(params) == 0) ||
  8674. (params_channels(params) > 32)) {
  8675. dev_err(dai->dev, "%s: invalid param channels %d\n",
  8676. __func__, params_channels(params));
  8677. return -EINVAL;
  8678. }
  8679. switch (params_format(params)) {
  8680. case SNDRV_PCM_FORMAT_S16_LE:
  8681. dai_data->bitwidth = 16;
  8682. break;
  8683. case SNDRV_PCM_FORMAT_S24_LE:
  8684. case SNDRV_PCM_FORMAT_S24_3LE:
  8685. dai_data->bitwidth = 24;
  8686. break;
  8687. case SNDRV_PCM_FORMAT_S32_LE:
  8688. dai_data->bitwidth = 32;
  8689. break;
  8690. default:
  8691. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  8692. __func__, params_format(params));
  8693. return -EINVAL;
  8694. }
  8695. dai_data->channels = params_channels(params);
  8696. dai_data->rate = params_rate(params);
  8697. /*
  8698. * update tdm group config param
  8699. * NOTE: group config is set to the same as slot config.
  8700. */
  8701. tdm_group->bit_width = tdm_group->slot_width;
  8702. /*
  8703. * for multi lane scenario
  8704. * Total number of active channels = number of active lanes * number of active slots.
  8705. */
  8706. if (dai_data->lane_cfg.lane_mask != AFE_LANE_MASK_INVALID)
  8707. tdm_group->num_channels = tdm_group->nslots_per_frame
  8708. * num_of_bits_set(dai_data->lane_cfg.lane_mask);
  8709. else
  8710. tdm_group->num_channels = tdm_group->nslots_per_frame;
  8711. tdm_group->sample_rate = dai_data->rate;
  8712. pr_debug("%s: TDM GROUP:\n"
  8713. "num_channels=%d sample_rate=%d bit_width=%d\n"
  8714. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  8715. __func__,
  8716. tdm_group->num_channels,
  8717. tdm_group->sample_rate,
  8718. tdm_group->bit_width,
  8719. tdm_group->nslots_per_frame,
  8720. tdm_group->slot_width,
  8721. tdm_group->slot_mask);
  8722. pr_debug("%s: TDM GROUP:\n"
  8723. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  8724. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  8725. __func__,
  8726. tdm_group->port_id[0],
  8727. tdm_group->port_id[1],
  8728. tdm_group->port_id[2],
  8729. tdm_group->port_id[3],
  8730. tdm_group->port_id[4],
  8731. tdm_group->port_id[5],
  8732. tdm_group->port_id[6],
  8733. tdm_group->port_id[7]);
  8734. pr_debug("%s: TDM GROUP ID 0x%x lane mask 0x%x:\n",
  8735. __func__,
  8736. tdm_group->group_id,
  8737. dai_data->lane_cfg.lane_mask);
  8738. /*
  8739. * update tdm config param
  8740. * NOTE: channels/rate/bitwidth are per stream property
  8741. */
  8742. tdm->num_channels = dai_data->channels;
  8743. tdm->sample_rate = dai_data->rate;
  8744. tdm->bit_width = dai_data->bitwidth;
  8745. /*
  8746. * port slot config is the same as group slot config
  8747. * port slot mask should be set according to offset
  8748. */
  8749. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  8750. tdm->slot_width = tdm_group->slot_width;
  8751. if (q6core_get_avcs_api_version_per_service(
  8752. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3)
  8753. tdm->slot_mask = tdm_param_set_slot_mask(
  8754. slot_mapping_v2->offset,
  8755. tdm_group->slot_width,
  8756. tdm_group->nslots_per_frame);
  8757. else
  8758. tdm->slot_mask = tdm_param_set_slot_mask(slot_mapping->offset,
  8759. tdm_group->slot_width,
  8760. tdm_group->nslots_per_frame);
  8761. pr_debug("%s: TDM:\n"
  8762. "num_channels=%d sample_rate=%d bit_width=%d\n"
  8763. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  8764. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  8765. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  8766. __func__,
  8767. tdm->num_channels,
  8768. tdm->sample_rate,
  8769. tdm->bit_width,
  8770. tdm->nslots_per_frame,
  8771. tdm->slot_width,
  8772. tdm->slot_mask,
  8773. tdm->data_format,
  8774. tdm->sync_mode,
  8775. tdm->sync_src,
  8776. tdm->ctrl_data_out_enable,
  8777. tdm->ctrl_invert_sync_pulse,
  8778. tdm->ctrl_sync_data_delay);
  8779. if (q6core_get_avcs_api_version_per_service(
  8780. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8781. /*
  8782. * update slot mapping v2 config param
  8783. * NOTE: channels/rate/bitwidth are per stream property
  8784. */
  8785. slot_mapping_v2->bitwidth = dai_data->bitwidth;
  8786. pr_debug("%s: SLOT MAPPING_V2:\n"
  8787. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  8788. __func__,
  8789. slot_mapping_v2->num_channel,
  8790. slot_mapping_v2->bitwidth,
  8791. slot_mapping_v2->data_align_type);
  8792. pr_debug("%s: SLOT MAPPING V2:\n"
  8793. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  8794. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n"
  8795. "offset[8]=0x%x offset[9]=0x%x offset[10]=0x%x offset[11]=0x%x\n"
  8796. "offset[12]=0x%x offset[13]=0x%x offset[14]=0x%x offset[15]=0x%x\n"
  8797. "offset[16]=0x%x offset[17]=0x%x offset[18]=0x%x offset[19]=0x%x\n"
  8798. "offset[20]=0x%x offset[21]=0x%x offset[22]=0x%x offset[23]=0x%x\n"
  8799. "offset[24]=0x%x offset[25]=0x%x offset[26]=0x%x offset[27]=0x%x\n"
  8800. "offset[28]=0x%x offset[29]=0x%x offset[30]=0x%x offset[31]=0x%x\n",
  8801. __func__,
  8802. slot_mapping_v2->offset[0],
  8803. slot_mapping_v2->offset[1],
  8804. slot_mapping_v2->offset[2],
  8805. slot_mapping_v2->offset[3],
  8806. slot_mapping_v2->offset[4],
  8807. slot_mapping_v2->offset[5],
  8808. slot_mapping_v2->offset[6],
  8809. slot_mapping_v2->offset[7],
  8810. slot_mapping_v2->offset[8],
  8811. slot_mapping_v2->offset[9],
  8812. slot_mapping_v2->offset[10],
  8813. slot_mapping_v2->offset[11],
  8814. slot_mapping_v2->offset[12],
  8815. slot_mapping_v2->offset[13],
  8816. slot_mapping_v2->offset[14],
  8817. slot_mapping_v2->offset[15],
  8818. slot_mapping_v2->offset[16],
  8819. slot_mapping_v2->offset[17],
  8820. slot_mapping_v2->offset[18],
  8821. slot_mapping_v2->offset[19],
  8822. slot_mapping_v2->offset[20],
  8823. slot_mapping_v2->offset[21],
  8824. slot_mapping_v2->offset[22],
  8825. slot_mapping_v2->offset[23],
  8826. slot_mapping_v2->offset[24],
  8827. slot_mapping_v2->offset[25],
  8828. slot_mapping_v2->offset[26],
  8829. slot_mapping_v2->offset[27],
  8830. slot_mapping_v2->offset[28],
  8831. slot_mapping_v2->offset[29],
  8832. slot_mapping_v2->offset[30],
  8833. slot_mapping_v2->offset[31]);
  8834. } else {
  8835. /*
  8836. * update slot mapping config param
  8837. * NOTE: channels/rate/bitwidth are per stream property
  8838. */
  8839. slot_mapping->bitwidth = dai_data->bitwidth;
  8840. pr_debug("%s: SLOT MAPPING:\n"
  8841. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  8842. __func__,
  8843. slot_mapping->num_channel,
  8844. slot_mapping->bitwidth,
  8845. slot_mapping->data_align_type);
  8846. pr_debug("%s: SLOT MAPPING:\n"
  8847. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  8848. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  8849. __func__,
  8850. slot_mapping->offset[0],
  8851. slot_mapping->offset[1],
  8852. slot_mapping->offset[2],
  8853. slot_mapping->offset[3],
  8854. slot_mapping->offset[4],
  8855. slot_mapping->offset[5],
  8856. slot_mapping->offset[6],
  8857. slot_mapping->offset[7]);
  8858. }
  8859. /*
  8860. * update custom header config param
  8861. * NOTE: channels/rate/bitwidth are per playback stream property.
  8862. * custom tdm header only applicable to playback stream.
  8863. */
  8864. if (custom_tdm_header->header_type !=
  8865. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  8866. pr_debug("%s: CUSTOM TDM HEADER:\n"
  8867. "start_offset=0x%x header_width=%d\n"
  8868. "num_frame_repeat=%d header_type=0x%x\n",
  8869. __func__,
  8870. custom_tdm_header->start_offset,
  8871. custom_tdm_header->header_width,
  8872. custom_tdm_header->num_frame_repeat,
  8873. custom_tdm_header->header_type);
  8874. pr_debug("%s: CUSTOM TDM HEADER:\n"
  8875. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  8876. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  8877. __func__,
  8878. custom_tdm_header->header[0],
  8879. custom_tdm_header->header[1],
  8880. custom_tdm_header->header[2],
  8881. custom_tdm_header->header[3],
  8882. custom_tdm_header->header[4],
  8883. custom_tdm_header->header[5],
  8884. custom_tdm_header->header[6],
  8885. custom_tdm_header->header[7]);
  8886. }
  8887. return 0;
  8888. }
  8889. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  8890. struct snd_soc_dai *dai)
  8891. {
  8892. int rc = 0;
  8893. struct msm_dai_q6_tdm_dai_data *dai_data =
  8894. dev_get_drvdata(dai->dev);
  8895. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  8896. int group_idx = 0;
  8897. atomic_t *group_ref = NULL;
  8898. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  8899. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  8900. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  8901. dev_dbg(dai->dev,
  8902. "%s: Custom tdm header not supported\n", __func__);
  8903. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8904. if (group_idx < 0) {
  8905. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8906. __func__, dai->id);
  8907. return -EINVAL;
  8908. }
  8909. mutex_lock(&tdm_mutex);
  8910. group_ref = &tdm_group_ref[group_idx];
  8911. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8912. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8913. /* TX and RX share the same clk. So enable the clk
  8914. * per TDM interface. */
  8915. rc = msm_dai_q6_tdm_set_clk(dai_data,
  8916. dai->id, true);
  8917. if (rc < 0) {
  8918. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  8919. __func__, dai->id);
  8920. goto rtn;
  8921. }
  8922. }
  8923. /* PORT START should be set if prepare called
  8924. * in active state.
  8925. */
  8926. if (atomic_read(group_ref) == 0) {
  8927. /*
  8928. * if only one port, don't do group enable as there
  8929. * is no group need for only one port
  8930. */
  8931. if (dai_data->num_group_ports > 1) {
  8932. rc = afe_port_group_enable(group_id,
  8933. &dai_data->group_cfg, true,
  8934. &dai_data->lane_cfg);
  8935. if (rc < 0) {
  8936. dev_err(dai->dev,
  8937. "%s: fail to enable AFE group 0x%x\n",
  8938. __func__, group_id);
  8939. goto rtn;
  8940. }
  8941. }
  8942. }
  8943. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  8944. dai_data->rate, dai_data->num_group_ports);
  8945. if (rc < 0) {
  8946. if (atomic_read(group_ref) == 0) {
  8947. afe_port_group_enable(group_id,
  8948. NULL, false, NULL);
  8949. }
  8950. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8951. msm_dai_q6_tdm_set_clk(dai_data,
  8952. dai->id, false);
  8953. }
  8954. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  8955. __func__, dai->id);
  8956. } else {
  8957. set_bit(STATUS_PORT_STARTED,
  8958. dai_data->status_mask);
  8959. atomic_inc(group_ref);
  8960. }
  8961. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  8962. /* NOTE: AFE should error out if HW resource contention */
  8963. }
  8964. rtn:
  8965. mutex_unlock(&tdm_mutex);
  8966. return rc;
  8967. }
  8968. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  8969. struct snd_soc_dai *dai)
  8970. {
  8971. int rc = 0;
  8972. struct msm_dai_q6_tdm_dai_data *dai_data =
  8973. dev_get_drvdata(dai->dev);
  8974. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  8975. int group_idx = 0;
  8976. atomic_t *group_ref = NULL;
  8977. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8978. if (group_idx < 0) {
  8979. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8980. __func__, dai->id);
  8981. return;
  8982. }
  8983. mutex_lock(&tdm_mutex);
  8984. group_ref = &tdm_group_ref[group_idx];
  8985. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8986. rc = afe_close(dai->id);
  8987. if (rc < 0) {
  8988. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8989. __func__, dai->id);
  8990. }
  8991. atomic_dec(group_ref);
  8992. clear_bit(STATUS_PORT_STARTED,
  8993. dai_data->status_mask);
  8994. if (atomic_read(group_ref) == 0) {
  8995. rc = afe_port_group_enable(group_id,
  8996. NULL, false, NULL);
  8997. if (rc < 0) {
  8998. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  8999. __func__, group_id);
  9000. }
  9001. }
  9002. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  9003. rc = msm_dai_q6_tdm_set_clk(dai_data,
  9004. dai->id, false);
  9005. if (rc < 0) {
  9006. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  9007. __func__, dai->id);
  9008. }
  9009. }
  9010. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  9011. /* NOTE: AFE should error out if HW resource contention */
  9012. }
  9013. mutex_unlock(&tdm_mutex);
  9014. }
  9015. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  9016. .prepare = msm_dai_q6_tdm_prepare,
  9017. .hw_params = msm_dai_q6_tdm_hw_params,
  9018. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  9019. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  9020. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  9021. .shutdown = msm_dai_q6_tdm_shutdown,
  9022. };
  9023. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  9024. {
  9025. .playback = {
  9026. .stream_name = "Primary TDM0 Playback",
  9027. .aif_name = "PRI_TDM_RX_0",
  9028. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9029. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9030. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9031. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9032. SNDRV_PCM_FMTBIT_S24_LE |
  9033. SNDRV_PCM_FMTBIT_S32_LE,
  9034. .channels_min = 1,
  9035. .channels_max = 16,
  9036. .rate_min = 8000,
  9037. .rate_max = 352800,
  9038. },
  9039. .name = "PRI_TDM_RX_0",
  9040. .ops = &msm_dai_q6_tdm_ops,
  9041. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  9042. .probe = msm_dai_q6_dai_tdm_probe,
  9043. .remove = msm_dai_q6_dai_tdm_remove,
  9044. },
  9045. {
  9046. .playback = {
  9047. .stream_name = "Primary TDM1 Playback",
  9048. .aif_name = "PRI_TDM_RX_1",
  9049. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9050. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9051. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9052. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9053. SNDRV_PCM_FMTBIT_S24_LE |
  9054. SNDRV_PCM_FMTBIT_S32_LE,
  9055. .channels_min = 1,
  9056. .channels_max = 16,
  9057. .rate_min = 8000,
  9058. .rate_max = 352800,
  9059. },
  9060. .name = "PRI_TDM_RX_1",
  9061. .ops = &msm_dai_q6_tdm_ops,
  9062. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  9063. .probe = msm_dai_q6_dai_tdm_probe,
  9064. .remove = msm_dai_q6_dai_tdm_remove,
  9065. },
  9066. {
  9067. .playback = {
  9068. .stream_name = "Primary TDM2 Playback",
  9069. .aif_name = "PRI_TDM_RX_2",
  9070. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9071. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9072. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9073. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9074. SNDRV_PCM_FMTBIT_S24_LE |
  9075. SNDRV_PCM_FMTBIT_S32_LE,
  9076. .channels_min = 1,
  9077. .channels_max = 16,
  9078. .rate_min = 8000,
  9079. .rate_max = 352800,
  9080. },
  9081. .name = "PRI_TDM_RX_2",
  9082. .ops = &msm_dai_q6_tdm_ops,
  9083. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  9084. .probe = msm_dai_q6_dai_tdm_probe,
  9085. .remove = msm_dai_q6_dai_tdm_remove,
  9086. },
  9087. {
  9088. .playback = {
  9089. .stream_name = "Primary TDM3 Playback",
  9090. .aif_name = "PRI_TDM_RX_3",
  9091. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9092. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9093. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9094. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9095. SNDRV_PCM_FMTBIT_S24_LE |
  9096. SNDRV_PCM_FMTBIT_S32_LE,
  9097. .channels_min = 1,
  9098. .channels_max = 16,
  9099. .rate_min = 8000,
  9100. .rate_max = 352800,
  9101. },
  9102. .name = "PRI_TDM_RX_3",
  9103. .ops = &msm_dai_q6_tdm_ops,
  9104. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  9105. .probe = msm_dai_q6_dai_tdm_probe,
  9106. .remove = msm_dai_q6_dai_tdm_remove,
  9107. },
  9108. {
  9109. .playback = {
  9110. .stream_name = "Primary TDM4 Playback",
  9111. .aif_name = "PRI_TDM_RX_4",
  9112. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9113. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9114. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9115. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9116. SNDRV_PCM_FMTBIT_S24_LE |
  9117. SNDRV_PCM_FMTBIT_S32_LE,
  9118. .channels_min = 1,
  9119. .channels_max = 16,
  9120. .rate_min = 8000,
  9121. .rate_max = 352800,
  9122. },
  9123. .name = "PRI_TDM_RX_4",
  9124. .ops = &msm_dai_q6_tdm_ops,
  9125. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  9126. .probe = msm_dai_q6_dai_tdm_probe,
  9127. .remove = msm_dai_q6_dai_tdm_remove,
  9128. },
  9129. {
  9130. .playback = {
  9131. .stream_name = "Primary TDM5 Playback",
  9132. .aif_name = "PRI_TDM_RX_5",
  9133. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9134. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9135. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9136. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9137. SNDRV_PCM_FMTBIT_S24_LE |
  9138. SNDRV_PCM_FMTBIT_S32_LE,
  9139. .channels_min = 1,
  9140. .channels_max = 16,
  9141. .rate_min = 8000,
  9142. .rate_max = 352800,
  9143. },
  9144. .name = "PRI_TDM_RX_5",
  9145. .ops = &msm_dai_q6_tdm_ops,
  9146. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  9147. .probe = msm_dai_q6_dai_tdm_probe,
  9148. .remove = msm_dai_q6_dai_tdm_remove,
  9149. },
  9150. {
  9151. .playback = {
  9152. .stream_name = "Primary TDM6 Playback",
  9153. .aif_name = "PRI_TDM_RX_6",
  9154. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9155. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9156. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9157. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9158. SNDRV_PCM_FMTBIT_S24_LE |
  9159. SNDRV_PCM_FMTBIT_S32_LE,
  9160. .channels_min = 1,
  9161. .channels_max = 16,
  9162. .rate_min = 8000,
  9163. .rate_max = 352800,
  9164. },
  9165. .name = "PRI_TDM_RX_6",
  9166. .ops = &msm_dai_q6_tdm_ops,
  9167. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  9168. .probe = msm_dai_q6_dai_tdm_probe,
  9169. .remove = msm_dai_q6_dai_tdm_remove,
  9170. },
  9171. {
  9172. .playback = {
  9173. .stream_name = "Primary TDM7 Playback",
  9174. .aif_name = "PRI_TDM_RX_7",
  9175. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9176. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9177. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9178. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9179. SNDRV_PCM_FMTBIT_S24_LE |
  9180. SNDRV_PCM_FMTBIT_S32_LE,
  9181. .channels_min = 1,
  9182. .channels_max = 16,
  9183. .rate_min = 8000,
  9184. .rate_max = 352800,
  9185. },
  9186. .name = "PRI_TDM_RX_7",
  9187. .ops = &msm_dai_q6_tdm_ops,
  9188. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  9189. .probe = msm_dai_q6_dai_tdm_probe,
  9190. .remove = msm_dai_q6_dai_tdm_remove,
  9191. },
  9192. {
  9193. .capture = {
  9194. .stream_name = "Primary TDM0 Capture",
  9195. .aif_name = "PRI_TDM_TX_0",
  9196. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9197. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9198. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9199. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9200. SNDRV_PCM_FMTBIT_S24_LE |
  9201. SNDRV_PCM_FMTBIT_S32_LE,
  9202. .channels_min = 1,
  9203. .channels_max = 16,
  9204. .rate_min = 8000,
  9205. .rate_max = 352800,
  9206. },
  9207. .name = "PRI_TDM_TX_0",
  9208. .ops = &msm_dai_q6_tdm_ops,
  9209. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  9210. .probe = msm_dai_q6_dai_tdm_probe,
  9211. .remove = msm_dai_q6_dai_tdm_remove,
  9212. },
  9213. {
  9214. .capture = {
  9215. .stream_name = "Primary TDM1 Capture",
  9216. .aif_name = "PRI_TDM_TX_1",
  9217. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9218. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9219. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9220. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9221. SNDRV_PCM_FMTBIT_S24_LE |
  9222. SNDRV_PCM_FMTBIT_S32_LE,
  9223. .channels_min = 1,
  9224. .channels_max = 16,
  9225. .rate_min = 8000,
  9226. .rate_max = 352800,
  9227. },
  9228. .name = "PRI_TDM_TX_1",
  9229. .ops = &msm_dai_q6_tdm_ops,
  9230. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  9231. .probe = msm_dai_q6_dai_tdm_probe,
  9232. .remove = msm_dai_q6_dai_tdm_remove,
  9233. },
  9234. {
  9235. .capture = {
  9236. .stream_name = "Primary TDM2 Capture",
  9237. .aif_name = "PRI_TDM_TX_2",
  9238. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9239. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9240. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9241. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9242. SNDRV_PCM_FMTBIT_S24_LE |
  9243. SNDRV_PCM_FMTBIT_S32_LE,
  9244. .channels_min = 1,
  9245. .channels_max = 16,
  9246. .rate_min = 8000,
  9247. .rate_max = 352800,
  9248. },
  9249. .name = "PRI_TDM_TX_2",
  9250. .ops = &msm_dai_q6_tdm_ops,
  9251. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  9252. .probe = msm_dai_q6_dai_tdm_probe,
  9253. .remove = msm_dai_q6_dai_tdm_remove,
  9254. },
  9255. {
  9256. .capture = {
  9257. .stream_name = "Primary TDM3 Capture",
  9258. .aif_name = "PRI_TDM_TX_3",
  9259. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9260. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9261. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9262. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9263. SNDRV_PCM_FMTBIT_S24_LE |
  9264. SNDRV_PCM_FMTBIT_S32_LE,
  9265. .channels_min = 1,
  9266. .channels_max = 16,
  9267. .rate_min = 8000,
  9268. .rate_max = 352800,
  9269. },
  9270. .name = "PRI_TDM_TX_3",
  9271. .ops = &msm_dai_q6_tdm_ops,
  9272. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  9273. .probe = msm_dai_q6_dai_tdm_probe,
  9274. .remove = msm_dai_q6_dai_tdm_remove,
  9275. },
  9276. {
  9277. .capture = {
  9278. .stream_name = "Primary TDM4 Capture",
  9279. .aif_name = "PRI_TDM_TX_4",
  9280. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9281. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9282. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9283. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9284. SNDRV_PCM_FMTBIT_S24_LE |
  9285. SNDRV_PCM_FMTBIT_S32_LE,
  9286. .channels_min = 1,
  9287. .channels_max = 16,
  9288. .rate_min = 8000,
  9289. .rate_max = 352800,
  9290. },
  9291. .name = "PRI_TDM_TX_4",
  9292. .ops = &msm_dai_q6_tdm_ops,
  9293. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  9294. .probe = msm_dai_q6_dai_tdm_probe,
  9295. .remove = msm_dai_q6_dai_tdm_remove,
  9296. },
  9297. {
  9298. .capture = {
  9299. .stream_name = "Primary TDM5 Capture",
  9300. .aif_name = "PRI_TDM_TX_5",
  9301. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9302. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9303. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9304. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9305. SNDRV_PCM_FMTBIT_S24_LE |
  9306. SNDRV_PCM_FMTBIT_S32_LE,
  9307. .channels_min = 1,
  9308. .channels_max = 16,
  9309. .rate_min = 8000,
  9310. .rate_max = 352800,
  9311. },
  9312. .name = "PRI_TDM_TX_5",
  9313. .ops = &msm_dai_q6_tdm_ops,
  9314. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  9315. .probe = msm_dai_q6_dai_tdm_probe,
  9316. .remove = msm_dai_q6_dai_tdm_remove,
  9317. },
  9318. {
  9319. .capture = {
  9320. .stream_name = "Primary TDM6 Capture",
  9321. .aif_name = "PRI_TDM_TX_6",
  9322. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9323. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9324. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9325. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9326. SNDRV_PCM_FMTBIT_S24_LE |
  9327. SNDRV_PCM_FMTBIT_S32_LE,
  9328. .channels_min = 1,
  9329. .channels_max = 16,
  9330. .rate_min = 8000,
  9331. .rate_max = 352800,
  9332. },
  9333. .name = "PRI_TDM_TX_6",
  9334. .ops = &msm_dai_q6_tdm_ops,
  9335. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  9336. .probe = msm_dai_q6_dai_tdm_probe,
  9337. .remove = msm_dai_q6_dai_tdm_remove,
  9338. },
  9339. {
  9340. .capture = {
  9341. .stream_name = "Primary TDM7 Capture",
  9342. .aif_name = "PRI_TDM_TX_7",
  9343. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9344. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9345. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9346. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9347. SNDRV_PCM_FMTBIT_S24_LE |
  9348. SNDRV_PCM_FMTBIT_S32_LE,
  9349. .channels_min = 1,
  9350. .channels_max = 16,
  9351. .rate_min = 8000,
  9352. .rate_max = 352800,
  9353. },
  9354. .name = "PRI_TDM_TX_7",
  9355. .ops = &msm_dai_q6_tdm_ops,
  9356. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  9357. .probe = msm_dai_q6_dai_tdm_probe,
  9358. .remove = msm_dai_q6_dai_tdm_remove,
  9359. },
  9360. {
  9361. .playback = {
  9362. .stream_name = "Secondary TDM0 Playback",
  9363. .aif_name = "SEC_TDM_RX_0",
  9364. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9365. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9366. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9367. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9368. SNDRV_PCM_FMTBIT_S24_LE |
  9369. SNDRV_PCM_FMTBIT_S32_LE,
  9370. .channels_min = 1,
  9371. .channels_max = 16,
  9372. .rate_min = 8000,
  9373. .rate_max = 352800,
  9374. },
  9375. .name = "SEC_TDM_RX_0",
  9376. .ops = &msm_dai_q6_tdm_ops,
  9377. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  9378. .probe = msm_dai_q6_dai_tdm_probe,
  9379. .remove = msm_dai_q6_dai_tdm_remove,
  9380. },
  9381. {
  9382. .playback = {
  9383. .stream_name = "Secondary TDM1 Playback",
  9384. .aif_name = "SEC_TDM_RX_1",
  9385. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9386. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9387. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9388. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9389. SNDRV_PCM_FMTBIT_S24_LE |
  9390. SNDRV_PCM_FMTBIT_S32_LE,
  9391. .channels_min = 1,
  9392. .channels_max = 16,
  9393. .rate_min = 8000,
  9394. .rate_max = 352800,
  9395. },
  9396. .name = "SEC_TDM_RX_1",
  9397. .ops = &msm_dai_q6_tdm_ops,
  9398. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  9399. .probe = msm_dai_q6_dai_tdm_probe,
  9400. .remove = msm_dai_q6_dai_tdm_remove,
  9401. },
  9402. {
  9403. .playback = {
  9404. .stream_name = "Secondary TDM2 Playback",
  9405. .aif_name = "SEC_TDM_RX_2",
  9406. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9407. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9408. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9409. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9410. SNDRV_PCM_FMTBIT_S24_LE |
  9411. SNDRV_PCM_FMTBIT_S32_LE,
  9412. .channels_min = 1,
  9413. .channels_max = 16,
  9414. .rate_min = 8000,
  9415. .rate_max = 352800,
  9416. },
  9417. .name = "SEC_TDM_RX_2",
  9418. .ops = &msm_dai_q6_tdm_ops,
  9419. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  9420. .probe = msm_dai_q6_dai_tdm_probe,
  9421. .remove = msm_dai_q6_dai_tdm_remove,
  9422. },
  9423. {
  9424. .playback = {
  9425. .stream_name = "Secondary TDM3 Playback",
  9426. .aif_name = "SEC_TDM_RX_3",
  9427. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9428. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9429. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9430. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9431. SNDRV_PCM_FMTBIT_S24_LE |
  9432. SNDRV_PCM_FMTBIT_S32_LE,
  9433. .channels_min = 1,
  9434. .channels_max = 16,
  9435. .rate_min = 8000,
  9436. .rate_max = 352800,
  9437. },
  9438. .name = "SEC_TDM_RX_3",
  9439. .ops = &msm_dai_q6_tdm_ops,
  9440. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  9441. .probe = msm_dai_q6_dai_tdm_probe,
  9442. .remove = msm_dai_q6_dai_tdm_remove,
  9443. },
  9444. {
  9445. .playback = {
  9446. .stream_name = "Secondary TDM4 Playback",
  9447. .aif_name = "SEC_TDM_RX_4",
  9448. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9449. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9450. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9451. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9452. SNDRV_PCM_FMTBIT_S24_LE |
  9453. SNDRV_PCM_FMTBIT_S32_LE,
  9454. .channels_min = 1,
  9455. .channels_max = 16,
  9456. .rate_min = 8000,
  9457. .rate_max = 352800,
  9458. },
  9459. .name = "SEC_TDM_RX_4",
  9460. .ops = &msm_dai_q6_tdm_ops,
  9461. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  9462. .probe = msm_dai_q6_dai_tdm_probe,
  9463. .remove = msm_dai_q6_dai_tdm_remove,
  9464. },
  9465. {
  9466. .playback = {
  9467. .stream_name = "Secondary TDM5 Playback",
  9468. .aif_name = "SEC_TDM_RX_5",
  9469. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9470. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9471. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9472. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9473. SNDRV_PCM_FMTBIT_S24_LE |
  9474. SNDRV_PCM_FMTBIT_S32_LE,
  9475. .channels_min = 1,
  9476. .channels_max = 16,
  9477. .rate_min = 8000,
  9478. .rate_max = 352800,
  9479. },
  9480. .name = "SEC_TDM_RX_5",
  9481. .ops = &msm_dai_q6_tdm_ops,
  9482. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  9483. .probe = msm_dai_q6_dai_tdm_probe,
  9484. .remove = msm_dai_q6_dai_tdm_remove,
  9485. },
  9486. {
  9487. .playback = {
  9488. .stream_name = "Secondary TDM6 Playback",
  9489. .aif_name = "SEC_TDM_RX_6",
  9490. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9491. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9492. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9493. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9494. SNDRV_PCM_FMTBIT_S24_LE |
  9495. SNDRV_PCM_FMTBIT_S32_LE,
  9496. .channels_min = 1,
  9497. .channels_max = 16,
  9498. .rate_min = 8000,
  9499. .rate_max = 352800,
  9500. },
  9501. .name = "SEC_TDM_RX_6",
  9502. .ops = &msm_dai_q6_tdm_ops,
  9503. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  9504. .probe = msm_dai_q6_dai_tdm_probe,
  9505. .remove = msm_dai_q6_dai_tdm_remove,
  9506. },
  9507. {
  9508. .playback = {
  9509. .stream_name = "Secondary TDM7 Playback",
  9510. .aif_name = "SEC_TDM_RX_7",
  9511. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9512. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9513. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9514. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9515. SNDRV_PCM_FMTBIT_S24_LE |
  9516. SNDRV_PCM_FMTBIT_S32_LE,
  9517. .channels_min = 1,
  9518. .channels_max = 16,
  9519. .rate_min = 8000,
  9520. .rate_max = 352800,
  9521. },
  9522. .name = "SEC_TDM_RX_7",
  9523. .ops = &msm_dai_q6_tdm_ops,
  9524. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  9525. .probe = msm_dai_q6_dai_tdm_probe,
  9526. .remove = msm_dai_q6_dai_tdm_remove,
  9527. },
  9528. {
  9529. .capture = {
  9530. .stream_name = "Secondary TDM0 Capture",
  9531. .aif_name = "SEC_TDM_TX_0",
  9532. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9533. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9534. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9535. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9536. SNDRV_PCM_FMTBIT_S24_LE |
  9537. SNDRV_PCM_FMTBIT_S32_LE,
  9538. .channels_min = 1,
  9539. .channels_max = 16,
  9540. .rate_min = 8000,
  9541. .rate_max = 352800,
  9542. },
  9543. .name = "SEC_TDM_TX_0",
  9544. .ops = &msm_dai_q6_tdm_ops,
  9545. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  9546. .probe = msm_dai_q6_dai_tdm_probe,
  9547. .remove = msm_dai_q6_dai_tdm_remove,
  9548. },
  9549. {
  9550. .capture = {
  9551. .stream_name = "Secondary TDM1 Capture",
  9552. .aif_name = "SEC_TDM_TX_1",
  9553. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9554. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9555. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9556. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9557. SNDRV_PCM_FMTBIT_S24_LE |
  9558. SNDRV_PCM_FMTBIT_S32_LE,
  9559. .channels_min = 1,
  9560. .channels_max = 16,
  9561. .rate_min = 8000,
  9562. .rate_max = 352800,
  9563. },
  9564. .name = "SEC_TDM_TX_1",
  9565. .ops = &msm_dai_q6_tdm_ops,
  9566. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  9567. .probe = msm_dai_q6_dai_tdm_probe,
  9568. .remove = msm_dai_q6_dai_tdm_remove,
  9569. },
  9570. {
  9571. .capture = {
  9572. .stream_name = "Secondary TDM2 Capture",
  9573. .aif_name = "SEC_TDM_TX_2",
  9574. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9575. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9576. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9577. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9578. SNDRV_PCM_FMTBIT_S24_LE |
  9579. SNDRV_PCM_FMTBIT_S32_LE,
  9580. .channels_min = 1,
  9581. .channels_max = 16,
  9582. .rate_min = 8000,
  9583. .rate_max = 352800,
  9584. },
  9585. .name = "SEC_TDM_TX_2",
  9586. .ops = &msm_dai_q6_tdm_ops,
  9587. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  9588. .probe = msm_dai_q6_dai_tdm_probe,
  9589. .remove = msm_dai_q6_dai_tdm_remove,
  9590. },
  9591. {
  9592. .capture = {
  9593. .stream_name = "Secondary TDM3 Capture",
  9594. .aif_name = "SEC_TDM_TX_3",
  9595. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9596. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9597. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9598. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9599. SNDRV_PCM_FMTBIT_S24_LE |
  9600. SNDRV_PCM_FMTBIT_S32_LE,
  9601. .channels_min = 1,
  9602. .channels_max = 16,
  9603. .rate_min = 8000,
  9604. .rate_max = 352800,
  9605. },
  9606. .name = "SEC_TDM_TX_3",
  9607. .ops = &msm_dai_q6_tdm_ops,
  9608. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  9609. .probe = msm_dai_q6_dai_tdm_probe,
  9610. .remove = msm_dai_q6_dai_tdm_remove,
  9611. },
  9612. {
  9613. .capture = {
  9614. .stream_name = "Secondary TDM4 Capture",
  9615. .aif_name = "SEC_TDM_TX_4",
  9616. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9617. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9618. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9619. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9620. SNDRV_PCM_FMTBIT_S24_LE |
  9621. SNDRV_PCM_FMTBIT_S32_LE,
  9622. .channels_min = 1,
  9623. .channels_max = 16,
  9624. .rate_min = 8000,
  9625. .rate_max = 352800,
  9626. },
  9627. .name = "SEC_TDM_TX_4",
  9628. .ops = &msm_dai_q6_tdm_ops,
  9629. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  9630. .probe = msm_dai_q6_dai_tdm_probe,
  9631. .remove = msm_dai_q6_dai_tdm_remove,
  9632. },
  9633. {
  9634. .capture = {
  9635. .stream_name = "Secondary TDM5 Capture",
  9636. .aif_name = "SEC_TDM_TX_5",
  9637. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9638. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9639. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9640. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9641. SNDRV_PCM_FMTBIT_S24_LE |
  9642. SNDRV_PCM_FMTBIT_S32_LE,
  9643. .channels_min = 1,
  9644. .channels_max = 16,
  9645. .rate_min = 8000,
  9646. .rate_max = 352800,
  9647. },
  9648. .name = "SEC_TDM_TX_5",
  9649. .ops = &msm_dai_q6_tdm_ops,
  9650. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  9651. .probe = msm_dai_q6_dai_tdm_probe,
  9652. .remove = msm_dai_q6_dai_tdm_remove,
  9653. },
  9654. {
  9655. .capture = {
  9656. .stream_name = "Secondary TDM6 Capture",
  9657. .aif_name = "SEC_TDM_TX_6",
  9658. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9659. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9660. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9661. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9662. SNDRV_PCM_FMTBIT_S24_LE |
  9663. SNDRV_PCM_FMTBIT_S32_LE,
  9664. .channels_min = 1,
  9665. .channels_max = 16,
  9666. .rate_min = 8000,
  9667. .rate_max = 352800,
  9668. },
  9669. .name = "SEC_TDM_TX_6",
  9670. .ops = &msm_dai_q6_tdm_ops,
  9671. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  9672. .probe = msm_dai_q6_dai_tdm_probe,
  9673. .remove = msm_dai_q6_dai_tdm_remove,
  9674. },
  9675. {
  9676. .capture = {
  9677. .stream_name = "Secondary TDM7 Capture",
  9678. .aif_name = "SEC_TDM_TX_7",
  9679. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9680. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9681. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9682. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9683. SNDRV_PCM_FMTBIT_S24_LE |
  9684. SNDRV_PCM_FMTBIT_S32_LE,
  9685. .channels_min = 1,
  9686. .channels_max = 16,
  9687. .rate_min = 8000,
  9688. .rate_max = 352800,
  9689. },
  9690. .name = "SEC_TDM_TX_7",
  9691. .ops = &msm_dai_q6_tdm_ops,
  9692. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  9693. .probe = msm_dai_q6_dai_tdm_probe,
  9694. .remove = msm_dai_q6_dai_tdm_remove,
  9695. },
  9696. {
  9697. .playback = {
  9698. .stream_name = "Tertiary TDM0 Playback",
  9699. .aif_name = "TERT_TDM_RX_0",
  9700. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9701. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9702. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9703. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9704. SNDRV_PCM_FMTBIT_S24_LE |
  9705. SNDRV_PCM_FMTBIT_S32_LE,
  9706. .channels_min = 1,
  9707. .channels_max = 16,
  9708. .rate_min = 8000,
  9709. .rate_max = 352800,
  9710. },
  9711. .name = "TERT_TDM_RX_0",
  9712. .ops = &msm_dai_q6_tdm_ops,
  9713. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  9714. .probe = msm_dai_q6_dai_tdm_probe,
  9715. .remove = msm_dai_q6_dai_tdm_remove,
  9716. },
  9717. {
  9718. .playback = {
  9719. .stream_name = "Tertiary TDM1 Playback",
  9720. .aif_name = "TERT_TDM_RX_1",
  9721. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9722. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9723. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9724. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9725. SNDRV_PCM_FMTBIT_S24_LE |
  9726. SNDRV_PCM_FMTBIT_S32_LE,
  9727. .channels_min = 1,
  9728. .channels_max = 16,
  9729. .rate_min = 8000,
  9730. .rate_max = 352800,
  9731. },
  9732. .name = "TERT_TDM_RX_1",
  9733. .ops = &msm_dai_q6_tdm_ops,
  9734. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  9735. .probe = msm_dai_q6_dai_tdm_probe,
  9736. .remove = msm_dai_q6_dai_tdm_remove,
  9737. },
  9738. {
  9739. .playback = {
  9740. .stream_name = "Tertiary TDM2 Playback",
  9741. .aif_name = "TERT_TDM_RX_2",
  9742. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9743. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9744. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9745. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9746. SNDRV_PCM_FMTBIT_S24_LE |
  9747. SNDRV_PCM_FMTBIT_S32_LE,
  9748. .channels_min = 1,
  9749. .channels_max = 16,
  9750. .rate_min = 8000,
  9751. .rate_max = 352800,
  9752. },
  9753. .name = "TERT_TDM_RX_2",
  9754. .ops = &msm_dai_q6_tdm_ops,
  9755. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  9756. .probe = msm_dai_q6_dai_tdm_probe,
  9757. .remove = msm_dai_q6_dai_tdm_remove,
  9758. },
  9759. {
  9760. .playback = {
  9761. .stream_name = "Tertiary TDM3 Playback",
  9762. .aif_name = "TERT_TDM_RX_3",
  9763. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9764. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9765. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9766. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9767. SNDRV_PCM_FMTBIT_S24_LE |
  9768. SNDRV_PCM_FMTBIT_S32_LE,
  9769. .channels_min = 1,
  9770. .channels_max = 16,
  9771. .rate_min = 8000,
  9772. .rate_max = 352800,
  9773. },
  9774. .name = "TERT_TDM_RX_3",
  9775. .ops = &msm_dai_q6_tdm_ops,
  9776. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  9777. .probe = msm_dai_q6_dai_tdm_probe,
  9778. .remove = msm_dai_q6_dai_tdm_remove,
  9779. },
  9780. {
  9781. .playback = {
  9782. .stream_name = "Tertiary TDM4 Playback",
  9783. .aif_name = "TERT_TDM_RX_4",
  9784. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9785. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9786. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9787. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9788. SNDRV_PCM_FMTBIT_S24_LE |
  9789. SNDRV_PCM_FMTBIT_S32_LE,
  9790. .channels_min = 1,
  9791. .channels_max = 16,
  9792. .rate_min = 8000,
  9793. .rate_max = 352800,
  9794. },
  9795. .name = "TERT_TDM_RX_4",
  9796. .ops = &msm_dai_q6_tdm_ops,
  9797. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  9798. .probe = msm_dai_q6_dai_tdm_probe,
  9799. .remove = msm_dai_q6_dai_tdm_remove,
  9800. },
  9801. {
  9802. .playback = {
  9803. .stream_name = "Tertiary TDM5 Playback",
  9804. .aif_name = "TERT_TDM_RX_5",
  9805. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9806. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9807. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9808. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9809. SNDRV_PCM_FMTBIT_S24_LE |
  9810. SNDRV_PCM_FMTBIT_S32_LE,
  9811. .channels_min = 1,
  9812. .channels_max = 16,
  9813. .rate_min = 8000,
  9814. .rate_max = 352800,
  9815. },
  9816. .name = "TERT_TDM_RX_5",
  9817. .ops = &msm_dai_q6_tdm_ops,
  9818. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  9819. .probe = msm_dai_q6_dai_tdm_probe,
  9820. .remove = msm_dai_q6_dai_tdm_remove,
  9821. },
  9822. {
  9823. .playback = {
  9824. .stream_name = "Tertiary TDM6 Playback",
  9825. .aif_name = "TERT_TDM_RX_6",
  9826. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9827. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9828. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9829. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9830. SNDRV_PCM_FMTBIT_S24_LE |
  9831. SNDRV_PCM_FMTBIT_S32_LE,
  9832. .channels_min = 1,
  9833. .channels_max = 16,
  9834. .rate_min = 8000,
  9835. .rate_max = 352800,
  9836. },
  9837. .name = "TERT_TDM_RX_6",
  9838. .ops = &msm_dai_q6_tdm_ops,
  9839. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  9840. .probe = msm_dai_q6_dai_tdm_probe,
  9841. .remove = msm_dai_q6_dai_tdm_remove,
  9842. },
  9843. {
  9844. .playback = {
  9845. .stream_name = "Tertiary TDM7 Playback",
  9846. .aif_name = "TERT_TDM_RX_7",
  9847. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9848. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9849. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9850. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9851. SNDRV_PCM_FMTBIT_S24_LE |
  9852. SNDRV_PCM_FMTBIT_S32_LE,
  9853. .channels_min = 1,
  9854. .channels_max = 16,
  9855. .rate_min = 8000,
  9856. .rate_max = 352800,
  9857. },
  9858. .name = "TERT_TDM_RX_7",
  9859. .ops = &msm_dai_q6_tdm_ops,
  9860. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  9861. .probe = msm_dai_q6_dai_tdm_probe,
  9862. .remove = msm_dai_q6_dai_tdm_remove,
  9863. },
  9864. {
  9865. .capture = {
  9866. .stream_name = "Tertiary TDM0 Capture",
  9867. .aif_name = "TERT_TDM_TX_0",
  9868. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9869. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9870. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9871. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9872. SNDRV_PCM_FMTBIT_S24_LE |
  9873. SNDRV_PCM_FMTBIT_S32_LE,
  9874. .channels_min = 1,
  9875. .channels_max = 16,
  9876. .rate_min = 8000,
  9877. .rate_max = 352800,
  9878. },
  9879. .name = "TERT_TDM_TX_0",
  9880. .ops = &msm_dai_q6_tdm_ops,
  9881. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  9882. .probe = msm_dai_q6_dai_tdm_probe,
  9883. .remove = msm_dai_q6_dai_tdm_remove,
  9884. },
  9885. {
  9886. .capture = {
  9887. .stream_name = "Tertiary TDM1 Capture",
  9888. .aif_name = "TERT_TDM_TX_1",
  9889. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9890. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9891. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9892. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9893. SNDRV_PCM_FMTBIT_S24_LE |
  9894. SNDRV_PCM_FMTBIT_S32_LE,
  9895. .channels_min = 1,
  9896. .channels_max = 16,
  9897. .rate_min = 8000,
  9898. .rate_max = 352800,
  9899. },
  9900. .name = "TERT_TDM_TX_1",
  9901. .ops = &msm_dai_q6_tdm_ops,
  9902. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  9903. .probe = msm_dai_q6_dai_tdm_probe,
  9904. .remove = msm_dai_q6_dai_tdm_remove,
  9905. },
  9906. {
  9907. .capture = {
  9908. .stream_name = "Tertiary TDM2 Capture",
  9909. .aif_name = "TERT_TDM_TX_2",
  9910. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9911. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9912. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9913. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9914. SNDRV_PCM_FMTBIT_S24_LE |
  9915. SNDRV_PCM_FMTBIT_S32_LE,
  9916. .channels_min = 1,
  9917. .channels_max = 16,
  9918. .rate_min = 8000,
  9919. .rate_max = 352800,
  9920. },
  9921. .name = "TERT_TDM_TX_2",
  9922. .ops = &msm_dai_q6_tdm_ops,
  9923. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  9924. .probe = msm_dai_q6_dai_tdm_probe,
  9925. .remove = msm_dai_q6_dai_tdm_remove,
  9926. },
  9927. {
  9928. .capture = {
  9929. .stream_name = "Tertiary TDM3 Capture",
  9930. .aif_name = "TERT_TDM_TX_3",
  9931. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9932. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9933. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9934. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9935. SNDRV_PCM_FMTBIT_S24_LE |
  9936. SNDRV_PCM_FMTBIT_S32_LE,
  9937. .channels_min = 1,
  9938. .channels_max = 16,
  9939. .rate_min = 8000,
  9940. .rate_max = 352800,
  9941. },
  9942. .name = "TERT_TDM_TX_3",
  9943. .ops = &msm_dai_q6_tdm_ops,
  9944. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  9945. .probe = msm_dai_q6_dai_tdm_probe,
  9946. .remove = msm_dai_q6_dai_tdm_remove,
  9947. },
  9948. {
  9949. .capture = {
  9950. .stream_name = "Tertiary TDM4 Capture",
  9951. .aif_name = "TERT_TDM_TX_4",
  9952. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9953. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9954. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9955. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9956. SNDRV_PCM_FMTBIT_S24_LE |
  9957. SNDRV_PCM_FMTBIT_S32_LE,
  9958. .channels_min = 1,
  9959. .channels_max = 16,
  9960. .rate_min = 8000,
  9961. .rate_max = 352800,
  9962. },
  9963. .name = "TERT_TDM_TX_4",
  9964. .ops = &msm_dai_q6_tdm_ops,
  9965. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  9966. .probe = msm_dai_q6_dai_tdm_probe,
  9967. .remove = msm_dai_q6_dai_tdm_remove,
  9968. },
  9969. {
  9970. .capture = {
  9971. .stream_name = "Tertiary TDM5 Capture",
  9972. .aif_name = "TERT_TDM_TX_5",
  9973. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9974. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9975. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9976. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9977. SNDRV_PCM_FMTBIT_S24_LE |
  9978. SNDRV_PCM_FMTBIT_S32_LE,
  9979. .channels_min = 1,
  9980. .channels_max = 16,
  9981. .rate_min = 8000,
  9982. .rate_max = 352800,
  9983. },
  9984. .name = "TERT_TDM_TX_5",
  9985. .ops = &msm_dai_q6_tdm_ops,
  9986. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  9987. .probe = msm_dai_q6_dai_tdm_probe,
  9988. .remove = msm_dai_q6_dai_tdm_remove,
  9989. },
  9990. {
  9991. .capture = {
  9992. .stream_name = "Tertiary TDM6 Capture",
  9993. .aif_name = "TERT_TDM_TX_6",
  9994. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9995. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9996. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9997. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9998. SNDRV_PCM_FMTBIT_S24_LE |
  9999. SNDRV_PCM_FMTBIT_S32_LE,
  10000. .channels_min = 1,
  10001. .channels_max = 16,
  10002. .rate_min = 8000,
  10003. .rate_max = 352800,
  10004. },
  10005. .name = "TERT_TDM_TX_6",
  10006. .ops = &msm_dai_q6_tdm_ops,
  10007. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  10008. .probe = msm_dai_q6_dai_tdm_probe,
  10009. .remove = msm_dai_q6_dai_tdm_remove,
  10010. },
  10011. {
  10012. .capture = {
  10013. .stream_name = "Tertiary TDM7 Capture",
  10014. .aif_name = "TERT_TDM_TX_7",
  10015. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10016. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10017. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10018. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10019. SNDRV_PCM_FMTBIT_S24_LE |
  10020. SNDRV_PCM_FMTBIT_S32_LE,
  10021. .channels_min = 1,
  10022. .channels_max = 16,
  10023. .rate_min = 8000,
  10024. .rate_max = 352800,
  10025. },
  10026. .name = "TERT_TDM_TX_7",
  10027. .ops = &msm_dai_q6_tdm_ops,
  10028. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  10029. .probe = msm_dai_q6_dai_tdm_probe,
  10030. .remove = msm_dai_q6_dai_tdm_remove,
  10031. },
  10032. {
  10033. .playback = {
  10034. .stream_name = "Quaternary TDM0 Playback",
  10035. .aif_name = "QUAT_TDM_RX_0",
  10036. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10037. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10038. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10039. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10040. SNDRV_PCM_FMTBIT_S24_LE |
  10041. SNDRV_PCM_FMTBIT_S32_LE,
  10042. .channels_min = 1,
  10043. .channels_max = 16,
  10044. .rate_min = 8000,
  10045. .rate_max = 352800,
  10046. },
  10047. .name = "QUAT_TDM_RX_0",
  10048. .ops = &msm_dai_q6_tdm_ops,
  10049. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  10050. .probe = msm_dai_q6_dai_tdm_probe,
  10051. .remove = msm_dai_q6_dai_tdm_remove,
  10052. },
  10053. {
  10054. .playback = {
  10055. .stream_name = "Quaternary TDM1 Playback",
  10056. .aif_name = "QUAT_TDM_RX_1",
  10057. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10058. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10059. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10060. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10061. SNDRV_PCM_FMTBIT_S24_LE |
  10062. SNDRV_PCM_FMTBIT_S32_LE,
  10063. .channels_min = 1,
  10064. .channels_max = 16,
  10065. .rate_min = 8000,
  10066. .rate_max = 352800,
  10067. },
  10068. .name = "QUAT_TDM_RX_1",
  10069. .ops = &msm_dai_q6_tdm_ops,
  10070. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  10071. .probe = msm_dai_q6_dai_tdm_probe,
  10072. .remove = msm_dai_q6_dai_tdm_remove,
  10073. },
  10074. {
  10075. .playback = {
  10076. .stream_name = "Quaternary TDM2 Playback",
  10077. .aif_name = "QUAT_TDM_RX_2",
  10078. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10079. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10080. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10081. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10082. SNDRV_PCM_FMTBIT_S24_LE |
  10083. SNDRV_PCM_FMTBIT_S32_LE,
  10084. .channels_min = 1,
  10085. .channels_max = 16,
  10086. .rate_min = 8000,
  10087. .rate_max = 352800,
  10088. },
  10089. .name = "QUAT_TDM_RX_2",
  10090. .ops = &msm_dai_q6_tdm_ops,
  10091. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  10092. .probe = msm_dai_q6_dai_tdm_probe,
  10093. .remove = msm_dai_q6_dai_tdm_remove,
  10094. },
  10095. {
  10096. .playback = {
  10097. .stream_name = "Quaternary TDM3 Playback",
  10098. .aif_name = "QUAT_TDM_RX_3",
  10099. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10100. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10101. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10102. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10103. SNDRV_PCM_FMTBIT_S24_LE |
  10104. SNDRV_PCM_FMTBIT_S32_LE,
  10105. .channels_min = 1,
  10106. .channels_max = 16,
  10107. .rate_min = 8000,
  10108. .rate_max = 352800,
  10109. },
  10110. .name = "QUAT_TDM_RX_3",
  10111. .ops = &msm_dai_q6_tdm_ops,
  10112. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  10113. .probe = msm_dai_q6_dai_tdm_probe,
  10114. .remove = msm_dai_q6_dai_tdm_remove,
  10115. },
  10116. {
  10117. .playback = {
  10118. .stream_name = "Quaternary TDM4 Playback",
  10119. .aif_name = "QUAT_TDM_RX_4",
  10120. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10121. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10122. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10123. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10124. SNDRV_PCM_FMTBIT_S24_LE |
  10125. SNDRV_PCM_FMTBIT_S32_LE,
  10126. .channels_min = 1,
  10127. .channels_max = 16,
  10128. .rate_min = 8000,
  10129. .rate_max = 352800,
  10130. },
  10131. .name = "QUAT_TDM_RX_4",
  10132. .ops = &msm_dai_q6_tdm_ops,
  10133. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  10134. .probe = msm_dai_q6_dai_tdm_probe,
  10135. .remove = msm_dai_q6_dai_tdm_remove,
  10136. },
  10137. {
  10138. .playback = {
  10139. .stream_name = "Quaternary TDM5 Playback",
  10140. .aif_name = "QUAT_TDM_RX_5",
  10141. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10142. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10143. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10144. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10145. SNDRV_PCM_FMTBIT_S24_LE |
  10146. SNDRV_PCM_FMTBIT_S32_LE,
  10147. .channels_min = 1,
  10148. .channels_max = 16,
  10149. .rate_min = 8000,
  10150. .rate_max = 352800,
  10151. },
  10152. .name = "QUAT_TDM_RX_5",
  10153. .ops = &msm_dai_q6_tdm_ops,
  10154. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  10155. .probe = msm_dai_q6_dai_tdm_probe,
  10156. .remove = msm_dai_q6_dai_tdm_remove,
  10157. },
  10158. {
  10159. .playback = {
  10160. .stream_name = "Quaternary TDM6 Playback",
  10161. .aif_name = "QUAT_TDM_RX_6",
  10162. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10163. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10164. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10165. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10166. SNDRV_PCM_FMTBIT_S24_LE |
  10167. SNDRV_PCM_FMTBIT_S32_LE,
  10168. .channels_min = 1,
  10169. .channels_max = 16,
  10170. .rate_min = 8000,
  10171. .rate_max = 352800,
  10172. },
  10173. .name = "QUAT_TDM_RX_6",
  10174. .ops = &msm_dai_q6_tdm_ops,
  10175. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  10176. .probe = msm_dai_q6_dai_tdm_probe,
  10177. .remove = msm_dai_q6_dai_tdm_remove,
  10178. },
  10179. {
  10180. .playback = {
  10181. .stream_name = "Quaternary TDM7 Playback",
  10182. .aif_name = "QUAT_TDM_RX_7",
  10183. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10184. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10185. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10186. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10187. SNDRV_PCM_FMTBIT_S24_LE |
  10188. SNDRV_PCM_FMTBIT_S32_LE,
  10189. .channels_min = 1,
  10190. .channels_max = 16,
  10191. .rate_min = 8000,
  10192. .rate_max = 352800,
  10193. },
  10194. .name = "QUAT_TDM_RX_7",
  10195. .ops = &msm_dai_q6_tdm_ops,
  10196. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  10197. .probe = msm_dai_q6_dai_tdm_probe,
  10198. .remove = msm_dai_q6_dai_tdm_remove,
  10199. },
  10200. {
  10201. .capture = {
  10202. .stream_name = "Quaternary TDM0 Capture",
  10203. .aif_name = "QUAT_TDM_TX_0",
  10204. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10205. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10206. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10207. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10208. SNDRV_PCM_FMTBIT_S24_LE |
  10209. SNDRV_PCM_FMTBIT_S32_LE,
  10210. .channels_min = 1,
  10211. .channels_max = 16,
  10212. .rate_min = 8000,
  10213. .rate_max = 352800,
  10214. },
  10215. .name = "QUAT_TDM_TX_0",
  10216. .ops = &msm_dai_q6_tdm_ops,
  10217. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  10218. .probe = msm_dai_q6_dai_tdm_probe,
  10219. .remove = msm_dai_q6_dai_tdm_remove,
  10220. },
  10221. {
  10222. .capture = {
  10223. .stream_name = "Quaternary TDM1 Capture",
  10224. .aif_name = "QUAT_TDM_TX_1",
  10225. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10226. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10227. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10228. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10229. SNDRV_PCM_FMTBIT_S24_LE |
  10230. SNDRV_PCM_FMTBIT_S32_LE,
  10231. .channels_min = 1,
  10232. .channels_max = 16,
  10233. .rate_min = 8000,
  10234. .rate_max = 352800,
  10235. },
  10236. .name = "QUAT_TDM_TX_1",
  10237. .ops = &msm_dai_q6_tdm_ops,
  10238. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  10239. .probe = msm_dai_q6_dai_tdm_probe,
  10240. .remove = msm_dai_q6_dai_tdm_remove,
  10241. },
  10242. {
  10243. .capture = {
  10244. .stream_name = "Quaternary TDM2 Capture",
  10245. .aif_name = "QUAT_TDM_TX_2",
  10246. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10247. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10248. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10249. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10250. SNDRV_PCM_FMTBIT_S24_LE |
  10251. SNDRV_PCM_FMTBIT_S32_LE,
  10252. .channels_min = 1,
  10253. .channels_max = 16,
  10254. .rate_min = 8000,
  10255. .rate_max = 352800,
  10256. },
  10257. .name = "QUAT_TDM_TX_2",
  10258. .ops = &msm_dai_q6_tdm_ops,
  10259. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  10260. .probe = msm_dai_q6_dai_tdm_probe,
  10261. .remove = msm_dai_q6_dai_tdm_remove,
  10262. },
  10263. {
  10264. .capture = {
  10265. .stream_name = "Quaternary TDM3 Capture",
  10266. .aif_name = "QUAT_TDM_TX_3",
  10267. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10268. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10269. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10270. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10271. SNDRV_PCM_FMTBIT_S24_LE |
  10272. SNDRV_PCM_FMTBIT_S32_LE,
  10273. .channels_min = 1,
  10274. .channels_max = 16,
  10275. .rate_min = 8000,
  10276. .rate_max = 352800,
  10277. },
  10278. .name = "QUAT_TDM_TX_3",
  10279. .ops = &msm_dai_q6_tdm_ops,
  10280. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  10281. .probe = msm_dai_q6_dai_tdm_probe,
  10282. .remove = msm_dai_q6_dai_tdm_remove,
  10283. },
  10284. {
  10285. .capture = {
  10286. .stream_name = "Quaternary TDM4 Capture",
  10287. .aif_name = "QUAT_TDM_TX_4",
  10288. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10289. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10290. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10291. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10292. SNDRV_PCM_FMTBIT_S24_LE |
  10293. SNDRV_PCM_FMTBIT_S32_LE,
  10294. .channels_min = 1,
  10295. .channels_max = 16,
  10296. .rate_min = 8000,
  10297. .rate_max = 352800,
  10298. },
  10299. .name = "QUAT_TDM_TX_4",
  10300. .ops = &msm_dai_q6_tdm_ops,
  10301. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  10302. .probe = msm_dai_q6_dai_tdm_probe,
  10303. .remove = msm_dai_q6_dai_tdm_remove,
  10304. },
  10305. {
  10306. .capture = {
  10307. .stream_name = "Quaternary TDM5 Capture",
  10308. .aif_name = "QUAT_TDM_TX_5",
  10309. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10310. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10311. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10312. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10313. SNDRV_PCM_FMTBIT_S24_LE |
  10314. SNDRV_PCM_FMTBIT_S32_LE,
  10315. .channels_min = 1,
  10316. .channels_max = 16,
  10317. .rate_min = 8000,
  10318. .rate_max = 352800,
  10319. },
  10320. .name = "QUAT_TDM_TX_5",
  10321. .ops = &msm_dai_q6_tdm_ops,
  10322. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  10323. .probe = msm_dai_q6_dai_tdm_probe,
  10324. .remove = msm_dai_q6_dai_tdm_remove,
  10325. },
  10326. {
  10327. .capture = {
  10328. .stream_name = "Quaternary TDM6 Capture",
  10329. .aif_name = "QUAT_TDM_TX_6",
  10330. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10331. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10332. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10333. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10334. SNDRV_PCM_FMTBIT_S24_LE |
  10335. SNDRV_PCM_FMTBIT_S32_LE,
  10336. .channels_min = 1,
  10337. .channels_max = 16,
  10338. .rate_min = 8000,
  10339. .rate_max = 352800,
  10340. },
  10341. .name = "QUAT_TDM_TX_6",
  10342. .ops = &msm_dai_q6_tdm_ops,
  10343. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  10344. .probe = msm_dai_q6_dai_tdm_probe,
  10345. .remove = msm_dai_q6_dai_tdm_remove,
  10346. },
  10347. {
  10348. .capture = {
  10349. .stream_name = "Quaternary TDM7 Capture",
  10350. .aif_name = "QUAT_TDM_TX_7",
  10351. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10352. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10353. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10354. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10355. SNDRV_PCM_FMTBIT_S24_LE |
  10356. SNDRV_PCM_FMTBIT_S32_LE,
  10357. .channels_min = 1,
  10358. .channels_max = 16,
  10359. .rate_min = 8000,
  10360. .rate_max = 352800,
  10361. },
  10362. .name = "QUAT_TDM_TX_7",
  10363. .ops = &msm_dai_q6_tdm_ops,
  10364. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  10365. .probe = msm_dai_q6_dai_tdm_probe,
  10366. .remove = msm_dai_q6_dai_tdm_remove,
  10367. },
  10368. {
  10369. .playback = {
  10370. .stream_name = "Quinary TDM0 Playback",
  10371. .aif_name = "QUIN_TDM_RX_0",
  10372. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10373. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10374. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10375. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10376. SNDRV_PCM_FMTBIT_S24_LE |
  10377. SNDRV_PCM_FMTBIT_S32_LE,
  10378. .channels_min = 1,
  10379. .channels_max = 16,
  10380. .rate_min = 8000,
  10381. .rate_max = 352800,
  10382. },
  10383. .name = "QUIN_TDM_RX_0",
  10384. .ops = &msm_dai_q6_tdm_ops,
  10385. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  10386. .probe = msm_dai_q6_dai_tdm_probe,
  10387. .remove = msm_dai_q6_dai_tdm_remove,
  10388. },
  10389. {
  10390. .playback = {
  10391. .stream_name = "Quinary TDM1 Playback",
  10392. .aif_name = "QUIN_TDM_RX_1",
  10393. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10394. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10395. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10396. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10397. SNDRV_PCM_FMTBIT_S24_LE |
  10398. SNDRV_PCM_FMTBIT_S32_LE,
  10399. .channels_min = 1,
  10400. .channels_max = 16,
  10401. .rate_min = 8000,
  10402. .rate_max = 352800,
  10403. },
  10404. .name = "QUIN_TDM_RX_1",
  10405. .ops = &msm_dai_q6_tdm_ops,
  10406. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  10407. .probe = msm_dai_q6_dai_tdm_probe,
  10408. .remove = msm_dai_q6_dai_tdm_remove,
  10409. },
  10410. {
  10411. .playback = {
  10412. .stream_name = "Quinary TDM2 Playback",
  10413. .aif_name = "QUIN_TDM_RX_2",
  10414. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10415. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10416. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10417. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10418. SNDRV_PCM_FMTBIT_S24_LE |
  10419. SNDRV_PCM_FMTBIT_S32_LE,
  10420. .channels_min = 1,
  10421. .channels_max = 16,
  10422. .rate_min = 8000,
  10423. .rate_max = 352800,
  10424. },
  10425. .name = "QUIN_TDM_RX_2",
  10426. .ops = &msm_dai_q6_tdm_ops,
  10427. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  10428. .probe = msm_dai_q6_dai_tdm_probe,
  10429. .remove = msm_dai_q6_dai_tdm_remove,
  10430. },
  10431. {
  10432. .playback = {
  10433. .stream_name = "Quinary TDM3 Playback",
  10434. .aif_name = "QUIN_TDM_RX_3",
  10435. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10436. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10437. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10438. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10439. SNDRV_PCM_FMTBIT_S24_LE |
  10440. SNDRV_PCM_FMTBIT_S32_LE,
  10441. .channels_min = 1,
  10442. .channels_max = 16,
  10443. .rate_min = 8000,
  10444. .rate_max = 352800,
  10445. },
  10446. .name = "QUIN_TDM_RX_3",
  10447. .ops = &msm_dai_q6_tdm_ops,
  10448. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  10449. .probe = msm_dai_q6_dai_tdm_probe,
  10450. .remove = msm_dai_q6_dai_tdm_remove,
  10451. },
  10452. {
  10453. .playback = {
  10454. .stream_name = "Quinary TDM4 Playback",
  10455. .aif_name = "QUIN_TDM_RX_4",
  10456. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10457. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10458. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10459. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10460. SNDRV_PCM_FMTBIT_S24_LE |
  10461. SNDRV_PCM_FMTBIT_S32_LE,
  10462. .channels_min = 1,
  10463. .channels_max = 16,
  10464. .rate_min = 8000,
  10465. .rate_max = 352800,
  10466. },
  10467. .name = "QUIN_TDM_RX_4",
  10468. .ops = &msm_dai_q6_tdm_ops,
  10469. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  10470. .probe = msm_dai_q6_dai_tdm_probe,
  10471. .remove = msm_dai_q6_dai_tdm_remove,
  10472. },
  10473. {
  10474. .playback = {
  10475. .stream_name = "Quinary TDM5 Playback",
  10476. .aif_name = "QUIN_TDM_RX_5",
  10477. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10478. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10479. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10480. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10481. SNDRV_PCM_FMTBIT_S24_LE |
  10482. SNDRV_PCM_FMTBIT_S32_LE,
  10483. .channels_min = 1,
  10484. .channels_max = 16,
  10485. .rate_min = 8000,
  10486. .rate_max = 352800,
  10487. },
  10488. .name = "QUIN_TDM_RX_5",
  10489. .ops = &msm_dai_q6_tdm_ops,
  10490. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  10491. .probe = msm_dai_q6_dai_tdm_probe,
  10492. .remove = msm_dai_q6_dai_tdm_remove,
  10493. },
  10494. {
  10495. .playback = {
  10496. .stream_name = "Quinary TDM6 Playback",
  10497. .aif_name = "QUIN_TDM_RX_6",
  10498. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10499. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10500. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10501. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10502. SNDRV_PCM_FMTBIT_S24_LE |
  10503. SNDRV_PCM_FMTBIT_S32_LE,
  10504. .channels_min = 1,
  10505. .channels_max = 16,
  10506. .rate_min = 8000,
  10507. .rate_max = 352800,
  10508. },
  10509. .name = "QUIN_TDM_RX_6",
  10510. .ops = &msm_dai_q6_tdm_ops,
  10511. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  10512. .probe = msm_dai_q6_dai_tdm_probe,
  10513. .remove = msm_dai_q6_dai_tdm_remove,
  10514. },
  10515. {
  10516. .playback = {
  10517. .stream_name = "Quinary TDM7 Playback",
  10518. .aif_name = "QUIN_TDM_RX_7",
  10519. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10520. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10521. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10522. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10523. SNDRV_PCM_FMTBIT_S24_LE |
  10524. SNDRV_PCM_FMTBIT_S32_LE,
  10525. .channels_min = 1,
  10526. .channels_max = 16,
  10527. .rate_min = 8000,
  10528. .rate_max = 352800,
  10529. },
  10530. .name = "QUIN_TDM_RX_7",
  10531. .ops = &msm_dai_q6_tdm_ops,
  10532. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  10533. .probe = msm_dai_q6_dai_tdm_probe,
  10534. .remove = msm_dai_q6_dai_tdm_remove,
  10535. },
  10536. {
  10537. .capture = {
  10538. .stream_name = "Quinary TDM0 Capture",
  10539. .aif_name = "QUIN_TDM_TX_0",
  10540. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10541. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10542. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10543. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10544. SNDRV_PCM_FMTBIT_S24_LE |
  10545. SNDRV_PCM_FMTBIT_S32_LE,
  10546. .channels_min = 1,
  10547. .channels_max = 16,
  10548. .rate_min = 8000,
  10549. .rate_max = 352800,
  10550. },
  10551. .name = "QUIN_TDM_TX_0",
  10552. .ops = &msm_dai_q6_tdm_ops,
  10553. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  10554. .probe = msm_dai_q6_dai_tdm_probe,
  10555. .remove = msm_dai_q6_dai_tdm_remove,
  10556. },
  10557. {
  10558. .capture = {
  10559. .stream_name = "Quinary TDM1 Capture",
  10560. .aif_name = "QUIN_TDM_TX_1",
  10561. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10562. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10563. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10564. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10565. SNDRV_PCM_FMTBIT_S24_LE |
  10566. SNDRV_PCM_FMTBIT_S32_LE,
  10567. .channels_min = 1,
  10568. .channels_max = 16,
  10569. .rate_min = 8000,
  10570. .rate_max = 352800,
  10571. },
  10572. .name = "QUIN_TDM_TX_1",
  10573. .ops = &msm_dai_q6_tdm_ops,
  10574. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  10575. .probe = msm_dai_q6_dai_tdm_probe,
  10576. .remove = msm_dai_q6_dai_tdm_remove,
  10577. },
  10578. {
  10579. .capture = {
  10580. .stream_name = "Quinary TDM2 Capture",
  10581. .aif_name = "QUIN_TDM_TX_2",
  10582. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10583. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10584. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10585. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10586. SNDRV_PCM_FMTBIT_S24_LE |
  10587. SNDRV_PCM_FMTBIT_S32_LE,
  10588. .channels_min = 1,
  10589. .channels_max = 16,
  10590. .rate_min = 8000,
  10591. .rate_max = 352800,
  10592. },
  10593. .name = "QUIN_TDM_TX_2",
  10594. .ops = &msm_dai_q6_tdm_ops,
  10595. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  10596. .probe = msm_dai_q6_dai_tdm_probe,
  10597. .remove = msm_dai_q6_dai_tdm_remove,
  10598. },
  10599. {
  10600. .capture = {
  10601. .stream_name = "Quinary TDM3 Capture",
  10602. .aif_name = "QUIN_TDM_TX_3",
  10603. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10604. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10605. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10606. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10607. SNDRV_PCM_FMTBIT_S24_LE |
  10608. SNDRV_PCM_FMTBIT_S32_LE,
  10609. .channels_min = 1,
  10610. .channels_max = 16,
  10611. .rate_min = 8000,
  10612. .rate_max = 352800,
  10613. },
  10614. .name = "QUIN_TDM_TX_3",
  10615. .ops = &msm_dai_q6_tdm_ops,
  10616. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  10617. .probe = msm_dai_q6_dai_tdm_probe,
  10618. .remove = msm_dai_q6_dai_tdm_remove,
  10619. },
  10620. {
  10621. .capture = {
  10622. .stream_name = "Quinary TDM4 Capture",
  10623. .aif_name = "QUIN_TDM_TX_4",
  10624. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10625. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10626. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10627. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10628. SNDRV_PCM_FMTBIT_S24_LE |
  10629. SNDRV_PCM_FMTBIT_S32_LE,
  10630. .channels_min = 1,
  10631. .channels_max = 16,
  10632. .rate_min = 8000,
  10633. .rate_max = 352800,
  10634. },
  10635. .name = "QUIN_TDM_TX_4",
  10636. .ops = &msm_dai_q6_tdm_ops,
  10637. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  10638. .probe = msm_dai_q6_dai_tdm_probe,
  10639. .remove = msm_dai_q6_dai_tdm_remove,
  10640. },
  10641. {
  10642. .capture = {
  10643. .stream_name = "Quinary TDM5 Capture",
  10644. .aif_name = "QUIN_TDM_TX_5",
  10645. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10646. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10647. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10648. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10649. SNDRV_PCM_FMTBIT_S24_LE |
  10650. SNDRV_PCM_FMTBIT_S32_LE,
  10651. .channels_min = 1,
  10652. .channels_max = 16,
  10653. .rate_min = 8000,
  10654. .rate_max = 352800,
  10655. },
  10656. .name = "QUIN_TDM_TX_5",
  10657. .ops = &msm_dai_q6_tdm_ops,
  10658. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  10659. .probe = msm_dai_q6_dai_tdm_probe,
  10660. .remove = msm_dai_q6_dai_tdm_remove,
  10661. },
  10662. {
  10663. .capture = {
  10664. .stream_name = "Quinary TDM6 Capture",
  10665. .aif_name = "QUIN_TDM_TX_6",
  10666. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10667. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10668. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10669. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10670. SNDRV_PCM_FMTBIT_S24_LE |
  10671. SNDRV_PCM_FMTBIT_S32_LE,
  10672. .channels_min = 1,
  10673. .channels_max = 16,
  10674. .rate_min = 8000,
  10675. .rate_max = 352800,
  10676. },
  10677. .name = "QUIN_TDM_TX_6",
  10678. .ops = &msm_dai_q6_tdm_ops,
  10679. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  10680. .probe = msm_dai_q6_dai_tdm_probe,
  10681. .remove = msm_dai_q6_dai_tdm_remove,
  10682. },
  10683. {
  10684. .capture = {
  10685. .stream_name = "Quinary TDM7 Capture",
  10686. .aif_name = "QUIN_TDM_TX_7",
  10687. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10688. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10689. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10690. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10691. SNDRV_PCM_FMTBIT_S24_LE |
  10692. SNDRV_PCM_FMTBIT_S32_LE,
  10693. .channels_min = 1,
  10694. .channels_max = 16,
  10695. .rate_min = 8000,
  10696. .rate_max = 352800,
  10697. },
  10698. .name = "QUIN_TDM_TX_7",
  10699. .ops = &msm_dai_q6_tdm_ops,
  10700. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  10701. .probe = msm_dai_q6_dai_tdm_probe,
  10702. .remove = msm_dai_q6_dai_tdm_remove,
  10703. },
  10704. {
  10705. .playback = {
  10706. .stream_name = "Senary TDM0 Playback",
  10707. .aif_name = "SEN_TDM_RX_0",
  10708. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10709. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10710. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10711. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10712. SNDRV_PCM_FMTBIT_S24_LE |
  10713. SNDRV_PCM_FMTBIT_S32_LE,
  10714. .channels_min = 1,
  10715. .channels_max = 8,
  10716. .rate_min = 8000,
  10717. .rate_max = 352800,
  10718. },
  10719. .name = "SEN_TDM_RX_0",
  10720. .ops = &msm_dai_q6_tdm_ops,
  10721. .id = AFE_PORT_ID_SENARY_TDM_RX,
  10722. .probe = msm_dai_q6_dai_tdm_probe,
  10723. .remove = msm_dai_q6_dai_tdm_remove,
  10724. },
  10725. {
  10726. .playback = {
  10727. .stream_name = "Senary TDM1 Playback",
  10728. .aif_name = "SEN_TDM_RX_1",
  10729. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10730. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10731. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10732. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10733. SNDRV_PCM_FMTBIT_S24_LE |
  10734. SNDRV_PCM_FMTBIT_S32_LE,
  10735. .channels_min = 1,
  10736. .channels_max = 8,
  10737. .rate_min = 8000,
  10738. .rate_max = 352800,
  10739. },
  10740. .name = "SEN_TDM_RX_1",
  10741. .ops = &msm_dai_q6_tdm_ops,
  10742. .id = AFE_PORT_ID_SENARY_TDM_RX_1,
  10743. .probe = msm_dai_q6_dai_tdm_probe,
  10744. .remove = msm_dai_q6_dai_tdm_remove,
  10745. },
  10746. {
  10747. .playback = {
  10748. .stream_name = "Senary TDM2 Playback",
  10749. .aif_name = "SEN_TDM_RX_2",
  10750. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10751. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10752. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10753. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10754. SNDRV_PCM_FMTBIT_S24_LE |
  10755. SNDRV_PCM_FMTBIT_S32_LE,
  10756. .channels_min = 1,
  10757. .channels_max = 8,
  10758. .rate_min = 8000,
  10759. .rate_max = 352800,
  10760. },
  10761. .name = "SEN_TDM_RX_2",
  10762. .ops = &msm_dai_q6_tdm_ops,
  10763. .id = AFE_PORT_ID_SENARY_TDM_RX_2,
  10764. .probe = msm_dai_q6_dai_tdm_probe,
  10765. .remove = msm_dai_q6_dai_tdm_remove,
  10766. },
  10767. {
  10768. .playback = {
  10769. .stream_name = "Senary TDM3 Playback",
  10770. .aif_name = "SEN_TDM_RX_3",
  10771. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10772. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10773. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10774. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10775. SNDRV_PCM_FMTBIT_S24_LE |
  10776. SNDRV_PCM_FMTBIT_S32_LE,
  10777. .channels_min = 1,
  10778. .channels_max = 8,
  10779. .rate_min = 8000,
  10780. .rate_max = 352800,
  10781. },
  10782. .name = "SEN_TDM_RX_3",
  10783. .ops = &msm_dai_q6_tdm_ops,
  10784. .id = AFE_PORT_ID_SENARY_TDM_RX_3,
  10785. .probe = msm_dai_q6_dai_tdm_probe,
  10786. .remove = msm_dai_q6_dai_tdm_remove,
  10787. },
  10788. {
  10789. .playback = {
  10790. .stream_name = "Senary TDM4 Playback",
  10791. .aif_name = "SEN_TDM_RX_4",
  10792. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10793. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10794. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10795. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10796. SNDRV_PCM_FMTBIT_S24_LE |
  10797. SNDRV_PCM_FMTBIT_S32_LE,
  10798. .channels_min = 1,
  10799. .channels_max = 8,
  10800. .rate_min = 8000,
  10801. .rate_max = 352800,
  10802. },
  10803. .name = "SEN_TDM_RX_4",
  10804. .ops = &msm_dai_q6_tdm_ops,
  10805. .id = AFE_PORT_ID_SENARY_TDM_RX_4,
  10806. .probe = msm_dai_q6_dai_tdm_probe,
  10807. .remove = msm_dai_q6_dai_tdm_remove,
  10808. },
  10809. {
  10810. .playback = {
  10811. .stream_name = "Senary TDM5 Playback",
  10812. .aif_name = "SEN_TDM_RX_5",
  10813. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10814. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10815. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10816. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10817. SNDRV_PCM_FMTBIT_S24_LE |
  10818. SNDRV_PCM_FMTBIT_S32_LE,
  10819. .channels_min = 1,
  10820. .channels_max = 8,
  10821. .rate_min = 8000,
  10822. .rate_max = 352800,
  10823. },
  10824. .name = "SEN_TDM_RX_5",
  10825. .ops = &msm_dai_q6_tdm_ops,
  10826. .id = AFE_PORT_ID_SENARY_TDM_RX_5,
  10827. .probe = msm_dai_q6_dai_tdm_probe,
  10828. .remove = msm_dai_q6_dai_tdm_remove,
  10829. },
  10830. {
  10831. .playback = {
  10832. .stream_name = "Senary TDM6 Playback",
  10833. .aif_name = "SEN_TDM_RX_6",
  10834. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10835. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10836. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10837. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10838. SNDRV_PCM_FMTBIT_S24_LE |
  10839. SNDRV_PCM_FMTBIT_S32_LE,
  10840. .channels_min = 1,
  10841. .channels_max = 8,
  10842. .rate_min = 8000,
  10843. .rate_max = 352800,
  10844. },
  10845. .name = "SEN_TDM_RX_6",
  10846. .ops = &msm_dai_q6_tdm_ops,
  10847. .id = AFE_PORT_ID_SENARY_TDM_RX_6,
  10848. .probe = msm_dai_q6_dai_tdm_probe,
  10849. .remove = msm_dai_q6_dai_tdm_remove,
  10850. },
  10851. {
  10852. .playback = {
  10853. .stream_name = "Senary TDM7 Playback",
  10854. .aif_name = "SEN_TDM_RX_7",
  10855. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10856. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10857. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10858. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10859. SNDRV_PCM_FMTBIT_S24_LE |
  10860. SNDRV_PCM_FMTBIT_S32_LE,
  10861. .channels_min = 1,
  10862. .channels_max = 8,
  10863. .rate_min = 8000,
  10864. .rate_max = 352800,
  10865. },
  10866. .name = "SEN_TDM_RX_7",
  10867. .ops = &msm_dai_q6_tdm_ops,
  10868. .id = AFE_PORT_ID_SENARY_TDM_RX_7,
  10869. .probe = msm_dai_q6_dai_tdm_probe,
  10870. .remove = msm_dai_q6_dai_tdm_remove,
  10871. },
  10872. {
  10873. .capture = {
  10874. .stream_name = "Senary TDM0 Capture",
  10875. .aif_name = "SEN_TDM_TX_0",
  10876. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10877. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10878. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10879. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10880. SNDRV_PCM_FMTBIT_S24_LE |
  10881. SNDRV_PCM_FMTBIT_S32_LE,
  10882. .channels_min = 1,
  10883. .channels_max = 8,
  10884. .rate_min = 8000,
  10885. .rate_max = 352800,
  10886. },
  10887. .name = "SEN_TDM_TX_0",
  10888. .ops = &msm_dai_q6_tdm_ops,
  10889. .id = AFE_PORT_ID_SENARY_TDM_TX,
  10890. .probe = msm_dai_q6_dai_tdm_probe,
  10891. .remove = msm_dai_q6_dai_tdm_remove,
  10892. },
  10893. {
  10894. .capture = {
  10895. .stream_name = "Senary TDM1 Capture",
  10896. .aif_name = "SEN_TDM_TX_1",
  10897. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10898. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10899. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10900. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10901. SNDRV_PCM_FMTBIT_S24_LE |
  10902. SNDRV_PCM_FMTBIT_S32_LE,
  10903. .channels_min = 1,
  10904. .channels_max = 8,
  10905. .rate_min = 8000,
  10906. .rate_max = 352800,
  10907. },
  10908. .name = "SEN_TDM_TX_1",
  10909. .ops = &msm_dai_q6_tdm_ops,
  10910. .id = AFE_PORT_ID_SENARY_TDM_TX_1,
  10911. .probe = msm_dai_q6_dai_tdm_probe,
  10912. .remove = msm_dai_q6_dai_tdm_remove,
  10913. },
  10914. {
  10915. .capture = {
  10916. .stream_name = "Senary TDM2 Capture",
  10917. .aif_name = "SEN_TDM_TX_2",
  10918. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10919. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10920. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10921. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10922. SNDRV_PCM_FMTBIT_S24_LE |
  10923. SNDRV_PCM_FMTBIT_S32_LE,
  10924. .channels_min = 1,
  10925. .channels_max = 8,
  10926. .rate_min = 8000,
  10927. .rate_max = 352800,
  10928. },
  10929. .name = "SEN_TDM_TX_2",
  10930. .ops = &msm_dai_q6_tdm_ops,
  10931. .id = AFE_PORT_ID_SENARY_TDM_TX_2,
  10932. .probe = msm_dai_q6_dai_tdm_probe,
  10933. .remove = msm_dai_q6_dai_tdm_remove,
  10934. },
  10935. {
  10936. .capture = {
  10937. .stream_name = "Senary TDM3 Capture",
  10938. .aif_name = "SEN_TDM_TX_3",
  10939. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10940. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10941. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10942. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10943. SNDRV_PCM_FMTBIT_S24_LE |
  10944. SNDRV_PCM_FMTBIT_S32_LE,
  10945. .channels_min = 1,
  10946. .channels_max = 8,
  10947. .rate_min = 8000,
  10948. .rate_max = 352800,
  10949. },
  10950. .name = "SEN_TDM_TX_3",
  10951. .ops = &msm_dai_q6_tdm_ops,
  10952. .id = AFE_PORT_ID_SENARY_TDM_TX_3,
  10953. .probe = msm_dai_q6_dai_tdm_probe,
  10954. .remove = msm_dai_q6_dai_tdm_remove,
  10955. },
  10956. {
  10957. .capture = {
  10958. .stream_name = "Senary TDM4 Capture",
  10959. .aif_name = "SEN_TDM_TX_4",
  10960. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10961. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10962. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10963. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10964. SNDRV_PCM_FMTBIT_S24_LE |
  10965. SNDRV_PCM_FMTBIT_S32_LE,
  10966. .channels_min = 1,
  10967. .channels_max = 8,
  10968. .rate_min = 8000,
  10969. .rate_max = 352800,
  10970. },
  10971. .name = "SEN_TDM_TX_4",
  10972. .ops = &msm_dai_q6_tdm_ops,
  10973. .id = AFE_PORT_ID_SENARY_TDM_TX_4,
  10974. .probe = msm_dai_q6_dai_tdm_probe,
  10975. .remove = msm_dai_q6_dai_tdm_remove,
  10976. },
  10977. {
  10978. .capture = {
  10979. .stream_name = "Senary TDM5 Capture",
  10980. .aif_name = "SEN_TDM_TX_5",
  10981. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10982. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10983. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10984. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10985. SNDRV_PCM_FMTBIT_S24_LE |
  10986. SNDRV_PCM_FMTBIT_S32_LE,
  10987. .channels_min = 1,
  10988. .channels_max = 8,
  10989. .rate_min = 8000,
  10990. .rate_max = 352800,
  10991. },
  10992. .name = "SEN_TDM_TX_5",
  10993. .ops = &msm_dai_q6_tdm_ops,
  10994. .id = AFE_PORT_ID_SENARY_TDM_TX_5,
  10995. .probe = msm_dai_q6_dai_tdm_probe,
  10996. .remove = msm_dai_q6_dai_tdm_remove,
  10997. },
  10998. {
  10999. .capture = {
  11000. .stream_name = "Senary TDM6 Capture",
  11001. .aif_name = "SEN_TDM_TX_6",
  11002. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11003. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11004. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11005. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11006. SNDRV_PCM_FMTBIT_S24_LE |
  11007. SNDRV_PCM_FMTBIT_S32_LE,
  11008. .channels_min = 1,
  11009. .channels_max = 8,
  11010. .rate_min = 8000,
  11011. .rate_max = 352800,
  11012. },
  11013. .name = "SEN_TDM_TX_6",
  11014. .ops = &msm_dai_q6_tdm_ops,
  11015. .id = AFE_PORT_ID_SENARY_TDM_TX_6,
  11016. .probe = msm_dai_q6_dai_tdm_probe,
  11017. .remove = msm_dai_q6_dai_tdm_remove,
  11018. },
  11019. {
  11020. .capture = {
  11021. .stream_name = "Senary TDM7 Capture",
  11022. .aif_name = "SEN_TDM_TX_7",
  11023. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11024. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11025. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11026. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11027. SNDRV_PCM_FMTBIT_S24_LE |
  11028. SNDRV_PCM_FMTBIT_S32_LE,
  11029. .channels_min = 1,
  11030. .channels_max = 8,
  11031. .rate_min = 8000,
  11032. .rate_max = 352800,
  11033. },
  11034. .name = "SEN_TDM_TX_7",
  11035. .ops = &msm_dai_q6_tdm_ops,
  11036. .id = AFE_PORT_ID_SENARY_TDM_TX_7,
  11037. .probe = msm_dai_q6_dai_tdm_probe,
  11038. .remove = msm_dai_q6_dai_tdm_remove,
  11039. },
  11040. };
  11041. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  11042. .name = "msm-dai-q6-tdm",
  11043. };
  11044. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  11045. {
  11046. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  11047. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  11048. int rc = 0;
  11049. u32 tdm_dev_id = 0;
  11050. int port_idx = 0;
  11051. struct device_node *tdm_parent_node = NULL;
  11052. /* retrieve device/afe id */
  11053. rc = of_property_read_u32(pdev->dev.of_node,
  11054. "qcom,msm-cpudai-tdm-dev-id",
  11055. &tdm_dev_id);
  11056. if (rc) {
  11057. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  11058. __func__);
  11059. goto rtn;
  11060. }
  11061. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  11062. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  11063. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  11064. __func__, tdm_dev_id);
  11065. rc = -ENXIO;
  11066. goto rtn;
  11067. }
  11068. pdev->id = tdm_dev_id;
  11069. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  11070. GFP_KERNEL);
  11071. if (!dai_data) {
  11072. rc = -ENOMEM;
  11073. dev_err(&pdev->dev,
  11074. "%s Failed to allocate memory for tdm dai_data\n",
  11075. __func__);
  11076. goto rtn;
  11077. }
  11078. memset(dai_data, 0, sizeof(*dai_data));
  11079. rc = of_property_read_u32(pdev->dev.of_node,
  11080. "qcom,msm-dai-is-island-supported",
  11081. &dai_data->is_island_dai);
  11082. if (rc)
  11083. dev_dbg(&pdev->dev, "island supported entry not found\n");
  11084. /* TDM CFG */
  11085. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  11086. rc = of_property_read_u32(tdm_parent_node,
  11087. "qcom,msm-cpudai-tdm-sync-mode",
  11088. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  11089. if (rc) {
  11090. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  11091. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  11092. goto free_dai_data;
  11093. }
  11094. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  11095. __func__, dai_data->port_cfg.tdm.sync_mode);
  11096. rc = of_property_read_u32(tdm_parent_node,
  11097. "qcom,msm-cpudai-tdm-sync-src",
  11098. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  11099. if (rc) {
  11100. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  11101. __func__, "qcom,msm-cpudai-tdm-sync-src");
  11102. goto free_dai_data;
  11103. }
  11104. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  11105. __func__, dai_data->port_cfg.tdm.sync_src);
  11106. rc = of_property_read_u32(tdm_parent_node,
  11107. "qcom,msm-cpudai-tdm-data-out",
  11108. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11109. if (rc) {
  11110. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  11111. __func__, "qcom,msm-cpudai-tdm-data-out");
  11112. goto free_dai_data;
  11113. }
  11114. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  11115. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11116. rc = of_property_read_u32(tdm_parent_node,
  11117. "qcom,msm-cpudai-tdm-invert-sync",
  11118. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11119. if (rc) {
  11120. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  11121. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  11122. goto free_dai_data;
  11123. }
  11124. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  11125. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11126. rc = of_property_read_u32(tdm_parent_node,
  11127. "qcom,msm-cpudai-tdm-data-delay",
  11128. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11129. if (rc) {
  11130. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  11131. __func__, "qcom,msm-cpudai-tdm-data-delay");
  11132. goto free_dai_data;
  11133. }
  11134. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  11135. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11136. /* TDM CFG -- set default */
  11137. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  11138. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  11139. AFE_API_VERSION_TDM_CONFIG;
  11140. /* TDM SLOT MAPPING CFG */
  11141. rc = of_property_read_u32(pdev->dev.of_node,
  11142. "qcom,msm-cpudai-tdm-data-align",
  11143. &dai_data->port_cfg.slot_mapping.data_align_type);
  11144. if (rc) {
  11145. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  11146. __func__,
  11147. "qcom,msm-cpudai-tdm-data-align");
  11148. goto free_dai_data;
  11149. }
  11150. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  11151. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  11152. /* TDM SLOT MAPPING CFG -- set default */
  11153. dai_data->port_cfg.slot_mapping.minor_version =
  11154. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  11155. dai_data->port_cfg.slot_mapping_v2.minor_version =
  11156. AFE_API_VERSION_SLOT_MAPPING_CONFIG_V2;
  11157. /* CUSTOM TDM HEADER CFG */
  11158. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  11159. if (of_find_property(pdev->dev.of_node,
  11160. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  11161. of_find_property(pdev->dev.of_node,
  11162. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  11163. of_find_property(pdev->dev.of_node,
  11164. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  11165. /* if the property exist */
  11166. rc = of_property_read_u32(pdev->dev.of_node,
  11167. "qcom,msm-cpudai-tdm-header-start-offset",
  11168. (u32 *)&custom_tdm_header->start_offset);
  11169. if (rc) {
  11170. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  11171. __func__,
  11172. "qcom,msm-cpudai-tdm-header-start-offset");
  11173. goto free_dai_data;
  11174. }
  11175. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  11176. __func__, custom_tdm_header->start_offset);
  11177. rc = of_property_read_u32(pdev->dev.of_node,
  11178. "qcom,msm-cpudai-tdm-header-width",
  11179. (u32 *)&custom_tdm_header->header_width);
  11180. if (rc) {
  11181. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  11182. __func__, "qcom,msm-cpudai-tdm-header-width");
  11183. goto free_dai_data;
  11184. }
  11185. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  11186. __func__, custom_tdm_header->header_width);
  11187. rc = of_property_read_u32(pdev->dev.of_node,
  11188. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  11189. (u32 *)&custom_tdm_header->num_frame_repeat);
  11190. if (rc) {
  11191. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  11192. __func__,
  11193. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  11194. goto free_dai_data;
  11195. }
  11196. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  11197. __func__, custom_tdm_header->num_frame_repeat);
  11198. /* CUSTOM TDM HEADER CFG -- set default */
  11199. custom_tdm_header->minor_version =
  11200. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  11201. custom_tdm_header->header_type =
  11202. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11203. } else {
  11204. /* CUSTOM TDM HEADER CFG -- set default */
  11205. custom_tdm_header->header_type =
  11206. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11207. /* proceed with probe */
  11208. }
  11209. /* copy static clk per parent node */
  11210. dai_data->clk_set = tdm_clk_set;
  11211. /* copy static group cfg per parent node */
  11212. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  11213. /* copy static num group ports per parent node */
  11214. dai_data->num_group_ports = num_tdm_group_ports;
  11215. dai_data->lane_cfg = tdm_lane_cfg;
  11216. dev_set_drvdata(&pdev->dev, dai_data);
  11217. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  11218. if (port_idx < 0) {
  11219. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  11220. __func__, tdm_dev_id);
  11221. rc = -EINVAL;
  11222. goto free_dai_data;
  11223. }
  11224. rc = snd_soc_register_component(&pdev->dev,
  11225. &msm_q6_tdm_dai_component,
  11226. &msm_dai_q6_tdm_dai[port_idx], 1);
  11227. if (rc) {
  11228. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  11229. __func__, tdm_dev_id, rc);
  11230. goto err_register;
  11231. }
  11232. return 0;
  11233. err_register:
  11234. free_dai_data:
  11235. kfree(dai_data);
  11236. rtn:
  11237. return rc;
  11238. }
  11239. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  11240. {
  11241. struct msm_dai_q6_tdm_dai_data *dai_data =
  11242. dev_get_drvdata(&pdev->dev);
  11243. snd_soc_unregister_component(&pdev->dev);
  11244. kfree(dai_data);
  11245. return 0;
  11246. }
  11247. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  11248. { .compatible = "qcom,msm-dai-q6-tdm", },
  11249. {}
  11250. };
  11251. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  11252. static struct platform_driver msm_dai_q6_tdm_driver = {
  11253. .probe = msm_dai_q6_tdm_dev_probe,
  11254. .remove = msm_dai_q6_tdm_dev_remove,
  11255. .driver = {
  11256. .name = "msm-dai-q6-tdm",
  11257. .owner = THIS_MODULE,
  11258. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  11259. .suppress_bind_attrs = true,
  11260. },
  11261. };
  11262. static int msm_dai_q6_cdc_dma_format_put(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. int value = ucontrol->value.integer.value[0];
  11267. dai_data->port_config.cdc_dma.data_format = value;
  11268. pr_debug("%s: format = %d\n", __func__, value);
  11269. return 0;
  11270. }
  11271. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  11272. struct snd_ctl_elem_value *ucontrol)
  11273. {
  11274. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  11275. ucontrol->value.integer.value[0] =
  11276. dai_data->port_config.cdc_dma.data_format;
  11277. return 0;
  11278. }
  11279. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  11280. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  11281. msm_dai_q6_cdc_dma_format_get,
  11282. msm_dai_q6_cdc_dma_format_put),
  11283. SOC_ENUM_EXT("WSA_CDC_DMA_0 RX XTLoggingDisable",
  11284. xt_logging_disable_enum[0],
  11285. msm_dai_q6_cdc_dma_xt_logging_disable_get,
  11286. msm_dai_q6_cdc_dma_xt_logging_disable_put),
  11287. };
  11288. /* SOC probe for codec DMA interface */
  11289. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  11290. {
  11291. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  11292. int rc = 0;
  11293. if (!dai) {
  11294. pr_err("%s: Invalid params dai\n", __func__);
  11295. return -EINVAL;
  11296. }
  11297. if (!dai->dev) {
  11298. pr_err("%s: Invalid params dai dev\n", __func__);
  11299. return -EINVAL;
  11300. }
  11301. msm_dai_q6_set_dai_id(dai);
  11302. dai_data = dev_get_drvdata(dai->dev);
  11303. switch (dai->id) {
  11304. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11305. rc = snd_ctl_add(dai->component->card->snd_card,
  11306. snd_ctl_new1(&cdc_dma_config_controls[0],
  11307. dai_data));
  11308. break;
  11309. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11310. rc = snd_ctl_add(dai->component->card->snd_card,
  11311. snd_ctl_new1(&cdc_dma_config_controls[1],
  11312. dai_data));
  11313. break;
  11314. default:
  11315. break;
  11316. }
  11317. if (rc < 0)
  11318. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  11319. __func__, dai->name);
  11320. if (dai_data->is_island_dai)
  11321. rc = msm_dai_q6_add_island_mx_ctls(
  11322. dai->component->card->snd_card,
  11323. dai->name, dai->id,
  11324. (void *)dai_data);
  11325. rc = msm_dai_q6_dai_add_route(dai);
  11326. return rc;
  11327. }
  11328. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  11329. {
  11330. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11331. dev_get_drvdata(dai->dev);
  11332. int rc = 0;
  11333. /* If AFE port is still up, close it */
  11334. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11335. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  11336. dai->id);
  11337. rc = afe_close(dai->id); /* can block */
  11338. if (rc < 0)
  11339. dev_err(dai->dev, "fail to close AFE port\n");
  11340. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11341. }
  11342. return rc;
  11343. }
  11344. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  11345. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  11346. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  11347. {
  11348. int rc = 0;
  11349. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11350. dev_get_drvdata(dai->dev);
  11351. unsigned int ch_mask = 0, ch_num = 0;
  11352. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  11353. switch (dai->id) {
  11354. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11355. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  11356. case AFE_PORT_ID_RX_CODEC_DMA_RX_0:
  11357. case AFE_PORT_ID_RX_CODEC_DMA_RX_1:
  11358. case AFE_PORT_ID_RX_CODEC_DMA_RX_2:
  11359. case AFE_PORT_ID_RX_CODEC_DMA_RX_3:
  11360. case AFE_PORT_ID_RX_CODEC_DMA_RX_4:
  11361. case AFE_PORT_ID_RX_CODEC_DMA_RX_5:
  11362. case AFE_PORT_ID_RX_CODEC_DMA_RX_6:
  11363. case AFE_PORT_ID_RX_CODEC_DMA_RX_7:
  11364. if (!rx_ch_mask) {
  11365. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  11366. return -EINVAL;
  11367. }
  11368. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11369. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  11370. __func__, rx_num_ch);
  11371. return -EINVAL;
  11372. }
  11373. ch_mask = *rx_ch_mask;
  11374. ch_num = rx_num_ch;
  11375. break;
  11376. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11377. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  11378. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  11379. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  11380. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  11381. case AFE_PORT_ID_TX_CODEC_DMA_TX_0:
  11382. case AFE_PORT_ID_TX_CODEC_DMA_TX_1:
  11383. case AFE_PORT_ID_TX_CODEC_DMA_TX_2:
  11384. case AFE_PORT_ID_TX_CODEC_DMA_TX_3:
  11385. case AFE_PORT_ID_TX_CODEC_DMA_TX_4:
  11386. case AFE_PORT_ID_TX_CODEC_DMA_TX_5:
  11387. if (!tx_ch_mask) {
  11388. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  11389. return -EINVAL;
  11390. }
  11391. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11392. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  11393. __func__, tx_num_ch);
  11394. return -EINVAL;
  11395. }
  11396. ch_mask = *tx_ch_mask;
  11397. ch_num = tx_num_ch;
  11398. break;
  11399. default:
  11400. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  11401. return -EINVAL;
  11402. }
  11403. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  11404. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  11405. dai->id, ch_num, ch_mask);
  11406. return rc;
  11407. }
  11408. static int msm_dai_q6_cdc_dma_hw_params(
  11409. struct snd_pcm_substream *substream,
  11410. struct snd_pcm_hw_params *params,
  11411. struct snd_soc_dai *dai)
  11412. {
  11413. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11414. dev_get_drvdata(dai->dev);
  11415. switch (params_format(params)) {
  11416. case SNDRV_PCM_FORMAT_S16_LE:
  11417. case SNDRV_PCM_FORMAT_SPECIAL:
  11418. dai_data->port_config.cdc_dma.bit_width = 16;
  11419. break;
  11420. case SNDRV_PCM_FORMAT_S24_LE:
  11421. case SNDRV_PCM_FORMAT_S24_3LE:
  11422. dai_data->port_config.cdc_dma.bit_width = 24;
  11423. break;
  11424. case SNDRV_PCM_FORMAT_S32_LE:
  11425. dai_data->port_config.cdc_dma.bit_width = 32;
  11426. break;
  11427. default:
  11428. dev_err(dai->dev, "%s: format %d\n",
  11429. __func__, params_format(params));
  11430. return -EINVAL;
  11431. }
  11432. dai_data->rate = params_rate(params);
  11433. dai_data->channels = params_channels(params);
  11434. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  11435. AFE_API_VERSION_CODEC_DMA_CONFIG;
  11436. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  11437. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  11438. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  11439. "num_channel %hu sample_rate %d\n", __func__,
  11440. dai_data->port_config.cdc_dma.bit_width,
  11441. dai_data->port_config.cdc_dma.data_format,
  11442. dai_data->port_config.cdc_dma.num_channels,
  11443. dai_data->rate);
  11444. return 0;
  11445. }
  11446. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  11447. struct snd_soc_dai *dai)
  11448. {
  11449. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11450. dev_get_drvdata(dai->dev);
  11451. int rc = 0;
  11452. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11453. if ((dai->id == AFE_PORT_ID_WSA_CODEC_DMA_TX_0) &&
  11454. (dai_data->port_config.cdc_dma.data_format == 1))
  11455. dai_data->port_config.cdc_dma.data_format =
  11456. AFE_LINEAR_PCM_DATA_PACKED_16BIT;
  11457. rc = afe_port_start(dai->id, &dai_data->port_config,
  11458. dai_data->rate);
  11459. if (rc < 0)
  11460. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  11461. dai->id);
  11462. else
  11463. set_bit(STATUS_PORT_STARTED,
  11464. dai_data->status_mask);
  11465. }
  11466. return rc;
  11467. }
  11468. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  11469. struct snd_soc_dai *dai)
  11470. {
  11471. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  11472. int rc = 0;
  11473. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11474. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  11475. dai->id);
  11476. rc = afe_close(dai->id); /* can block */
  11477. if (rc < 0)
  11478. dev_err(dai->dev, "fail to close AFE port\n");
  11479. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  11480. *dai_data->status_mask);
  11481. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11482. }
  11483. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  11484. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  11485. }
  11486. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  11487. .prepare = msm_dai_q6_cdc_dma_prepare,
  11488. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11489. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11490. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11491. };
  11492. static struct snd_soc_dai_ops msm_dai_q6_cdc_wsa_dma_ops = {
  11493. .prepare = msm_dai_q6_cdc_dma_prepare,
  11494. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11495. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11496. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11497. .digital_mute = msm_dai_q6_spk_digital_mute,
  11498. };
  11499. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  11500. {
  11501. .playback = {
  11502. .stream_name = "WSA CDC DMA0 Playback",
  11503. .aif_name = "WSA_CDC_DMA_RX_0",
  11504. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11505. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11506. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11507. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11508. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11509. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11510. SNDRV_PCM_RATE_384000,
  11511. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11512. SNDRV_PCM_FMTBIT_S24_LE |
  11513. SNDRV_PCM_FMTBIT_S24_3LE |
  11514. SNDRV_PCM_FMTBIT_S32_LE,
  11515. .channels_min = 1,
  11516. .channels_max = 4,
  11517. .rate_min = 8000,
  11518. .rate_max = 384000,
  11519. },
  11520. .name = "WSA_CDC_DMA_RX_0",
  11521. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11522. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  11523. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11524. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11525. },
  11526. {
  11527. .capture = {
  11528. .stream_name = "WSA CDC DMA0 Capture",
  11529. .aif_name = "WSA_CDC_DMA_TX_0",
  11530. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11531. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11532. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11533. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11534. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11535. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11536. SNDRV_PCM_RATE_384000,
  11537. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11538. SNDRV_PCM_FMTBIT_S24_LE |
  11539. SNDRV_PCM_FMTBIT_S24_3LE |
  11540. SNDRV_PCM_FMTBIT_S32_LE,
  11541. .channels_min = 1,
  11542. .channels_max = 4,
  11543. .rate_min = 8000,
  11544. .rate_max = 384000,
  11545. },
  11546. .name = "WSA_CDC_DMA_TX_0",
  11547. .ops = &msm_dai_q6_cdc_dma_ops,
  11548. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  11549. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11550. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11551. },
  11552. {
  11553. .playback = {
  11554. .stream_name = "WSA CDC DMA1 Playback",
  11555. .aif_name = "WSA_CDC_DMA_RX_1",
  11556. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11557. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11558. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11559. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11560. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11561. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11562. SNDRV_PCM_RATE_384000,
  11563. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11564. SNDRV_PCM_FMTBIT_S24_LE |
  11565. SNDRV_PCM_FMTBIT_S24_3LE |
  11566. SNDRV_PCM_FMTBIT_S32_LE,
  11567. .channels_min = 1,
  11568. .channels_max = 2,
  11569. .rate_min = 8000,
  11570. .rate_max = 384000,
  11571. },
  11572. .name = "WSA_CDC_DMA_RX_1",
  11573. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11574. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  11575. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11576. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11577. },
  11578. {
  11579. .capture = {
  11580. .stream_name = "WSA CDC DMA1 Capture",
  11581. .aif_name = "WSA_CDC_DMA_TX_1",
  11582. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11583. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11584. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11585. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11586. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11587. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11588. SNDRV_PCM_RATE_384000,
  11589. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11590. SNDRV_PCM_FMTBIT_S24_LE |
  11591. SNDRV_PCM_FMTBIT_S24_3LE |
  11592. SNDRV_PCM_FMTBIT_S32_LE,
  11593. .channels_min = 1,
  11594. .channels_max = 2,
  11595. .rate_min = 8000,
  11596. .rate_max = 384000,
  11597. },
  11598. .name = "WSA_CDC_DMA_TX_1",
  11599. .ops = &msm_dai_q6_cdc_dma_ops,
  11600. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  11601. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11602. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11603. },
  11604. {
  11605. .capture = {
  11606. .stream_name = "WSA CDC DMA2 Capture",
  11607. .aif_name = "WSA_CDC_DMA_TX_2",
  11608. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11609. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11610. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11611. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11612. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11613. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11614. SNDRV_PCM_RATE_384000,
  11615. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11616. SNDRV_PCM_FMTBIT_S24_LE |
  11617. SNDRV_PCM_FMTBIT_S24_3LE |
  11618. SNDRV_PCM_FMTBIT_S32_LE,
  11619. .channels_min = 1,
  11620. .channels_max = 1,
  11621. .rate_min = 8000,
  11622. .rate_max = 384000,
  11623. },
  11624. .name = "WSA_CDC_DMA_TX_2",
  11625. .ops = &msm_dai_q6_cdc_dma_ops,
  11626. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  11627. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11628. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11629. },
  11630. {
  11631. .capture = {
  11632. .stream_name = "VA CDC DMA0 Capture",
  11633. .aif_name = "VA_CDC_DMA_TX_0",
  11634. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11635. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11636. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11637. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11638. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11639. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11640. SNDRV_PCM_RATE_384000,
  11641. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11642. SNDRV_PCM_FMTBIT_S24_LE |
  11643. SNDRV_PCM_FMTBIT_S24_3LE,
  11644. .channels_min = 1,
  11645. .channels_max = 8,
  11646. .rate_min = 8000,
  11647. .rate_max = 384000,
  11648. },
  11649. .name = "VA_CDC_DMA_TX_0",
  11650. .ops = &msm_dai_q6_cdc_dma_ops,
  11651. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  11652. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11653. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11654. },
  11655. {
  11656. .capture = {
  11657. .stream_name = "VA CDC DMA1 Capture",
  11658. .aif_name = "VA_CDC_DMA_TX_1",
  11659. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11660. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11661. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11662. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11663. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11664. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11665. SNDRV_PCM_RATE_384000,
  11666. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11667. SNDRV_PCM_FMTBIT_S24_LE |
  11668. SNDRV_PCM_FMTBIT_S24_3LE,
  11669. .channels_min = 1,
  11670. .channels_max = 8,
  11671. .rate_min = 8000,
  11672. .rate_max = 384000,
  11673. },
  11674. .name = "VA_CDC_DMA_TX_1",
  11675. .ops = &msm_dai_q6_cdc_dma_ops,
  11676. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  11677. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11678. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11679. },
  11680. {
  11681. .capture = {
  11682. .stream_name = "VA CDC DMA2 Capture",
  11683. .aif_name = "VA_CDC_DMA_TX_2",
  11684. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11685. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11686. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11687. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11688. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11689. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11690. SNDRV_PCM_RATE_384000,
  11691. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11692. SNDRV_PCM_FMTBIT_S24_LE |
  11693. SNDRV_PCM_FMTBIT_S24_3LE,
  11694. .channels_min = 1,
  11695. .channels_max = 8,
  11696. .rate_min = 8000,
  11697. .rate_max = 384000,
  11698. },
  11699. .name = "VA_CDC_DMA_TX_2",
  11700. .ops = &msm_dai_q6_cdc_dma_ops,
  11701. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  11702. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11703. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11704. },
  11705. {
  11706. .playback = {
  11707. .stream_name = "RX CDC DMA0 Playback",
  11708. .aif_name = "RX_CDC_DMA_RX_0",
  11709. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11710. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11711. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11712. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11713. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11714. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11715. SNDRV_PCM_RATE_384000,
  11716. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11717. SNDRV_PCM_FMTBIT_S24_LE |
  11718. SNDRV_PCM_FMTBIT_S24_3LE |
  11719. SNDRV_PCM_FMTBIT_S32_LE,
  11720. .channels_min = 1,
  11721. .channels_max = 2,
  11722. .rate_min = 8000,
  11723. .rate_max = 384000,
  11724. },
  11725. .ops = &msm_dai_q6_cdc_dma_ops,
  11726. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  11727. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11728. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11729. },
  11730. {
  11731. .capture = {
  11732. .stream_name = "TX CDC DMA0 Capture",
  11733. .aif_name = "TX_CDC_DMA_TX_0",
  11734. .rates = SNDRV_PCM_RATE_8000 |
  11735. SNDRV_PCM_RATE_16000 |
  11736. SNDRV_PCM_RATE_32000 |
  11737. SNDRV_PCM_RATE_48000 |
  11738. SNDRV_PCM_RATE_96000 |
  11739. SNDRV_PCM_RATE_192000 |
  11740. SNDRV_PCM_RATE_384000,
  11741. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11742. SNDRV_PCM_FMTBIT_S24_LE |
  11743. SNDRV_PCM_FMTBIT_S24_3LE |
  11744. SNDRV_PCM_FMTBIT_S32_LE,
  11745. .channels_min = 1,
  11746. .channels_max = 3,
  11747. .rate_min = 8000,
  11748. .rate_max = 384000,
  11749. },
  11750. .ops = &msm_dai_q6_cdc_dma_ops,
  11751. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  11752. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11753. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11754. },
  11755. {
  11756. .playback = {
  11757. .stream_name = "RX CDC DMA1 Playback",
  11758. .aif_name = "RX_CDC_DMA_RX_1",
  11759. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11760. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11761. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11762. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11763. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11764. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11765. SNDRV_PCM_RATE_384000,
  11766. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11767. SNDRV_PCM_FMTBIT_S24_LE |
  11768. SNDRV_PCM_FMTBIT_S24_3LE |
  11769. SNDRV_PCM_FMTBIT_S32_LE,
  11770. .channels_min = 1,
  11771. .channels_max = 2,
  11772. .rate_min = 8000,
  11773. .rate_max = 384000,
  11774. },
  11775. .ops = &msm_dai_q6_cdc_dma_ops,
  11776. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  11777. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11778. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11779. },
  11780. {
  11781. .capture = {
  11782. .stream_name = "TX CDC DMA1 Capture",
  11783. .aif_name = "TX_CDC_DMA_TX_1",
  11784. .rates = SNDRV_PCM_RATE_8000 |
  11785. SNDRV_PCM_RATE_16000 |
  11786. SNDRV_PCM_RATE_32000 |
  11787. SNDRV_PCM_RATE_48000 |
  11788. SNDRV_PCM_RATE_96000 |
  11789. SNDRV_PCM_RATE_192000 |
  11790. SNDRV_PCM_RATE_384000,
  11791. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11792. SNDRV_PCM_FMTBIT_S24_LE |
  11793. SNDRV_PCM_FMTBIT_S24_3LE |
  11794. SNDRV_PCM_FMTBIT_S32_LE,
  11795. .channels_min = 1,
  11796. .channels_max = 3,
  11797. .rate_min = 8000,
  11798. .rate_max = 384000,
  11799. },
  11800. .ops = &msm_dai_q6_cdc_dma_ops,
  11801. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  11802. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11803. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11804. },
  11805. {
  11806. .playback = {
  11807. .stream_name = "RX CDC DMA2 Playback",
  11808. .aif_name = "RX_CDC_DMA_RX_2",
  11809. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11810. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11811. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11812. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11813. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11814. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11815. SNDRV_PCM_RATE_384000,
  11816. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11817. SNDRV_PCM_FMTBIT_S24_LE |
  11818. SNDRV_PCM_FMTBIT_S24_3LE |
  11819. SNDRV_PCM_FMTBIT_S32_LE,
  11820. .channels_min = 1,
  11821. .channels_max = 1,
  11822. .rate_min = 8000,
  11823. .rate_max = 384000,
  11824. },
  11825. .ops = &msm_dai_q6_cdc_dma_ops,
  11826. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  11827. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11828. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11829. },
  11830. {
  11831. .capture = {
  11832. .stream_name = "TX CDC DMA2 Capture",
  11833. .aif_name = "TX_CDC_DMA_TX_2",
  11834. .rates = SNDRV_PCM_RATE_8000 |
  11835. SNDRV_PCM_RATE_16000 |
  11836. SNDRV_PCM_RATE_32000 |
  11837. SNDRV_PCM_RATE_48000 |
  11838. SNDRV_PCM_RATE_96000 |
  11839. SNDRV_PCM_RATE_192000 |
  11840. SNDRV_PCM_RATE_384000,
  11841. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11842. SNDRV_PCM_FMTBIT_S24_LE |
  11843. SNDRV_PCM_FMTBIT_S24_3LE |
  11844. SNDRV_PCM_FMTBIT_S32_LE,
  11845. .channels_min = 1,
  11846. .channels_max = 4,
  11847. .rate_min = 8000,
  11848. .rate_max = 384000,
  11849. },
  11850. .ops = &msm_dai_q6_cdc_dma_ops,
  11851. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  11852. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11853. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11854. }, {
  11855. .playback = {
  11856. .stream_name = "RX CDC DMA3 Playback",
  11857. .aif_name = "RX_CDC_DMA_RX_3",
  11858. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11859. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11860. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11861. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11862. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11863. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11864. SNDRV_PCM_RATE_384000,
  11865. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11866. SNDRV_PCM_FMTBIT_S24_LE |
  11867. SNDRV_PCM_FMTBIT_S24_3LE |
  11868. SNDRV_PCM_FMTBIT_S32_LE,
  11869. .channels_min = 1,
  11870. .channels_max = 1,
  11871. .rate_min = 8000,
  11872. .rate_max = 384000,
  11873. },
  11874. .ops = &msm_dai_q6_cdc_dma_ops,
  11875. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  11876. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11877. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11878. },
  11879. {
  11880. .capture = {
  11881. .stream_name = "TX CDC DMA3 Capture",
  11882. .aif_name = "TX_CDC_DMA_TX_3",
  11883. .rates = SNDRV_PCM_RATE_8000 |
  11884. SNDRV_PCM_RATE_16000 |
  11885. SNDRV_PCM_RATE_32000 |
  11886. SNDRV_PCM_RATE_48000 |
  11887. SNDRV_PCM_RATE_96000 |
  11888. SNDRV_PCM_RATE_192000 |
  11889. SNDRV_PCM_RATE_384000,
  11890. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11891. SNDRV_PCM_FMTBIT_S24_LE |
  11892. SNDRV_PCM_FMTBIT_S24_3LE |
  11893. SNDRV_PCM_FMTBIT_S32_LE,
  11894. .channels_min = 1,
  11895. .channels_max = 8,
  11896. .rate_min = 8000,
  11897. .rate_max = 384000,
  11898. },
  11899. .ops = &msm_dai_q6_cdc_dma_ops,
  11900. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  11901. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11902. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11903. },
  11904. {
  11905. .playback = {
  11906. .stream_name = "RX CDC DMA4 Playback",
  11907. .aif_name = "RX_CDC_DMA_RX_4",
  11908. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11909. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11910. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11911. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11912. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11913. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11914. SNDRV_PCM_RATE_384000,
  11915. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11916. SNDRV_PCM_FMTBIT_S24_LE |
  11917. SNDRV_PCM_FMTBIT_S24_3LE |
  11918. SNDRV_PCM_FMTBIT_S32_LE,
  11919. .channels_min = 1,
  11920. .channels_max = 6,
  11921. .rate_min = 8000,
  11922. .rate_max = 384000,
  11923. },
  11924. .ops = &msm_dai_q6_cdc_dma_ops,
  11925. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  11926. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11927. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11928. },
  11929. {
  11930. .capture = {
  11931. .stream_name = "TX CDC DMA4 Capture",
  11932. .aif_name = "TX_CDC_DMA_TX_4",
  11933. .rates = SNDRV_PCM_RATE_8000 |
  11934. SNDRV_PCM_RATE_16000 |
  11935. SNDRV_PCM_RATE_32000 |
  11936. SNDRV_PCM_RATE_48000 |
  11937. SNDRV_PCM_RATE_96000 |
  11938. SNDRV_PCM_RATE_192000 |
  11939. SNDRV_PCM_RATE_384000,
  11940. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11941. SNDRV_PCM_FMTBIT_S24_LE |
  11942. SNDRV_PCM_FMTBIT_S24_3LE |
  11943. SNDRV_PCM_FMTBIT_S32_LE,
  11944. .channels_min = 1,
  11945. .channels_max = 8,
  11946. .rate_min = 8000,
  11947. .rate_max = 384000,
  11948. },
  11949. .ops = &msm_dai_q6_cdc_dma_ops,
  11950. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  11951. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11952. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11953. },
  11954. {
  11955. .playback = {
  11956. .stream_name = "RX CDC DMA5 Playback",
  11957. .aif_name = "RX_CDC_DMA_RX_5",
  11958. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11959. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11960. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11961. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11962. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11963. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11964. SNDRV_PCM_RATE_384000,
  11965. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11966. SNDRV_PCM_FMTBIT_S24_LE |
  11967. SNDRV_PCM_FMTBIT_S24_3LE |
  11968. SNDRV_PCM_FMTBIT_S32_LE,
  11969. .channels_min = 1,
  11970. .channels_max = 1,
  11971. .rate_min = 8000,
  11972. .rate_max = 384000,
  11973. },
  11974. .ops = &msm_dai_q6_cdc_dma_ops,
  11975. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  11976. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11977. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11978. },
  11979. {
  11980. .capture = {
  11981. .stream_name = "TX CDC DMA5 Capture",
  11982. .aif_name = "TX_CDC_DMA_TX_5",
  11983. .rates = SNDRV_PCM_RATE_8000 |
  11984. SNDRV_PCM_RATE_16000 |
  11985. SNDRV_PCM_RATE_32000 |
  11986. SNDRV_PCM_RATE_48000 |
  11987. SNDRV_PCM_RATE_96000 |
  11988. SNDRV_PCM_RATE_192000 |
  11989. SNDRV_PCM_RATE_384000,
  11990. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11991. SNDRV_PCM_FMTBIT_S24_LE |
  11992. SNDRV_PCM_FMTBIT_S24_3LE |
  11993. SNDRV_PCM_FMTBIT_S32_LE,
  11994. .channels_min = 1,
  11995. .channels_max = 4,
  11996. .rate_min = 8000,
  11997. .rate_max = 384000,
  11998. },
  11999. .ops = &msm_dai_q6_cdc_dma_ops,
  12000. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  12001. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12002. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12003. },
  12004. {
  12005. .playback = {
  12006. .stream_name = "RX CDC DMA6 Playback",
  12007. .aif_name = "RX_CDC_DMA_RX_6",
  12008. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12009. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12010. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12011. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12012. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12013. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12014. SNDRV_PCM_RATE_384000,
  12015. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12016. SNDRV_PCM_FMTBIT_S24_LE |
  12017. SNDRV_PCM_FMTBIT_S24_3LE |
  12018. SNDRV_PCM_FMTBIT_S32_LE,
  12019. .channels_min = 1,
  12020. .channels_max = 4,
  12021. .rate_min = 8000,
  12022. .rate_max = 384000,
  12023. },
  12024. .ops = &msm_dai_q6_cdc_dma_ops,
  12025. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  12026. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12027. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12028. },
  12029. {
  12030. .playback = {
  12031. .stream_name = "RX CDC DMA7 Playback",
  12032. .aif_name = "RX_CDC_DMA_RX_7",
  12033. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12034. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12035. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12036. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12037. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12038. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12039. SNDRV_PCM_RATE_384000,
  12040. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12041. SNDRV_PCM_FMTBIT_S24_LE |
  12042. SNDRV_PCM_FMTBIT_S24_3LE |
  12043. SNDRV_PCM_FMTBIT_S32_LE,
  12044. .channels_min = 1,
  12045. .channels_max = 2,
  12046. .rate_min = 8000,
  12047. .rate_max = 384000,
  12048. },
  12049. .ops = &msm_dai_q6_cdc_dma_ops,
  12050. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  12051. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12052. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12053. },
  12054. };
  12055. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  12056. .name = "msm-dai-cdc-dma-dev",
  12057. };
  12058. /* DT related probe for each codec DMA interface device */
  12059. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  12060. {
  12061. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  12062. u32 cdc_dma_id = 0;
  12063. int i;
  12064. int rc = 0;
  12065. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  12066. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  12067. &cdc_dma_id);
  12068. if (rc) {
  12069. dev_err(&pdev->dev,
  12070. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  12071. return rc;
  12072. }
  12073. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  12074. dev_name(&pdev->dev), cdc_dma_id);
  12075. pdev->id = cdc_dma_id;
  12076. dai_data = devm_kzalloc(&pdev->dev,
  12077. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  12078. GFP_KERNEL);
  12079. if (!dai_data)
  12080. return -ENOMEM;
  12081. rc = of_property_read_u32(pdev->dev.of_node,
  12082. "qcom,msm-dai-is-island-supported",
  12083. &dai_data->is_island_dai);
  12084. if (rc)
  12085. dev_dbg(&pdev->dev, "island supported entry not found\n");
  12086. dev_set_drvdata(&pdev->dev, dai_data);
  12087. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  12088. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  12089. return snd_soc_register_component(&pdev->dev,
  12090. &msm_q6_cdc_dma_dai_component,
  12091. &msm_dai_q6_cdc_dma_dai[i], 1);
  12092. }
  12093. }
  12094. return -ENODEV;
  12095. }
  12096. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  12097. {
  12098. snd_soc_unregister_component(&pdev->dev);
  12099. return 0;
  12100. }
  12101. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  12102. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  12103. { }
  12104. };
  12105. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  12106. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  12107. .probe = msm_dai_q6_cdc_dma_dev_probe,
  12108. .remove = msm_dai_q6_cdc_dma_dev_remove,
  12109. .driver = {
  12110. .name = "msm-dai-cdc-dma-dev",
  12111. .owner = THIS_MODULE,
  12112. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  12113. .suppress_bind_attrs = true,
  12114. },
  12115. };
  12116. /* DT related probe for codec DMA interface device group */
  12117. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  12118. {
  12119. int rc;
  12120. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  12121. if (rc) {
  12122. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  12123. __func__, rc);
  12124. } else
  12125. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  12126. return rc;
  12127. }
  12128. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  12129. {
  12130. of_platform_depopulate(&pdev->dev);
  12131. return 0;
  12132. }
  12133. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  12134. { .compatible = "qcom,msm-dai-cdc-dma", },
  12135. { }
  12136. };
  12137. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  12138. static struct platform_driver msm_dai_cdc_dma_q6 = {
  12139. .probe = msm_dai_cdc_dma_q6_probe,
  12140. .remove = msm_dai_cdc_dma_q6_remove,
  12141. .driver = {
  12142. .name = "msm-dai-cdc-dma",
  12143. .owner = THIS_MODULE,
  12144. .of_match_table = msm_dai_cdc_dma_dt_match,
  12145. .suppress_bind_attrs = true,
  12146. },
  12147. };
  12148. int __init msm_dai_q6_init(void)
  12149. {
  12150. int rc;
  12151. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  12152. if (rc) {
  12153. pr_err("%s: fail to register auxpcm dev driver", __func__);
  12154. goto fail;
  12155. }
  12156. rc = platform_driver_register(&msm_dai_q6);
  12157. if (rc) {
  12158. pr_err("%s: fail to register dai q6 driver", __func__);
  12159. goto dai_q6_fail;
  12160. }
  12161. rc = platform_driver_register(&msm_dai_q6_dev);
  12162. if (rc) {
  12163. pr_err("%s: fail to register dai q6 dev driver", __func__);
  12164. goto dai_q6_dev_fail;
  12165. }
  12166. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  12167. if (rc) {
  12168. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  12169. goto dai_q6_mi2s_drv_fail;
  12170. }
  12171. rc = platform_driver_register(&msm_dai_q6_meta_mi2s_driver);
  12172. if (rc) {
  12173. pr_err("%s: fail to register dai META MI2S dev drv\n",
  12174. __func__);
  12175. goto dai_q6_meta_mi2s_drv_fail;
  12176. }
  12177. rc = platform_driver_register(&msm_dai_mi2s_q6);
  12178. if (rc) {
  12179. pr_err("%s: fail to register dai MI2S\n", __func__);
  12180. goto dai_mi2s_q6_fail;
  12181. }
  12182. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  12183. if (rc) {
  12184. pr_err("%s: fail to register dai SPDIF\n", __func__);
  12185. goto dai_spdif_q6_fail;
  12186. }
  12187. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  12188. if (rc) {
  12189. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  12190. goto dai_q6_tdm_drv_fail;
  12191. }
  12192. rc = platform_driver_register(&msm_dai_tdm_q6);
  12193. if (rc) {
  12194. pr_err("%s: fail to register dai TDM\n", __func__);
  12195. goto dai_tdm_q6_fail;
  12196. }
  12197. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  12198. if (rc) {
  12199. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  12200. goto dai_cdc_dma_q6_dev_fail;
  12201. }
  12202. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  12203. if (rc) {
  12204. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  12205. goto dai_cdc_dma_q6_fail;
  12206. }
  12207. return rc;
  12208. dai_cdc_dma_q6_fail:
  12209. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12210. dai_cdc_dma_q6_dev_fail:
  12211. platform_driver_unregister(&msm_dai_tdm_q6);
  12212. dai_tdm_q6_fail:
  12213. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12214. dai_q6_tdm_drv_fail:
  12215. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12216. dai_spdif_q6_fail:
  12217. platform_driver_unregister(&msm_dai_mi2s_q6);
  12218. dai_mi2s_q6_fail:
  12219. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12220. dai_q6_meta_mi2s_drv_fail:
  12221. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12222. dai_q6_mi2s_drv_fail:
  12223. platform_driver_unregister(&msm_dai_q6_dev);
  12224. dai_q6_dev_fail:
  12225. platform_driver_unregister(&msm_dai_q6);
  12226. dai_q6_fail:
  12227. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12228. fail:
  12229. return rc;
  12230. }
  12231. void msm_dai_q6_exit(void)
  12232. {
  12233. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  12234. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12235. platform_driver_unregister(&msm_dai_tdm_q6);
  12236. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12237. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12238. platform_driver_unregister(&msm_dai_mi2s_q6);
  12239. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12240. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12241. platform_driver_unregister(&msm_dai_q6_dev);
  12242. platform_driver_unregister(&msm_dai_q6);
  12243. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12244. }
  12245. /* Module information */
  12246. MODULE_DESCRIPTION("MSM DSP DAI driver");
  12247. MODULE_LICENSE("GPL v2");