msm-dai-q6-v2.c 330 KB

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