msm-dai-q6-v2.c 262 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955
  1. /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/device.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/bitops.h>
  17. #include <linux/slab.h>
  18. #include <linux/clk.h>
  19. #include <linux/of_device.h>
  20. #include <sound/core.h>
  21. #include <sound/pcm.h>
  22. #include <sound/soc.h>
  23. #include <sound/pcm_params.h>
  24. #include <dsp/apr_audio-v2.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include "msm-dai-q6-v2.h"
  27. #include "codecs/core.h"
  28. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  29. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  30. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  31. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  32. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  33. #define spdif_clock_value(rate) (2*rate*32*2)
  34. #define CHANNEL_STATUS_SIZE 24
  35. #define CHANNEL_STATUS_MASK_INIT 0x0
  36. #define CHANNEL_STATUS_MASK 0x4
  37. #define AFE_API_VERSION_CLOCK_SET 1
  38. #define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  39. SNDRV_PCM_FMTBIT_S24_LE | \
  40. SNDRV_PCM_FMTBIT_S32_LE)
  41. enum {
  42. ENC_FMT_NONE,
  43. ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  44. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  45. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  46. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  47. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  48. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  49. };
  50. enum {
  51. SPKR_1,
  52. SPKR_2,
  53. };
  54. static const struct afe_clk_set lpass_clk_set_default = {
  55. AFE_API_VERSION_CLOCK_SET,
  56. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  57. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  58. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  59. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  60. 0,
  61. };
  62. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  63. AFE_API_VERSION_I2S_CONFIG,
  64. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  65. 0,
  66. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  67. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  68. Q6AFE_LPASS_MODE_CLK1_VALID,
  69. 0,
  70. };
  71. enum {
  72. STATUS_PORT_STARTED, /* track if AFE port has started */
  73. /* track AFE Tx port status for bi-directional transfers */
  74. STATUS_TX_PORT,
  75. /* track AFE Rx port status for bi-directional transfers */
  76. STATUS_RX_PORT,
  77. STATUS_MAX
  78. };
  79. enum {
  80. RATE_8KHZ,
  81. RATE_16KHZ,
  82. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  83. };
  84. enum {
  85. IDX_PRIMARY_TDM_RX_0,
  86. IDX_PRIMARY_TDM_RX_1,
  87. IDX_PRIMARY_TDM_RX_2,
  88. IDX_PRIMARY_TDM_RX_3,
  89. IDX_PRIMARY_TDM_RX_4,
  90. IDX_PRIMARY_TDM_RX_5,
  91. IDX_PRIMARY_TDM_RX_6,
  92. IDX_PRIMARY_TDM_RX_7,
  93. IDX_PRIMARY_TDM_TX_0,
  94. IDX_PRIMARY_TDM_TX_1,
  95. IDX_PRIMARY_TDM_TX_2,
  96. IDX_PRIMARY_TDM_TX_3,
  97. IDX_PRIMARY_TDM_TX_4,
  98. IDX_PRIMARY_TDM_TX_5,
  99. IDX_PRIMARY_TDM_TX_6,
  100. IDX_PRIMARY_TDM_TX_7,
  101. IDX_SECONDARY_TDM_RX_0,
  102. IDX_SECONDARY_TDM_RX_1,
  103. IDX_SECONDARY_TDM_RX_2,
  104. IDX_SECONDARY_TDM_RX_3,
  105. IDX_SECONDARY_TDM_RX_4,
  106. IDX_SECONDARY_TDM_RX_5,
  107. IDX_SECONDARY_TDM_RX_6,
  108. IDX_SECONDARY_TDM_RX_7,
  109. IDX_SECONDARY_TDM_TX_0,
  110. IDX_SECONDARY_TDM_TX_1,
  111. IDX_SECONDARY_TDM_TX_2,
  112. IDX_SECONDARY_TDM_TX_3,
  113. IDX_SECONDARY_TDM_TX_4,
  114. IDX_SECONDARY_TDM_TX_5,
  115. IDX_SECONDARY_TDM_TX_6,
  116. IDX_SECONDARY_TDM_TX_7,
  117. IDX_TERTIARY_TDM_RX_0,
  118. IDX_TERTIARY_TDM_RX_1,
  119. IDX_TERTIARY_TDM_RX_2,
  120. IDX_TERTIARY_TDM_RX_3,
  121. IDX_TERTIARY_TDM_RX_4,
  122. IDX_TERTIARY_TDM_RX_5,
  123. IDX_TERTIARY_TDM_RX_6,
  124. IDX_TERTIARY_TDM_RX_7,
  125. IDX_TERTIARY_TDM_TX_0,
  126. IDX_TERTIARY_TDM_TX_1,
  127. IDX_TERTIARY_TDM_TX_2,
  128. IDX_TERTIARY_TDM_TX_3,
  129. IDX_TERTIARY_TDM_TX_4,
  130. IDX_TERTIARY_TDM_TX_5,
  131. IDX_TERTIARY_TDM_TX_6,
  132. IDX_TERTIARY_TDM_TX_7,
  133. IDX_QUATERNARY_TDM_RX_0,
  134. IDX_QUATERNARY_TDM_RX_1,
  135. IDX_QUATERNARY_TDM_RX_2,
  136. IDX_QUATERNARY_TDM_RX_3,
  137. IDX_QUATERNARY_TDM_RX_4,
  138. IDX_QUATERNARY_TDM_RX_5,
  139. IDX_QUATERNARY_TDM_RX_6,
  140. IDX_QUATERNARY_TDM_RX_7,
  141. IDX_QUATERNARY_TDM_TX_0,
  142. IDX_QUATERNARY_TDM_TX_1,
  143. IDX_QUATERNARY_TDM_TX_2,
  144. IDX_QUATERNARY_TDM_TX_3,
  145. IDX_QUATERNARY_TDM_TX_4,
  146. IDX_QUATERNARY_TDM_TX_5,
  147. IDX_QUATERNARY_TDM_TX_6,
  148. IDX_QUATERNARY_TDM_TX_7,
  149. IDX_QUINARY_TDM_RX_0,
  150. IDX_QUINARY_TDM_RX_1,
  151. IDX_QUINARY_TDM_RX_2,
  152. IDX_QUINARY_TDM_RX_3,
  153. IDX_QUINARY_TDM_RX_4,
  154. IDX_QUINARY_TDM_RX_5,
  155. IDX_QUINARY_TDM_RX_6,
  156. IDX_QUINARY_TDM_RX_7,
  157. IDX_QUINARY_TDM_TX_0,
  158. IDX_QUINARY_TDM_TX_1,
  159. IDX_QUINARY_TDM_TX_2,
  160. IDX_QUINARY_TDM_TX_3,
  161. IDX_QUINARY_TDM_TX_4,
  162. IDX_QUINARY_TDM_TX_5,
  163. IDX_QUINARY_TDM_TX_6,
  164. IDX_QUINARY_TDM_TX_7,
  165. IDX_TDM_MAX,
  166. };
  167. enum {
  168. IDX_GROUP_PRIMARY_TDM_RX,
  169. IDX_GROUP_PRIMARY_TDM_TX,
  170. IDX_GROUP_SECONDARY_TDM_RX,
  171. IDX_GROUP_SECONDARY_TDM_TX,
  172. IDX_GROUP_TERTIARY_TDM_RX,
  173. IDX_GROUP_TERTIARY_TDM_TX,
  174. IDX_GROUP_QUATERNARY_TDM_RX,
  175. IDX_GROUP_QUATERNARY_TDM_TX,
  176. IDX_GROUP_QUINARY_TDM_RX,
  177. IDX_GROUP_QUINARY_TDM_TX,
  178. IDX_GROUP_TDM_MAX,
  179. };
  180. struct msm_dai_q6_dai_data {
  181. DECLARE_BITMAP(status_mask, STATUS_MAX);
  182. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  183. u32 rate;
  184. u32 channels;
  185. u32 bitwidth;
  186. u32 cal_mode;
  187. u32 afe_in_channels;
  188. u16 afe_in_bitformat;
  189. struct afe_enc_config enc_config;
  190. union afe_port_config port_config;
  191. u16 vi_feed_mono;
  192. };
  193. struct msm_dai_q6_spdif_dai_data {
  194. DECLARE_BITMAP(status_mask, STATUS_MAX);
  195. u32 rate;
  196. u32 channels;
  197. u32 bitwidth;
  198. struct afe_spdif_port_config spdif_port;
  199. };
  200. struct msm_dai_q6_mi2s_dai_config {
  201. u16 pdata_mi2s_lines;
  202. struct msm_dai_q6_dai_data mi2s_dai_data;
  203. };
  204. struct msm_dai_q6_mi2s_dai_data {
  205. struct msm_dai_q6_mi2s_dai_config tx_dai;
  206. struct msm_dai_q6_mi2s_dai_config rx_dai;
  207. };
  208. struct msm_dai_q6_auxpcm_dai_data {
  209. /* BITMAP to track Rx and Tx port usage count */
  210. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  211. struct mutex rlock; /* auxpcm dev resource lock */
  212. u16 rx_pid; /* AUXPCM RX AFE port ID */
  213. u16 tx_pid; /* AUXPCM TX AFE port ID */
  214. u16 afe_clk_ver;
  215. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  216. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  217. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  218. };
  219. struct msm_dai_q6_tdm_dai_data {
  220. DECLARE_BITMAP(status_mask, STATUS_MAX);
  221. u32 rate;
  222. u32 channels;
  223. u32 bitwidth;
  224. u32 num_group_ports;
  225. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  226. union afe_port_group_config group_cfg; /* hold tdm group config */
  227. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  228. };
  229. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  230. * 0: linear PCM
  231. * 1: non-linear PCM
  232. * 2: PCM data in IEC 60968 container
  233. * 3: compressed data in IEC 60958 container
  234. */
  235. static const char *const mi2s_format[] = {
  236. "LPCM",
  237. "Compr",
  238. "LPCM-60958",
  239. "Compr-60958"
  240. };
  241. static const char *const mi2s_vi_feed_mono[] = {
  242. "Left",
  243. "Right",
  244. };
  245. static const struct soc_enum mi2s_config_enum[] = {
  246. SOC_ENUM_SINGLE_EXT(4, mi2s_format),
  247. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  248. };
  249. static const char *const sb_format[] = {
  250. "UNPACKED",
  251. "PACKED_16B",
  252. "DSD_DOP",
  253. };
  254. static const struct soc_enum sb_config_enum[] = {
  255. SOC_ENUM_SINGLE_EXT(3, sb_format),
  256. };
  257. static const char *const tdm_data_format[] = {
  258. "LPCM",
  259. "Compr",
  260. "Gen Compr"
  261. };
  262. static const char *const tdm_header_type[] = {
  263. "Invalid",
  264. "Default",
  265. "Entertainment",
  266. };
  267. static const struct soc_enum tdm_config_enum[] = {
  268. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  269. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  270. };
  271. static DEFINE_MUTEX(tdm_mutex);
  272. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  273. /* cache of group cfg per parent node */
  274. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  275. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  276. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  277. 0,
  278. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  279. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  280. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  281. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  282. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  283. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  284. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  285. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  286. 8,
  287. 48000,
  288. 32,
  289. 8,
  290. 32,
  291. 0xFF,
  292. };
  293. static u32 num_tdm_group_ports;
  294. static struct afe_clk_set tdm_clk_set = {
  295. AFE_API_VERSION_CLOCK_SET,
  296. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  297. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  298. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  299. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  300. 0,
  301. };
  302. int msm_dai_q6_get_group_idx(u16 id)
  303. {
  304. switch (id) {
  305. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  306. case AFE_PORT_ID_PRIMARY_TDM_RX:
  307. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  308. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  309. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  310. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  311. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  312. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  313. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  314. return IDX_GROUP_PRIMARY_TDM_RX;
  315. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  316. case AFE_PORT_ID_PRIMARY_TDM_TX:
  317. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  318. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  319. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  320. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  321. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  322. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  323. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  324. return IDX_GROUP_PRIMARY_TDM_TX;
  325. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  326. case AFE_PORT_ID_SECONDARY_TDM_RX:
  327. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  328. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  329. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  330. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  331. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  332. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  333. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  334. return IDX_GROUP_SECONDARY_TDM_RX;
  335. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  336. case AFE_PORT_ID_SECONDARY_TDM_TX:
  337. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  338. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  339. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  340. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  341. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  342. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  343. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  344. return IDX_GROUP_SECONDARY_TDM_TX;
  345. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  346. case AFE_PORT_ID_TERTIARY_TDM_RX:
  347. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  348. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  349. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  350. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  351. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  352. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  353. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  354. return IDX_GROUP_TERTIARY_TDM_RX;
  355. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  356. case AFE_PORT_ID_TERTIARY_TDM_TX:
  357. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  358. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  359. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  360. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  361. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  362. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  363. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  364. return IDX_GROUP_TERTIARY_TDM_TX;
  365. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  366. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  367. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  368. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  369. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  370. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  371. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  372. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  373. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  374. return IDX_GROUP_QUATERNARY_TDM_RX;
  375. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  376. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  377. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  378. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  379. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  380. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  381. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  382. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  383. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  384. return IDX_GROUP_QUATERNARY_TDM_TX;
  385. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  386. case AFE_PORT_ID_QUINARY_TDM_RX:
  387. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  388. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  389. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  390. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  391. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  392. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  393. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  394. return IDX_GROUP_QUINARY_TDM_RX;
  395. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  396. case AFE_PORT_ID_QUINARY_TDM_TX:
  397. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  398. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  399. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  400. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  401. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  402. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  403. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  404. return IDX_GROUP_QUINARY_TDM_TX;
  405. default: return -EINVAL;
  406. }
  407. }
  408. int msm_dai_q6_get_port_idx(u16 id)
  409. {
  410. switch (id) {
  411. case AFE_PORT_ID_PRIMARY_TDM_RX:
  412. return IDX_PRIMARY_TDM_RX_0;
  413. case AFE_PORT_ID_PRIMARY_TDM_TX:
  414. return IDX_PRIMARY_TDM_TX_0;
  415. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  416. return IDX_PRIMARY_TDM_RX_1;
  417. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  418. return IDX_PRIMARY_TDM_TX_1;
  419. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  420. return IDX_PRIMARY_TDM_RX_2;
  421. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  422. return IDX_PRIMARY_TDM_TX_2;
  423. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  424. return IDX_PRIMARY_TDM_RX_3;
  425. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  426. return IDX_PRIMARY_TDM_TX_3;
  427. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  428. return IDX_PRIMARY_TDM_RX_4;
  429. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  430. return IDX_PRIMARY_TDM_TX_4;
  431. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  432. return IDX_PRIMARY_TDM_RX_5;
  433. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  434. return IDX_PRIMARY_TDM_TX_5;
  435. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  436. return IDX_PRIMARY_TDM_RX_6;
  437. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  438. return IDX_PRIMARY_TDM_TX_6;
  439. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  440. return IDX_PRIMARY_TDM_RX_7;
  441. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  442. return IDX_PRIMARY_TDM_TX_7;
  443. case AFE_PORT_ID_SECONDARY_TDM_RX:
  444. return IDX_SECONDARY_TDM_RX_0;
  445. case AFE_PORT_ID_SECONDARY_TDM_TX:
  446. return IDX_SECONDARY_TDM_TX_0;
  447. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  448. return IDX_SECONDARY_TDM_RX_1;
  449. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  450. return IDX_SECONDARY_TDM_TX_1;
  451. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  452. return IDX_SECONDARY_TDM_RX_2;
  453. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  454. return IDX_SECONDARY_TDM_TX_2;
  455. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  456. return IDX_SECONDARY_TDM_RX_3;
  457. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  458. return IDX_SECONDARY_TDM_TX_3;
  459. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  460. return IDX_SECONDARY_TDM_RX_4;
  461. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  462. return IDX_SECONDARY_TDM_TX_4;
  463. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  464. return IDX_SECONDARY_TDM_RX_5;
  465. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  466. return IDX_SECONDARY_TDM_TX_5;
  467. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  468. return IDX_SECONDARY_TDM_RX_6;
  469. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  470. return IDX_SECONDARY_TDM_TX_6;
  471. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  472. return IDX_SECONDARY_TDM_RX_7;
  473. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  474. return IDX_SECONDARY_TDM_TX_7;
  475. case AFE_PORT_ID_TERTIARY_TDM_RX:
  476. return IDX_TERTIARY_TDM_RX_0;
  477. case AFE_PORT_ID_TERTIARY_TDM_TX:
  478. return IDX_TERTIARY_TDM_TX_0;
  479. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  480. return IDX_TERTIARY_TDM_RX_1;
  481. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  482. return IDX_TERTIARY_TDM_TX_1;
  483. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  484. return IDX_TERTIARY_TDM_RX_2;
  485. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  486. return IDX_TERTIARY_TDM_TX_2;
  487. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  488. return IDX_TERTIARY_TDM_RX_3;
  489. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  490. return IDX_TERTIARY_TDM_TX_3;
  491. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  492. return IDX_TERTIARY_TDM_RX_4;
  493. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  494. return IDX_TERTIARY_TDM_TX_4;
  495. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  496. return IDX_TERTIARY_TDM_RX_5;
  497. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  498. return IDX_TERTIARY_TDM_TX_5;
  499. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  500. return IDX_TERTIARY_TDM_RX_6;
  501. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  502. return IDX_TERTIARY_TDM_TX_6;
  503. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  504. return IDX_TERTIARY_TDM_RX_7;
  505. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  506. return IDX_TERTIARY_TDM_TX_7;
  507. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  508. return IDX_QUATERNARY_TDM_RX_0;
  509. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  510. return IDX_QUATERNARY_TDM_TX_0;
  511. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  512. return IDX_QUATERNARY_TDM_RX_1;
  513. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  514. return IDX_QUATERNARY_TDM_TX_1;
  515. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  516. return IDX_QUATERNARY_TDM_RX_2;
  517. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  518. return IDX_QUATERNARY_TDM_TX_2;
  519. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  520. return IDX_QUATERNARY_TDM_RX_3;
  521. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  522. return IDX_QUATERNARY_TDM_TX_3;
  523. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  524. return IDX_QUATERNARY_TDM_RX_4;
  525. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  526. return IDX_QUATERNARY_TDM_TX_4;
  527. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  528. return IDX_QUATERNARY_TDM_RX_5;
  529. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  530. return IDX_QUATERNARY_TDM_TX_5;
  531. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  532. return IDX_QUATERNARY_TDM_RX_6;
  533. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  534. return IDX_QUATERNARY_TDM_TX_6;
  535. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  536. return IDX_QUATERNARY_TDM_RX_7;
  537. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  538. return IDX_QUATERNARY_TDM_TX_7;
  539. case AFE_PORT_ID_QUINARY_TDM_RX:
  540. return IDX_QUINARY_TDM_RX_0;
  541. case AFE_PORT_ID_QUINARY_TDM_TX:
  542. return IDX_QUINARY_TDM_TX_0;
  543. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  544. return IDX_QUINARY_TDM_RX_1;
  545. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  546. return IDX_QUINARY_TDM_TX_1;
  547. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  548. return IDX_QUINARY_TDM_RX_2;
  549. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  550. return IDX_QUINARY_TDM_TX_2;
  551. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  552. return IDX_QUINARY_TDM_RX_3;
  553. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  554. return IDX_QUINARY_TDM_TX_3;
  555. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  556. return IDX_QUINARY_TDM_RX_4;
  557. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  558. return IDX_QUINARY_TDM_TX_4;
  559. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  560. return IDX_QUINARY_TDM_RX_5;
  561. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  562. return IDX_QUINARY_TDM_TX_5;
  563. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  564. return IDX_QUINARY_TDM_RX_6;
  565. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  566. return IDX_QUINARY_TDM_TX_6;
  567. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  568. return IDX_QUINARY_TDM_RX_7;
  569. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  570. return IDX_QUINARY_TDM_TX_7;
  571. default: return -EINVAL;
  572. }
  573. }
  574. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  575. {
  576. /* Max num of slots is bits per frame divided
  577. * by bits per sample which is 16
  578. */
  579. switch (frame_rate) {
  580. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  581. return 0;
  582. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  583. return 1;
  584. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  585. return 2;
  586. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  587. return 4;
  588. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  589. return 8;
  590. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  591. return 16;
  592. default:
  593. pr_err("%s Invalid bits per frame %d\n",
  594. __func__, frame_rate);
  595. return 0;
  596. }
  597. }
  598. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  599. {
  600. struct snd_soc_dapm_route intercon;
  601. struct snd_soc_dapm_context *dapm;
  602. if (!dai) {
  603. pr_err("%s: Invalid params dai\n", __func__);
  604. return -EINVAL;
  605. }
  606. if (!dai->driver) {
  607. pr_err("%s: Invalid params dai driver\n", __func__);
  608. return -EINVAL;
  609. }
  610. dapm = snd_soc_component_get_dapm(dai->component);
  611. memset(&intercon, 0, sizeof(intercon));
  612. if (dai->driver->playback.stream_name &&
  613. dai->driver->playback.aif_name) {
  614. dev_dbg(dai->dev, "%s: add route for widget %s",
  615. __func__, dai->driver->playback.stream_name);
  616. intercon.source = dai->driver->playback.aif_name;
  617. intercon.sink = dai->driver->playback.stream_name;
  618. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  619. __func__, intercon.source, intercon.sink);
  620. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  621. }
  622. if (dai->driver->capture.stream_name &&
  623. dai->driver->capture.aif_name) {
  624. dev_dbg(dai->dev, "%s: add route for widget %s",
  625. __func__, dai->driver->capture.stream_name);
  626. intercon.sink = dai->driver->capture.aif_name;
  627. intercon.source = dai->driver->capture.stream_name;
  628. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  629. __func__, intercon.source, intercon.sink);
  630. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  631. }
  632. return 0;
  633. }
  634. static int msm_dai_q6_auxpcm_hw_params(
  635. struct snd_pcm_substream *substream,
  636. struct snd_pcm_hw_params *params,
  637. struct snd_soc_dai *dai)
  638. {
  639. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  640. dev_get_drvdata(dai->dev);
  641. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  642. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  643. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  644. int rc = 0, slot_mapping_copy_len = 0;
  645. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  646. params_rate(params) != 16000)) {
  647. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  648. __func__, params_channels(params), params_rate(params));
  649. return -EINVAL;
  650. }
  651. mutex_lock(&aux_dai_data->rlock);
  652. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  653. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  654. /* AUXPCM DAI in use */
  655. if (dai_data->rate != params_rate(params)) {
  656. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  657. __func__);
  658. rc = -EINVAL;
  659. }
  660. mutex_unlock(&aux_dai_data->rlock);
  661. return rc;
  662. }
  663. dai_data->channels = params_channels(params);
  664. dai_data->rate = params_rate(params);
  665. if (dai_data->rate == 8000) {
  666. dai_data->port_config.pcm.pcm_cfg_minor_version =
  667. AFE_API_VERSION_PCM_CONFIG;
  668. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  669. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  670. dai_data->port_config.pcm.frame_setting =
  671. auxpcm_pdata->mode_8k.frame;
  672. dai_data->port_config.pcm.quantype =
  673. auxpcm_pdata->mode_8k.quant;
  674. dai_data->port_config.pcm.ctrl_data_out_enable =
  675. auxpcm_pdata->mode_8k.data;
  676. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  677. dai_data->port_config.pcm.num_channels = dai_data->channels;
  678. dai_data->port_config.pcm.bit_width = 16;
  679. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  680. auxpcm_pdata->mode_8k.num_slots)
  681. slot_mapping_copy_len =
  682. ARRAY_SIZE(
  683. dai_data->port_config.pcm.slot_number_mapping)
  684. * sizeof(uint16_t);
  685. else
  686. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  687. * sizeof(uint16_t);
  688. if (auxpcm_pdata->mode_8k.slot_mapping) {
  689. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  690. auxpcm_pdata->mode_8k.slot_mapping,
  691. slot_mapping_copy_len);
  692. } else {
  693. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  694. __func__);
  695. mutex_unlock(&aux_dai_data->rlock);
  696. return -EINVAL;
  697. }
  698. } else {
  699. dai_data->port_config.pcm.pcm_cfg_minor_version =
  700. AFE_API_VERSION_PCM_CONFIG;
  701. dai_data->port_config.pcm.aux_mode =
  702. auxpcm_pdata->mode_16k.mode;
  703. dai_data->port_config.pcm.sync_src =
  704. auxpcm_pdata->mode_16k.sync;
  705. dai_data->port_config.pcm.frame_setting =
  706. auxpcm_pdata->mode_16k.frame;
  707. dai_data->port_config.pcm.quantype =
  708. auxpcm_pdata->mode_16k.quant;
  709. dai_data->port_config.pcm.ctrl_data_out_enable =
  710. auxpcm_pdata->mode_16k.data;
  711. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  712. dai_data->port_config.pcm.num_channels = dai_data->channels;
  713. dai_data->port_config.pcm.bit_width = 16;
  714. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  715. auxpcm_pdata->mode_16k.num_slots)
  716. slot_mapping_copy_len =
  717. ARRAY_SIZE(
  718. dai_data->port_config.pcm.slot_number_mapping)
  719. * sizeof(uint16_t);
  720. else
  721. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  722. * sizeof(uint16_t);
  723. if (auxpcm_pdata->mode_16k.slot_mapping) {
  724. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  725. auxpcm_pdata->mode_16k.slot_mapping,
  726. slot_mapping_copy_len);
  727. } else {
  728. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  729. __func__);
  730. mutex_unlock(&aux_dai_data->rlock);
  731. return -EINVAL;
  732. }
  733. }
  734. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  735. __func__, dai_data->port_config.pcm.aux_mode,
  736. dai_data->port_config.pcm.sync_src,
  737. dai_data->port_config.pcm.frame_setting);
  738. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  739. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  740. __func__, dai_data->port_config.pcm.quantype,
  741. dai_data->port_config.pcm.ctrl_data_out_enable,
  742. dai_data->port_config.pcm.slot_number_mapping[0],
  743. dai_data->port_config.pcm.slot_number_mapping[1],
  744. dai_data->port_config.pcm.slot_number_mapping[2],
  745. dai_data->port_config.pcm.slot_number_mapping[3]);
  746. mutex_unlock(&aux_dai_data->rlock);
  747. return rc;
  748. }
  749. static int msm_dai_q6_auxpcm_set_clk(
  750. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  751. u16 port_id, bool enable)
  752. {
  753. int rc;
  754. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  755. aux_dai_data->afe_clk_ver, port_id, enable);
  756. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  757. aux_dai_data->clk_set.enable = enable;
  758. rc = afe_set_lpass_clock_v2(port_id,
  759. &aux_dai_data->clk_set);
  760. } else {
  761. if (!enable)
  762. aux_dai_data->clk_cfg.clk_val1 = 0;
  763. rc = afe_set_lpass_clock(port_id,
  764. &aux_dai_data->clk_cfg);
  765. }
  766. return rc;
  767. }
  768. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  769. struct snd_soc_dai *dai)
  770. {
  771. int rc = 0;
  772. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  773. dev_get_drvdata(dai->dev);
  774. mutex_lock(&aux_dai_data->rlock);
  775. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  776. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  777. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  778. __func__, dai->id);
  779. goto exit;
  780. }
  781. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  782. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  783. clear_bit(STATUS_TX_PORT,
  784. aux_dai_data->auxpcm_port_status);
  785. else {
  786. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  787. __func__);
  788. goto exit;
  789. }
  790. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  791. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  792. clear_bit(STATUS_RX_PORT,
  793. aux_dai_data->auxpcm_port_status);
  794. else {
  795. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  796. __func__);
  797. goto exit;
  798. }
  799. }
  800. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  801. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  802. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  803. __func__);
  804. goto exit;
  805. }
  806. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  807. __func__, dai->id);
  808. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  809. if (rc < 0)
  810. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  811. rc = afe_close(aux_dai_data->tx_pid);
  812. if (rc < 0)
  813. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  814. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  815. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  816. exit:
  817. mutex_unlock(&aux_dai_data->rlock);
  818. }
  819. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  820. struct snd_soc_dai *dai)
  821. {
  822. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  823. dev_get_drvdata(dai->dev);
  824. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  825. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  826. int rc = 0;
  827. u32 pcm_clk_rate;
  828. auxpcm_pdata = dai->dev->platform_data;
  829. mutex_lock(&aux_dai_data->rlock);
  830. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  831. if (test_bit(STATUS_TX_PORT,
  832. aux_dai_data->auxpcm_port_status)) {
  833. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  834. __func__);
  835. goto exit;
  836. } else
  837. set_bit(STATUS_TX_PORT,
  838. aux_dai_data->auxpcm_port_status);
  839. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  840. if (test_bit(STATUS_RX_PORT,
  841. aux_dai_data->auxpcm_port_status)) {
  842. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  843. __func__);
  844. goto exit;
  845. } else
  846. set_bit(STATUS_RX_PORT,
  847. aux_dai_data->auxpcm_port_status);
  848. }
  849. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  850. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  851. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  852. goto exit;
  853. }
  854. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  855. __func__, dai->id);
  856. rc = afe_q6_interface_prepare();
  857. if (rc < 0) {
  858. dev_err(dai->dev, "fail to open AFE APR\n");
  859. goto fail;
  860. }
  861. /*
  862. * For AUX PCM Interface the below sequence of clk
  863. * settings and afe_open is a strict requirement.
  864. *
  865. * Also using afe_open instead of afe_port_start_nowait
  866. * to make sure the port is open before deasserting the
  867. * clock line. This is required because pcm register is
  868. * not written before clock deassert. Hence the hw does
  869. * not get updated with new setting if the below clock
  870. * assert/deasset and afe_open sequence is not followed.
  871. */
  872. if (dai_data->rate == 8000) {
  873. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  874. } else if (dai_data->rate == 16000) {
  875. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  876. } else {
  877. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  878. dai_data->rate);
  879. rc = -EINVAL;
  880. goto fail;
  881. }
  882. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  883. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  884. sizeof(struct afe_clk_set));
  885. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  886. switch (dai->id) {
  887. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  888. if (pcm_clk_rate)
  889. aux_dai_data->clk_set.clk_id =
  890. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  891. else
  892. aux_dai_data->clk_set.clk_id =
  893. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  894. break;
  895. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  896. if (pcm_clk_rate)
  897. aux_dai_data->clk_set.clk_id =
  898. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  899. else
  900. aux_dai_data->clk_set.clk_id =
  901. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  902. break;
  903. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  904. if (pcm_clk_rate)
  905. aux_dai_data->clk_set.clk_id =
  906. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  907. else
  908. aux_dai_data->clk_set.clk_id =
  909. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  910. break;
  911. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  912. if (pcm_clk_rate)
  913. aux_dai_data->clk_set.clk_id =
  914. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  915. else
  916. aux_dai_data->clk_set.clk_id =
  917. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  918. break;
  919. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  920. if (pcm_clk_rate)
  921. aux_dai_data->clk_set.clk_id =
  922. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  923. else
  924. aux_dai_data->clk_set.clk_id =
  925. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  926. break;
  927. default:
  928. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  929. __func__, dai->id);
  930. break;
  931. }
  932. } else {
  933. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  934. sizeof(struct afe_clk_cfg));
  935. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  936. }
  937. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  938. aux_dai_data->rx_pid, true);
  939. if (rc < 0) {
  940. dev_err(dai->dev,
  941. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  942. __func__);
  943. goto fail;
  944. }
  945. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  946. aux_dai_data->tx_pid, true);
  947. if (rc < 0) {
  948. dev_err(dai->dev,
  949. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  950. __func__);
  951. goto fail;
  952. }
  953. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  954. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  955. goto exit;
  956. fail:
  957. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  958. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  959. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  960. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  961. exit:
  962. mutex_unlock(&aux_dai_data->rlock);
  963. return rc;
  964. }
  965. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  966. int cmd, struct snd_soc_dai *dai)
  967. {
  968. int rc = 0;
  969. pr_debug("%s:port:%d cmd:%d\n",
  970. __func__, dai->id, cmd);
  971. switch (cmd) {
  972. case SNDRV_PCM_TRIGGER_START:
  973. case SNDRV_PCM_TRIGGER_RESUME:
  974. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  975. /* afe_open will be called from prepare */
  976. return 0;
  977. case SNDRV_PCM_TRIGGER_STOP:
  978. case SNDRV_PCM_TRIGGER_SUSPEND:
  979. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  980. return 0;
  981. default:
  982. pr_err("%s: cmd %d\n", __func__, cmd);
  983. rc = -EINVAL;
  984. }
  985. return rc;
  986. }
  987. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  988. {
  989. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  990. int rc;
  991. aux_dai_data = dev_get_drvdata(dai->dev);
  992. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  993. __func__, dai->id);
  994. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  995. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  996. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  997. if (rc < 0)
  998. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  999. rc = afe_close(aux_dai_data->tx_pid);
  1000. if (rc < 0)
  1001. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1002. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1003. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1004. }
  1005. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1006. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1007. return 0;
  1008. }
  1009. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1010. {
  1011. int rc = 0;
  1012. if (!dai) {
  1013. pr_err("%s: Invalid params dai\n", __func__);
  1014. return -EINVAL;
  1015. }
  1016. if (!dai->dev) {
  1017. pr_err("%s: Invalid params dai dev\n", __func__);
  1018. return -EINVAL;
  1019. }
  1020. if (!dai->driver->id) {
  1021. dev_warn(dai->dev, "DAI driver id is not set\n");
  1022. return -EINVAL;
  1023. }
  1024. dai->id = dai->driver->id;
  1025. rc = msm_dai_q6_dai_add_route(dai);
  1026. return rc;
  1027. }
  1028. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1029. .prepare = msm_dai_q6_auxpcm_prepare,
  1030. .trigger = msm_dai_q6_auxpcm_trigger,
  1031. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1032. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1033. };
  1034. static const struct snd_soc_component_driver
  1035. msm_dai_q6_aux_pcm_dai_component = {
  1036. .name = "msm-auxpcm-dev",
  1037. };
  1038. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1039. {
  1040. .playback = {
  1041. .stream_name = "AUX PCM Playback",
  1042. .aif_name = "AUX_PCM_RX",
  1043. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1044. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1045. .channels_min = 1,
  1046. .channels_max = 1,
  1047. .rate_max = 16000,
  1048. .rate_min = 8000,
  1049. },
  1050. .capture = {
  1051. .stream_name = "AUX PCM Capture",
  1052. .aif_name = "AUX_PCM_TX",
  1053. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1054. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1055. .channels_min = 1,
  1056. .channels_max = 1,
  1057. .rate_max = 16000,
  1058. .rate_min = 8000,
  1059. },
  1060. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1061. .ops = &msm_dai_q6_auxpcm_ops,
  1062. .probe = msm_dai_q6_aux_pcm_probe,
  1063. .remove = msm_dai_q6_dai_auxpcm_remove,
  1064. },
  1065. {
  1066. .playback = {
  1067. .stream_name = "Sec AUX PCM Playback",
  1068. .aif_name = "SEC_AUX_PCM_RX",
  1069. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1070. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1071. .channels_min = 1,
  1072. .channels_max = 1,
  1073. .rate_max = 16000,
  1074. .rate_min = 8000,
  1075. },
  1076. .capture = {
  1077. .stream_name = "Sec AUX PCM Capture",
  1078. .aif_name = "SEC_AUX_PCM_TX",
  1079. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1080. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1081. .channels_min = 1,
  1082. .channels_max = 1,
  1083. .rate_max = 16000,
  1084. .rate_min = 8000,
  1085. },
  1086. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1087. .ops = &msm_dai_q6_auxpcm_ops,
  1088. .probe = msm_dai_q6_aux_pcm_probe,
  1089. .remove = msm_dai_q6_dai_auxpcm_remove,
  1090. },
  1091. {
  1092. .playback = {
  1093. .stream_name = "Tert AUX PCM Playback",
  1094. .aif_name = "TERT_AUX_PCM_RX",
  1095. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1096. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1097. .channels_min = 1,
  1098. .channels_max = 1,
  1099. .rate_max = 16000,
  1100. .rate_min = 8000,
  1101. },
  1102. .capture = {
  1103. .stream_name = "Tert AUX PCM Capture",
  1104. .aif_name = "TERT_AUX_PCM_TX",
  1105. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1106. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1107. .channels_min = 1,
  1108. .channels_max = 1,
  1109. .rate_max = 16000,
  1110. .rate_min = 8000,
  1111. },
  1112. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1113. .ops = &msm_dai_q6_auxpcm_ops,
  1114. .probe = msm_dai_q6_aux_pcm_probe,
  1115. .remove = msm_dai_q6_dai_auxpcm_remove,
  1116. },
  1117. {
  1118. .playback = {
  1119. .stream_name = "Quat AUX PCM Playback",
  1120. .aif_name = "QUAT_AUX_PCM_RX",
  1121. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1122. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1123. .channels_min = 1,
  1124. .channels_max = 1,
  1125. .rate_max = 16000,
  1126. .rate_min = 8000,
  1127. },
  1128. .capture = {
  1129. .stream_name = "Quat AUX PCM Capture",
  1130. .aif_name = "QUAT_AUX_PCM_TX",
  1131. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1132. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1133. .channels_min = 1,
  1134. .channels_max = 1,
  1135. .rate_max = 16000,
  1136. .rate_min = 8000,
  1137. },
  1138. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1139. .ops = &msm_dai_q6_auxpcm_ops,
  1140. .probe = msm_dai_q6_aux_pcm_probe,
  1141. .remove = msm_dai_q6_dai_auxpcm_remove,
  1142. },
  1143. {
  1144. .playback = {
  1145. .stream_name = "Quin AUX PCM Playback",
  1146. .aif_name = "QUIN_AUX_PCM_RX",
  1147. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1148. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1149. .channels_min = 1,
  1150. .channels_max = 1,
  1151. .rate_max = 16000,
  1152. .rate_min = 8000,
  1153. },
  1154. .capture = {
  1155. .stream_name = "Quin AUX PCM Capture",
  1156. .aif_name = "QUIN_AUX_PCM_TX",
  1157. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1158. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1159. .channels_min = 1,
  1160. .channels_max = 1,
  1161. .rate_max = 16000,
  1162. .rate_min = 8000,
  1163. },
  1164. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1165. .ops = &msm_dai_q6_auxpcm_ops,
  1166. .probe = msm_dai_q6_aux_pcm_probe,
  1167. .remove = msm_dai_q6_dai_auxpcm_remove,
  1168. },
  1169. };
  1170. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1171. struct snd_ctl_elem_value *ucontrol)
  1172. {
  1173. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1174. int value = ucontrol->value.integer.value[0];
  1175. dai_data->spdif_port.cfg.data_format = value;
  1176. pr_debug("%s: value = %d\n", __func__, value);
  1177. return 0;
  1178. }
  1179. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1180. struct snd_ctl_elem_value *ucontrol)
  1181. {
  1182. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1183. ucontrol->value.integer.value[0] =
  1184. dai_data->spdif_port.cfg.data_format;
  1185. return 0;
  1186. }
  1187. static const char * const spdif_format[] = {
  1188. "LPCM",
  1189. "Compr"
  1190. };
  1191. static const struct soc_enum spdif_config_enum[] = {
  1192. SOC_ENUM_SINGLE_EXT(2, spdif_format),
  1193. };
  1194. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1195. struct snd_ctl_elem_value *ucontrol)
  1196. {
  1197. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1198. int ret = 0;
  1199. dai_data->spdif_port.ch_status.status_type =
  1200. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1201. memset(dai_data->spdif_port.ch_status.status_mask,
  1202. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1203. dai_data->spdif_port.ch_status.status_mask[0] =
  1204. CHANNEL_STATUS_MASK;
  1205. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1206. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1207. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1208. pr_debug("%s: Port already started. Dynamic update\n",
  1209. __func__);
  1210. ret = afe_send_spdif_ch_status_cfg(
  1211. &dai_data->spdif_port.ch_status,
  1212. AFE_PORT_ID_SPDIF_RX);
  1213. }
  1214. return ret;
  1215. }
  1216. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1217. struct snd_ctl_elem_value *ucontrol)
  1218. {
  1219. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1220. memcpy(ucontrol->value.iec958.status,
  1221. dai_data->spdif_port.ch_status.status_bits,
  1222. CHANNEL_STATUS_SIZE);
  1223. return 0;
  1224. }
  1225. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1226. struct snd_ctl_elem_info *uinfo)
  1227. {
  1228. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1229. uinfo->count = 1;
  1230. return 0;
  1231. }
  1232. static const struct snd_kcontrol_new spdif_config_controls[] = {
  1233. {
  1234. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1235. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1236. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1237. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1238. .info = msm_dai_q6_spdif_chstatus_info,
  1239. .get = msm_dai_q6_spdif_chstatus_get,
  1240. .put = msm_dai_q6_spdif_chstatus_put,
  1241. },
  1242. SOC_ENUM_EXT("SPDIF RX Format", spdif_config_enum[0],
  1243. msm_dai_q6_spdif_format_get,
  1244. msm_dai_q6_spdif_format_put)
  1245. };
  1246. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1247. struct snd_pcm_hw_params *params,
  1248. struct snd_soc_dai *dai)
  1249. {
  1250. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1251. dai->id = AFE_PORT_ID_SPDIF_RX;
  1252. dai_data->channels = params_channels(params);
  1253. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1254. switch (params_format(params)) {
  1255. case SNDRV_PCM_FORMAT_S16_LE:
  1256. dai_data->spdif_port.cfg.bit_width = 16;
  1257. break;
  1258. case SNDRV_PCM_FORMAT_S24_LE:
  1259. case SNDRV_PCM_FORMAT_S24_3LE:
  1260. dai_data->spdif_port.cfg.bit_width = 24;
  1261. break;
  1262. default:
  1263. pr_err("%s: format %d\n",
  1264. __func__, params_format(params));
  1265. return -EINVAL;
  1266. }
  1267. dai_data->rate = params_rate(params);
  1268. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1269. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1270. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1271. AFE_API_VERSION_SPDIF_CONFIG;
  1272. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1273. dai_data->channels, dai_data->rate,
  1274. dai_data->spdif_port.cfg.bit_width);
  1275. dai_data->spdif_port.cfg.reserved = 0;
  1276. return 0;
  1277. }
  1278. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1279. struct snd_soc_dai *dai)
  1280. {
  1281. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1282. int rc = 0;
  1283. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1284. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1285. __func__, *dai_data->status_mask);
  1286. return;
  1287. }
  1288. rc = afe_close(dai->id);
  1289. if (rc < 0)
  1290. dev_err(dai->dev, "fail to close AFE port\n");
  1291. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1292. *dai_data->status_mask);
  1293. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1294. }
  1295. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1296. struct snd_soc_dai *dai)
  1297. {
  1298. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1299. int rc = 0;
  1300. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1301. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1302. dai_data->rate);
  1303. if (rc < 0)
  1304. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1305. dai->id);
  1306. else
  1307. set_bit(STATUS_PORT_STARTED,
  1308. dai_data->status_mask);
  1309. }
  1310. return rc;
  1311. }
  1312. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1313. {
  1314. struct msm_dai_q6_spdif_dai_data *dai_data;
  1315. const struct snd_kcontrol_new *kcontrol;
  1316. int rc = 0;
  1317. struct snd_soc_dapm_route intercon;
  1318. struct snd_soc_dapm_context *dapm;
  1319. if (!dai) {
  1320. pr_err("%s: dai not found!!\n", __func__);
  1321. return -EINVAL;
  1322. }
  1323. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1324. GFP_KERNEL);
  1325. if (!dai_data) {
  1326. dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
  1327. AFE_PORT_ID_SPDIF_RX);
  1328. rc = -ENOMEM;
  1329. } else
  1330. dev_set_drvdata(dai->dev, dai_data);
  1331. kcontrol = &spdif_config_controls[1];
  1332. dapm = snd_soc_component_get_dapm(dai->component);
  1333. rc = snd_ctl_add(dai->component->card->snd_card,
  1334. snd_ctl_new1(kcontrol, dai_data));
  1335. memset(&intercon, 0, sizeof(intercon));
  1336. if (!rc && dai && dai->driver) {
  1337. if (dai->driver->playback.stream_name &&
  1338. dai->driver->playback.aif_name) {
  1339. dev_dbg(dai->dev, "%s: add route for widget %s",
  1340. __func__, dai->driver->playback.stream_name);
  1341. intercon.source = dai->driver->playback.aif_name;
  1342. intercon.sink = dai->driver->playback.stream_name;
  1343. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1344. __func__, intercon.source, intercon.sink);
  1345. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1346. }
  1347. if (dai->driver->capture.stream_name &&
  1348. dai->driver->capture.aif_name) {
  1349. dev_dbg(dai->dev, "%s: add route for widget %s",
  1350. __func__, dai->driver->capture.stream_name);
  1351. intercon.sink = dai->driver->capture.aif_name;
  1352. intercon.source = dai->driver->capture.stream_name;
  1353. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1354. __func__, intercon.source, intercon.sink);
  1355. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1356. }
  1357. }
  1358. return rc;
  1359. }
  1360. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  1361. {
  1362. struct msm_dai_q6_spdif_dai_data *dai_data;
  1363. int rc;
  1364. dai_data = dev_get_drvdata(dai->dev);
  1365. /* If AFE port is still up, close it */
  1366. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1367. rc = afe_close(dai->id); /* can block */
  1368. if (rc < 0)
  1369. dev_err(dai->dev, "fail to close AFE port\n");
  1370. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1371. }
  1372. kfree(dai_data);
  1373. return 0;
  1374. }
  1375. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  1376. .prepare = msm_dai_q6_spdif_prepare,
  1377. .hw_params = msm_dai_q6_spdif_hw_params,
  1378. .shutdown = msm_dai_q6_spdif_shutdown,
  1379. };
  1380. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai = {
  1381. .playback = {
  1382. .stream_name = "SPDIF Playback",
  1383. .aif_name = "SPDIF_RX",
  1384. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1385. SNDRV_PCM_RATE_16000,
  1386. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
  1387. .channels_min = 1,
  1388. .channels_max = 4,
  1389. .rate_min = 8000,
  1390. .rate_max = 48000,
  1391. },
  1392. .ops = &msm_dai_q6_spdif_ops,
  1393. .probe = msm_dai_q6_spdif_dai_probe,
  1394. .remove = msm_dai_q6_spdif_dai_remove,
  1395. };
  1396. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  1397. .name = "msm-dai-q6-spdif",
  1398. };
  1399. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  1400. struct snd_soc_dai *dai)
  1401. {
  1402. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1403. int rc = 0;
  1404. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1405. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  1406. int bitwidth = 0;
  1407. if (dai_data->afe_in_bitformat ==
  1408. SNDRV_PCM_FORMAT_S24_LE)
  1409. bitwidth = 24;
  1410. else if (dai_data->afe_in_bitformat ==
  1411. SNDRV_PCM_FORMAT_S16_LE)
  1412. bitwidth = 16;
  1413. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  1414. __func__, dai_data->enc_config.format);
  1415. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  1416. dai_data->rate,
  1417. dai_data->afe_in_channels,
  1418. bitwidth,
  1419. &dai_data->enc_config);
  1420. if (rc < 0)
  1421. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  1422. __func__, rc);
  1423. } else {
  1424. rc = afe_port_start(dai->id, &dai_data->port_config,
  1425. dai_data->rate);
  1426. }
  1427. if (rc < 0)
  1428. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1429. dai->id);
  1430. else
  1431. set_bit(STATUS_PORT_STARTED,
  1432. dai_data->status_mask);
  1433. }
  1434. return rc;
  1435. }
  1436. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  1437. struct snd_soc_dai *dai, int stream)
  1438. {
  1439. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1440. dai_data->channels = params_channels(params);
  1441. switch (dai_data->channels) {
  1442. case 2:
  1443. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1444. break;
  1445. case 1:
  1446. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1447. break;
  1448. default:
  1449. return -EINVAL;
  1450. pr_err("%s: err channels %d\n",
  1451. __func__, dai_data->channels);
  1452. break;
  1453. }
  1454. switch (params_format(params)) {
  1455. case SNDRV_PCM_FORMAT_S16_LE:
  1456. case SNDRV_PCM_FORMAT_SPECIAL:
  1457. dai_data->port_config.i2s.bit_width = 16;
  1458. break;
  1459. case SNDRV_PCM_FORMAT_S24_LE:
  1460. case SNDRV_PCM_FORMAT_S24_3LE:
  1461. dai_data->port_config.i2s.bit_width = 24;
  1462. break;
  1463. default:
  1464. pr_err("%s: format %d\n",
  1465. __func__, params_format(params));
  1466. return -EINVAL;
  1467. }
  1468. dai_data->rate = params_rate(params);
  1469. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1470. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1471. AFE_API_VERSION_I2S_CONFIG;
  1472. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1473. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  1474. dai_data->channels, dai_data->rate);
  1475. dai_data->port_config.i2s.channel_mode = 1;
  1476. return 0;
  1477. }
  1478. static u8 num_of_bits_set(u8 sd_line_mask)
  1479. {
  1480. u8 num_bits_set = 0;
  1481. while (sd_line_mask) {
  1482. num_bits_set++;
  1483. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  1484. }
  1485. return num_bits_set;
  1486. }
  1487. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  1488. struct snd_soc_dai *dai, int stream)
  1489. {
  1490. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1491. struct msm_i2s_data *i2s_pdata =
  1492. (struct msm_i2s_data *) dai->dev->platform_data;
  1493. dai_data->channels = params_channels(params);
  1494. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  1495. switch (dai_data->channels) {
  1496. case 2:
  1497. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1498. break;
  1499. case 1:
  1500. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1501. break;
  1502. default:
  1503. pr_warn("%s: greater than stereo has not been validated %d",
  1504. __func__, dai_data->channels);
  1505. break;
  1506. }
  1507. }
  1508. dai_data->rate = params_rate(params);
  1509. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1510. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1511. AFE_API_VERSION_I2S_CONFIG;
  1512. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1513. /* Q6 only supports 16 as now */
  1514. dai_data->port_config.i2s.bit_width = 16;
  1515. dai_data->port_config.i2s.channel_mode = 1;
  1516. return 0;
  1517. }
  1518. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  1519. struct snd_soc_dai *dai, int stream)
  1520. {
  1521. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1522. dai_data->channels = params_channels(params);
  1523. dai_data->rate = params_rate(params);
  1524. switch (params_format(params)) {
  1525. case SNDRV_PCM_FORMAT_S16_LE:
  1526. case SNDRV_PCM_FORMAT_SPECIAL:
  1527. dai_data->port_config.slim_sch.bit_width = 16;
  1528. break;
  1529. case SNDRV_PCM_FORMAT_S24_LE:
  1530. case SNDRV_PCM_FORMAT_S24_3LE:
  1531. dai_data->port_config.slim_sch.bit_width = 24;
  1532. break;
  1533. case SNDRV_PCM_FORMAT_S32_LE:
  1534. dai_data->port_config.slim_sch.bit_width = 32;
  1535. break;
  1536. default:
  1537. pr_err("%s: format %d\n",
  1538. __func__, params_format(params));
  1539. return -EINVAL;
  1540. }
  1541. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  1542. AFE_API_VERSION_SLIMBUS_CONFIG;
  1543. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  1544. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  1545. switch (dai->id) {
  1546. case SLIMBUS_7_RX:
  1547. case SLIMBUS_7_TX:
  1548. case SLIMBUS_8_RX:
  1549. case SLIMBUS_8_TX:
  1550. dai_data->port_config.slim_sch.slimbus_dev_id =
  1551. AFE_SLIMBUS_DEVICE_2;
  1552. break;
  1553. default:
  1554. dai_data->port_config.slim_sch.slimbus_dev_id =
  1555. AFE_SLIMBUS_DEVICE_1;
  1556. break;
  1557. }
  1558. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  1559. "num_channel %hu shared_ch_mapping[0] %hu\n"
  1560. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  1561. "sample_rate %d\n", __func__,
  1562. dai_data->port_config.slim_sch.slimbus_dev_id,
  1563. dai_data->port_config.slim_sch.bit_width,
  1564. dai_data->port_config.slim_sch.data_format,
  1565. dai_data->port_config.slim_sch.num_channels,
  1566. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1567. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  1568. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  1569. dai_data->rate);
  1570. return 0;
  1571. }
  1572. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  1573. struct snd_soc_dai *dai, int stream)
  1574. {
  1575. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1576. dai_data->channels = params_channels(params);
  1577. dai_data->rate = params_rate(params);
  1578. switch (params_format(params)) {
  1579. case SNDRV_PCM_FORMAT_S16_LE:
  1580. case SNDRV_PCM_FORMAT_SPECIAL:
  1581. dai_data->port_config.usb_audio.bit_width = 16;
  1582. break;
  1583. case SNDRV_PCM_FORMAT_S24_LE:
  1584. case SNDRV_PCM_FORMAT_S24_3LE:
  1585. dai_data->port_config.usb_audio.bit_width = 24;
  1586. break;
  1587. case SNDRV_PCM_FORMAT_S32_LE:
  1588. dai_data->port_config.usb_audio.bit_width = 32;
  1589. break;
  1590. default:
  1591. dev_err(dai->dev, "%s: invalid format %d\n",
  1592. __func__, params_format(params));
  1593. return -EINVAL;
  1594. }
  1595. dai_data->port_config.usb_audio.cfg_minor_version =
  1596. AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
  1597. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  1598. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  1599. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  1600. "num_channel %hu sample_rate %d\n", __func__,
  1601. dai_data->port_config.usb_audio.dev_token,
  1602. dai_data->port_config.usb_audio.bit_width,
  1603. dai_data->port_config.usb_audio.data_format,
  1604. dai_data->port_config.usb_audio.num_channels,
  1605. dai_data->port_config.usb_audio.sample_rate);
  1606. return 0;
  1607. }
  1608. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  1609. struct snd_soc_dai *dai, int stream)
  1610. {
  1611. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1612. dai_data->channels = params_channels(params);
  1613. dai_data->rate = params_rate(params);
  1614. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  1615. dai_data->channels, dai_data->rate);
  1616. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  1617. pr_debug("%s: setting bt_fm parameters\n", __func__);
  1618. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  1619. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  1620. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  1621. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  1622. dai_data->port_config.int_bt_fm.bit_width = 16;
  1623. return 0;
  1624. }
  1625. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  1626. struct snd_soc_dai *dai)
  1627. {
  1628. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1629. dai_data->rate = params_rate(params);
  1630. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  1631. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  1632. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  1633. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  1634. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  1635. AFE_API_VERSION_RT_PROXY_CONFIG;
  1636. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  1637. dai_data->port_config.rtproxy.interleaved = 1;
  1638. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  1639. dai_data->port_config.rtproxy.jitter_allowance =
  1640. dai_data->port_config.rtproxy.frame_size/2;
  1641. dai_data->port_config.rtproxy.low_water_mark = 0;
  1642. dai_data->port_config.rtproxy.high_water_mark = 0;
  1643. return 0;
  1644. }
  1645. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  1646. struct snd_soc_dai *dai, int stream)
  1647. {
  1648. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1649. dai_data->channels = params_channels(params);
  1650. dai_data->rate = params_rate(params);
  1651. /* Q6 only supports 16 as now */
  1652. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  1653. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  1654. dai_data->port_config.pseudo_port.num_channels =
  1655. params_channels(params);
  1656. dai_data->port_config.pseudo_port.bit_width = 16;
  1657. dai_data->port_config.pseudo_port.data_format = 0;
  1658. dai_data->port_config.pseudo_port.timing_mode =
  1659. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  1660. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  1661. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  1662. "timing Mode %hu sample_rate %d\n", __func__,
  1663. dai_data->port_config.pseudo_port.bit_width,
  1664. dai_data->port_config.pseudo_port.num_channels,
  1665. dai_data->port_config.pseudo_port.data_format,
  1666. dai_data->port_config.pseudo_port.timing_mode,
  1667. dai_data->port_config.pseudo_port.sample_rate);
  1668. return 0;
  1669. }
  1670. /* Current implementation assumes hw_param is called once
  1671. * This may not be the case but what to do when ADM and AFE
  1672. * port are already opened and parameter changes
  1673. */
  1674. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  1675. struct snd_pcm_hw_params *params,
  1676. struct snd_soc_dai *dai)
  1677. {
  1678. int rc = 0;
  1679. switch (dai->id) {
  1680. case PRIMARY_I2S_TX:
  1681. case PRIMARY_I2S_RX:
  1682. case SECONDARY_I2S_RX:
  1683. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  1684. break;
  1685. case MI2S_RX:
  1686. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  1687. break;
  1688. case SLIMBUS_0_RX:
  1689. case SLIMBUS_1_RX:
  1690. case SLIMBUS_2_RX:
  1691. case SLIMBUS_3_RX:
  1692. case SLIMBUS_4_RX:
  1693. case SLIMBUS_5_RX:
  1694. case SLIMBUS_6_RX:
  1695. case SLIMBUS_7_RX:
  1696. case SLIMBUS_8_RX:
  1697. case SLIMBUS_0_TX:
  1698. case SLIMBUS_1_TX:
  1699. case SLIMBUS_2_TX:
  1700. case SLIMBUS_3_TX:
  1701. case SLIMBUS_4_TX:
  1702. case SLIMBUS_5_TX:
  1703. case SLIMBUS_6_TX:
  1704. case SLIMBUS_7_TX:
  1705. case SLIMBUS_8_TX:
  1706. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  1707. substream->stream);
  1708. break;
  1709. case INT_BT_SCO_RX:
  1710. case INT_BT_SCO_TX:
  1711. case INT_BT_A2DP_RX:
  1712. case INT_FM_RX:
  1713. case INT_FM_TX:
  1714. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  1715. break;
  1716. case AFE_PORT_ID_USB_RX:
  1717. case AFE_PORT_ID_USB_TX:
  1718. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  1719. substream->stream);
  1720. break;
  1721. case RT_PROXY_DAI_001_TX:
  1722. case RT_PROXY_DAI_001_RX:
  1723. case RT_PROXY_DAI_002_TX:
  1724. case RT_PROXY_DAI_002_RX:
  1725. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  1726. break;
  1727. case VOICE_PLAYBACK_TX:
  1728. case VOICE2_PLAYBACK_TX:
  1729. case VOICE_RECORD_RX:
  1730. case VOICE_RECORD_TX:
  1731. rc = msm_dai_q6_pseudo_port_hw_params(params,
  1732. dai, substream->stream);
  1733. break;
  1734. default:
  1735. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  1736. rc = -EINVAL;
  1737. break;
  1738. }
  1739. return rc;
  1740. }
  1741. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  1742. struct snd_soc_dai *dai)
  1743. {
  1744. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1745. int rc = 0;
  1746. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1747. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  1748. rc = afe_close(dai->id); /* can block */
  1749. if (rc < 0)
  1750. dev_err(dai->dev, "fail to close AFE port\n");
  1751. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1752. *dai_data->status_mask);
  1753. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1754. }
  1755. }
  1756. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  1757. {
  1758. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1759. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  1760. case SND_SOC_DAIFMT_CBS_CFS:
  1761. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  1762. break;
  1763. case SND_SOC_DAIFMT_CBM_CFM:
  1764. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  1765. break;
  1766. default:
  1767. pr_err("%s: fmt 0x%x\n",
  1768. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  1769. return -EINVAL;
  1770. }
  1771. return 0;
  1772. }
  1773. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  1774. {
  1775. int rc = 0;
  1776. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  1777. dai->id, fmt);
  1778. switch (dai->id) {
  1779. case PRIMARY_I2S_TX:
  1780. case PRIMARY_I2S_RX:
  1781. case MI2S_RX:
  1782. case SECONDARY_I2S_RX:
  1783. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  1784. break;
  1785. default:
  1786. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  1787. rc = -EINVAL;
  1788. break;
  1789. }
  1790. return rc;
  1791. }
  1792. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  1793. unsigned int tx_num, unsigned int *tx_slot,
  1794. unsigned int rx_num, unsigned int *rx_slot)
  1795. {
  1796. int rc = 0;
  1797. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1798. unsigned int i = 0;
  1799. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  1800. switch (dai->id) {
  1801. case SLIMBUS_0_RX:
  1802. case SLIMBUS_1_RX:
  1803. case SLIMBUS_2_RX:
  1804. case SLIMBUS_3_RX:
  1805. case SLIMBUS_4_RX:
  1806. case SLIMBUS_5_RX:
  1807. case SLIMBUS_6_RX:
  1808. case SLIMBUS_7_RX:
  1809. case SLIMBUS_8_RX:
  1810. /*
  1811. * channel number to be between 128 and 255.
  1812. * For RX port use channel numbers
  1813. * from 138 to 144 for pre-Taiko
  1814. * from 144 to 159 for Taiko
  1815. */
  1816. if (!rx_slot) {
  1817. pr_err("%s: rx slot not found\n", __func__);
  1818. return -EINVAL;
  1819. }
  1820. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  1821. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  1822. return -EINVAL;
  1823. }
  1824. for (i = 0; i < rx_num; i++) {
  1825. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  1826. rx_slot[i];
  1827. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  1828. __func__, i, rx_slot[i]);
  1829. }
  1830. dai_data->port_config.slim_sch.num_channels = rx_num;
  1831. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  1832. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  1833. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1834. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  1835. break;
  1836. case SLIMBUS_0_TX:
  1837. case SLIMBUS_1_TX:
  1838. case SLIMBUS_2_TX:
  1839. case SLIMBUS_3_TX:
  1840. case SLIMBUS_4_TX:
  1841. case SLIMBUS_5_TX:
  1842. case SLIMBUS_6_TX:
  1843. case SLIMBUS_7_TX:
  1844. case SLIMBUS_8_TX:
  1845. /*
  1846. * channel number to be between 128 and 255.
  1847. * For TX port use channel numbers
  1848. * from 128 to 137 for pre-Taiko
  1849. * from 128 to 143 for Taiko
  1850. */
  1851. if (!tx_slot) {
  1852. pr_err("%s: tx slot not found\n", __func__);
  1853. return -EINVAL;
  1854. }
  1855. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  1856. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  1857. return -EINVAL;
  1858. }
  1859. for (i = 0; i < tx_num; i++) {
  1860. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  1861. tx_slot[i];
  1862. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  1863. __func__, i, tx_slot[i]);
  1864. }
  1865. dai_data->port_config.slim_sch.num_channels = tx_num;
  1866. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  1867. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  1868. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1869. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  1870. break;
  1871. default:
  1872. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  1873. rc = -EINVAL;
  1874. break;
  1875. }
  1876. return rc;
  1877. }
  1878. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  1879. .prepare = msm_dai_q6_prepare,
  1880. .hw_params = msm_dai_q6_hw_params,
  1881. .shutdown = msm_dai_q6_shutdown,
  1882. .set_fmt = msm_dai_q6_set_fmt,
  1883. .set_channel_map = msm_dai_q6_set_channel_map,
  1884. };
  1885. /*
  1886. * For single CPU DAI registration, the dai id needs to be
  1887. * set explicitly in the dai probe as ASoC does not read
  1888. * the cpu->driver->id field rather it assigns the dai id
  1889. * from the device name that is in the form %s.%d. This dai
  1890. * id should be assigned to back-end AFE port id and used
  1891. * during dai prepare. For multiple dai registration, it
  1892. * is not required to call this function, however the dai->
  1893. * driver->id field must be defined and set to corresponding
  1894. * AFE Port id.
  1895. */
  1896. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  1897. {
  1898. if (!dai->driver->id) {
  1899. dev_warn(dai->dev, "DAI driver id is not set\n");
  1900. return;
  1901. }
  1902. dai->id = dai->driver->id;
  1903. }
  1904. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  1905. struct snd_ctl_elem_value *ucontrol)
  1906. {
  1907. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1908. u16 port_id = ((struct soc_enum *)
  1909. kcontrol->private_value)->reg;
  1910. dai_data->cal_mode = ucontrol->value.integer.value[0];
  1911. pr_debug("%s: setting cal_mode to %d\n",
  1912. __func__, dai_data->cal_mode);
  1913. afe_set_cal_mode(port_id, dai_data->cal_mode);
  1914. return 0;
  1915. }
  1916. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  1917. struct snd_ctl_elem_value *ucontrol)
  1918. {
  1919. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1920. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  1921. return 0;
  1922. }
  1923. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  1924. struct snd_ctl_elem_value *ucontrol)
  1925. {
  1926. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1927. int value = ucontrol->value.integer.value[0];
  1928. if (dai_data) {
  1929. dai_data->port_config.slim_sch.data_format = value;
  1930. pr_debug("%s: format = %d\n", __func__, value);
  1931. }
  1932. return 0;
  1933. }
  1934. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  1935. struct snd_ctl_elem_value *ucontrol)
  1936. {
  1937. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1938. if (dai_data)
  1939. ucontrol->value.integer.value[0] =
  1940. dai_data->port_config.slim_sch.data_format;
  1941. return 0;
  1942. }
  1943. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  1944. struct snd_ctl_elem_value *ucontrol)
  1945. {
  1946. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1947. u32 val = ucontrol->value.integer.value[0];
  1948. if (dai_data) {
  1949. dai_data->port_config.usb_audio.dev_token = val;
  1950. pr_debug("%s: dev_token = 0x%x\n", __func__,
  1951. dai_data->port_config.usb_audio.dev_token);
  1952. } else {
  1953. pr_err("%s: dai_data is NULL\n", __func__);
  1954. }
  1955. return 0;
  1956. }
  1957. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  1958. struct snd_ctl_elem_value *ucontrol)
  1959. {
  1960. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1961. if (dai_data) {
  1962. ucontrol->value.integer.value[0] =
  1963. dai_data->port_config.usb_audio.dev_token;
  1964. pr_debug("%s: dev_token = 0x%x\n", __func__,
  1965. dai_data->port_config.usb_audio.dev_token);
  1966. } else {
  1967. pr_err("%s: dai_data is NULL\n", __func__);
  1968. }
  1969. return 0;
  1970. }
  1971. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  1972. struct snd_ctl_elem_value *ucontrol)
  1973. {
  1974. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1975. u32 val = ucontrol->value.integer.value[0];
  1976. if (dai_data) {
  1977. dai_data->port_config.usb_audio.endian = val;
  1978. pr_debug("%s: endian = 0x%x\n", __func__,
  1979. dai_data->port_config.usb_audio.endian);
  1980. } else {
  1981. pr_err("%s: dai_data is NULL\n", __func__);
  1982. return -EINVAL;
  1983. }
  1984. return 0;
  1985. }
  1986. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  1987. struct snd_ctl_elem_value *ucontrol)
  1988. {
  1989. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1990. if (dai_data) {
  1991. ucontrol->value.integer.value[0] =
  1992. dai_data->port_config.usb_audio.endian;
  1993. pr_debug("%s: endian = 0x%x\n", __func__,
  1994. dai_data->port_config.usb_audio.endian);
  1995. } else {
  1996. pr_err("%s: dai_data is NULL\n", __func__);
  1997. return -EINVAL;
  1998. }
  1999. return 0;
  2000. }
  2001. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2002. struct snd_ctl_elem_info *uinfo)
  2003. {
  2004. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2005. uinfo->count = sizeof(struct afe_enc_config);
  2006. return 0;
  2007. }
  2008. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2009. struct snd_ctl_elem_value *ucontrol)
  2010. {
  2011. int ret = 0;
  2012. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2013. if (dai_data) {
  2014. int format_size = sizeof(dai_data->enc_config.format);
  2015. pr_debug("%s:encoder config for %d format\n",
  2016. __func__, dai_data->enc_config.format);
  2017. memcpy(ucontrol->value.bytes.data,
  2018. &dai_data->enc_config.format,
  2019. format_size);
  2020. switch (dai_data->enc_config.format) {
  2021. case ENC_FMT_SBC:
  2022. memcpy(ucontrol->value.bytes.data + format_size,
  2023. &dai_data->enc_config.data,
  2024. sizeof(struct asm_sbc_enc_cfg_t));
  2025. break;
  2026. case ENC_FMT_AAC_V2:
  2027. memcpy(ucontrol->value.bytes.data + format_size,
  2028. &dai_data->enc_config.data,
  2029. sizeof(struct asm_aac_enc_cfg_v2_t));
  2030. break;
  2031. case ENC_FMT_APTX:
  2032. memcpy(ucontrol->value.bytes.data + format_size,
  2033. &dai_data->enc_config.data,
  2034. sizeof(struct asm_aptx_enc_cfg_t));
  2035. break;
  2036. case ENC_FMT_APTX_HD:
  2037. memcpy(ucontrol->value.bytes.data + format_size,
  2038. &dai_data->enc_config.data,
  2039. sizeof(struct asm_custom_enc_cfg_t));
  2040. break;
  2041. case ENC_FMT_CELT:
  2042. memcpy(ucontrol->value.bytes.data + format_size,
  2043. &dai_data->enc_config.data,
  2044. sizeof(struct asm_celt_enc_cfg_t));
  2045. break;
  2046. case ENC_FMT_LDAC:
  2047. memcpy(ucontrol->value.bytes.data + format_size,
  2048. &dai_data->enc_config.data,
  2049. sizeof(struct asm_ldac_enc_cfg_t));
  2050. break;
  2051. default:
  2052. pr_debug("%s: unknown format = %d\n",
  2053. __func__, dai_data->enc_config.format);
  2054. ret = -EINVAL;
  2055. break;
  2056. }
  2057. }
  2058. return ret;
  2059. }
  2060. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2061. struct snd_ctl_elem_value *ucontrol)
  2062. {
  2063. int ret = 0;
  2064. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2065. if (dai_data) {
  2066. int format_size = sizeof(dai_data->enc_config.format);
  2067. memset(&dai_data->enc_config, 0x0,
  2068. sizeof(struct afe_enc_config));
  2069. memcpy(&dai_data->enc_config.format,
  2070. ucontrol->value.bytes.data,
  2071. format_size);
  2072. pr_debug("%s: Received encoder config for %d format\n",
  2073. __func__, dai_data->enc_config.format);
  2074. switch (dai_data->enc_config.format) {
  2075. case ENC_FMT_SBC:
  2076. memcpy(&dai_data->enc_config.data,
  2077. ucontrol->value.bytes.data + format_size,
  2078. sizeof(struct asm_sbc_enc_cfg_t));
  2079. break;
  2080. case ENC_FMT_AAC_V2:
  2081. memcpy(&dai_data->enc_config.data,
  2082. ucontrol->value.bytes.data + format_size,
  2083. sizeof(struct asm_aac_enc_cfg_v2_t));
  2084. break;
  2085. case ENC_FMT_APTX:
  2086. memcpy(&dai_data->enc_config.data,
  2087. ucontrol->value.bytes.data + format_size,
  2088. sizeof(struct asm_aptx_enc_cfg_t));
  2089. break;
  2090. case ENC_FMT_APTX_HD:
  2091. memcpy(&dai_data->enc_config.data,
  2092. ucontrol->value.bytes.data + format_size,
  2093. sizeof(struct asm_custom_enc_cfg_t));
  2094. break;
  2095. case ENC_FMT_CELT:
  2096. memcpy(&dai_data->enc_config.data,
  2097. ucontrol->value.bytes.data + format_size,
  2098. sizeof(struct asm_celt_enc_cfg_t));
  2099. break;
  2100. case ENC_FMT_LDAC:
  2101. memcpy(&dai_data->enc_config.data,
  2102. ucontrol->value.bytes.data + format_size,
  2103. sizeof(struct asm_ldac_enc_cfg_t));
  2104. break;
  2105. default:
  2106. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2107. __func__, dai_data->enc_config.format);
  2108. ret = -EINVAL;
  2109. break;
  2110. }
  2111. } else
  2112. ret = -EINVAL;
  2113. return ret;
  2114. }
  2115. static const char *const afe_input_chs_text[] = {"Zero", "One", "Two"};
  2116. static const struct soc_enum afe_input_chs_enum[] = {
  2117. SOC_ENUM_SINGLE_EXT(3, afe_input_chs_text),
  2118. };
  2119. static const char *const afe_input_bit_format_text[] = {"S16_LE", "S24_LE"};
  2120. static const struct soc_enum afe_input_bit_format_enum[] = {
  2121. SOC_ENUM_SINGLE_EXT(2, afe_input_bit_format_text),
  2122. };
  2123. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2124. struct snd_ctl_elem_value *ucontrol)
  2125. {
  2126. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2127. if (dai_data) {
  2128. ucontrol->value.integer.value[0] = dai_data->afe_in_channels;
  2129. pr_debug("%s:afe input channel = %d\n",
  2130. __func__, dai_data->afe_in_channels);
  2131. }
  2132. return 0;
  2133. }
  2134. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2135. struct snd_ctl_elem_value *ucontrol)
  2136. {
  2137. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2138. if (dai_data) {
  2139. dai_data->afe_in_channels = ucontrol->value.integer.value[0];
  2140. pr_debug("%s: updating afe input channel : %d\n",
  2141. __func__, dai_data->afe_in_channels);
  2142. }
  2143. return 0;
  2144. }
  2145. static int msm_dai_q6_afe_input_bit_format_get(
  2146. struct snd_kcontrol *kcontrol,
  2147. struct snd_ctl_elem_value *ucontrol)
  2148. {
  2149. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2150. if (!dai_data) {
  2151. pr_err("%s: Invalid dai data\n", __func__);
  2152. return -EINVAL;
  2153. }
  2154. switch (dai_data->afe_in_bitformat) {
  2155. case SNDRV_PCM_FORMAT_S24_LE:
  2156. ucontrol->value.integer.value[0] = 1;
  2157. break;
  2158. case SNDRV_PCM_FORMAT_S16_LE:
  2159. default:
  2160. ucontrol->value.integer.value[0] = 0;
  2161. break;
  2162. }
  2163. pr_debug("%s: afe input bit format : %ld\n",
  2164. __func__, ucontrol->value.integer.value[0]);
  2165. return 0;
  2166. }
  2167. static int msm_dai_q6_afe_input_bit_format_put(
  2168. struct snd_kcontrol *kcontrol,
  2169. struct snd_ctl_elem_value *ucontrol)
  2170. {
  2171. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2172. if (!dai_data) {
  2173. pr_err("%s: Invalid dai data\n", __func__);
  2174. return -EINVAL;
  2175. }
  2176. switch (ucontrol->value.integer.value[0]) {
  2177. case 1:
  2178. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2179. break;
  2180. case 0:
  2181. default:
  2182. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2183. break;
  2184. }
  2185. pr_debug("%s: updating afe input bit format : %d\n",
  2186. __func__, dai_data->afe_in_bitformat);
  2187. return 0;
  2188. }
  2189. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  2190. {
  2191. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2192. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2193. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2194. .name = "SLIM_7_RX Encoder Config",
  2195. .info = msm_dai_q6_afe_enc_cfg_info,
  2196. .get = msm_dai_q6_afe_enc_cfg_get,
  2197. .put = msm_dai_q6_afe_enc_cfg_put,
  2198. },
  2199. SOC_ENUM_EXT("AFE Input Channels", afe_input_chs_enum[0],
  2200. msm_dai_q6_afe_input_channel_get,
  2201. msm_dai_q6_afe_input_channel_put),
  2202. SOC_ENUM_EXT("AFE Input Bit Format", afe_input_bit_format_enum[0],
  2203. msm_dai_q6_afe_input_bit_format_get,
  2204. msm_dai_q6_afe_input_bit_format_put),
  2205. };
  2206. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  2207. struct snd_ctl_elem_info *uinfo)
  2208. {
  2209. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2210. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  2211. return 0;
  2212. }
  2213. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  2214. struct snd_ctl_elem_value *ucontrol)
  2215. {
  2216. int ret = -EINVAL;
  2217. struct afe_param_id_dev_timing_stats timing_stats;
  2218. struct snd_soc_dai *dai = kcontrol->private_data;
  2219. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2220. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2221. pr_err("%s: afe port not started. dai_data->status_mask = %ld\n",
  2222. __func__, *dai_data->status_mask);
  2223. goto done;
  2224. }
  2225. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  2226. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  2227. if (ret) {
  2228. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  2229. __func__, dai->id, ret);
  2230. goto done;
  2231. }
  2232. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  2233. sizeof(struct afe_param_id_dev_timing_stats));
  2234. done:
  2235. return ret;
  2236. }
  2237. static const char * const afe_cal_mode_text[] = {
  2238. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  2239. };
  2240. static const struct soc_enum slim_2_rx_enum =
  2241. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2242. afe_cal_mode_text);
  2243. static const struct soc_enum rt_proxy_1_rx_enum =
  2244. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2245. afe_cal_mode_text);
  2246. static const struct soc_enum rt_proxy_1_tx_enum =
  2247. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2248. afe_cal_mode_text);
  2249. static const struct snd_kcontrol_new sb_config_controls[] = {
  2250. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  2251. msm_dai_q6_sb_format_get,
  2252. msm_dai_q6_sb_format_put),
  2253. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  2254. msm_dai_q6_cal_info_get,
  2255. msm_dai_q6_cal_info_put),
  2256. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  2257. msm_dai_q6_sb_format_get,
  2258. msm_dai_q6_sb_format_put)
  2259. };
  2260. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  2261. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  2262. msm_dai_q6_cal_info_get,
  2263. msm_dai_q6_cal_info_put),
  2264. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  2265. msm_dai_q6_cal_info_get,
  2266. msm_dai_q6_cal_info_put),
  2267. };
  2268. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  2269. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  2270. msm_dai_q6_usb_audio_cfg_get,
  2271. msm_dai_q6_usb_audio_cfg_put),
  2272. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  2273. msm_dai_q6_usb_audio_endian_cfg_get,
  2274. msm_dai_q6_usb_audio_endian_cfg_put),
  2275. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  2276. msm_dai_q6_usb_audio_cfg_get,
  2277. msm_dai_q6_usb_audio_cfg_put),
  2278. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  2279. msm_dai_q6_usb_audio_endian_cfg_get,
  2280. msm_dai_q6_usb_audio_endian_cfg_put),
  2281. };
  2282. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  2283. {
  2284. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2285. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2286. .name = "SLIMBUS_0_RX DRIFT",
  2287. .info = msm_dai_q6_slim_rx_drift_info,
  2288. .get = msm_dai_q6_slim_rx_drift_get,
  2289. },
  2290. {
  2291. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2292. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2293. .name = "SLIMBUS_6_RX DRIFT",
  2294. .info = msm_dai_q6_slim_rx_drift_info,
  2295. .get = msm_dai_q6_slim_rx_drift_get,
  2296. },
  2297. {
  2298. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2299. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2300. .name = "SLIMBUS_7_RX DRIFT",
  2301. .info = msm_dai_q6_slim_rx_drift_info,
  2302. .get = msm_dai_q6_slim_rx_drift_get,
  2303. },
  2304. };
  2305. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  2306. {
  2307. struct msm_dai_q6_dai_data *dai_data;
  2308. int rc = 0;
  2309. if (!dai) {
  2310. pr_err("%s: Invalid params dai\n", __func__);
  2311. return -EINVAL;
  2312. }
  2313. if (!dai->dev) {
  2314. pr_err("%s: Invalid params dai dev\n", __func__);
  2315. return -EINVAL;
  2316. }
  2317. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  2318. if (!dai_data)
  2319. rc = -ENOMEM;
  2320. else
  2321. dev_set_drvdata(dai->dev, dai_data);
  2322. msm_dai_q6_set_dai_id(dai);
  2323. switch (dai->id) {
  2324. case SLIMBUS_4_TX:
  2325. rc = snd_ctl_add(dai->component->card->snd_card,
  2326. snd_ctl_new1(&sb_config_controls[0],
  2327. dai_data));
  2328. break;
  2329. case SLIMBUS_2_RX:
  2330. rc = snd_ctl_add(dai->component->card->snd_card,
  2331. snd_ctl_new1(&sb_config_controls[1],
  2332. dai_data));
  2333. rc = snd_ctl_add(dai->component->card->snd_card,
  2334. snd_ctl_new1(&sb_config_controls[2],
  2335. dai_data));
  2336. break;
  2337. case SLIMBUS_7_RX:
  2338. rc = snd_ctl_add(dai->component->card->snd_card,
  2339. snd_ctl_new1(&afe_enc_config_controls[0],
  2340. dai_data));
  2341. rc = snd_ctl_add(dai->component->card->snd_card,
  2342. snd_ctl_new1(&afe_enc_config_controls[1],
  2343. dai_data));
  2344. rc = snd_ctl_add(dai->component->card->snd_card,
  2345. snd_ctl_new1(&afe_enc_config_controls[2],
  2346. dai_data));
  2347. rc = snd_ctl_add(dai->component->card->snd_card,
  2348. snd_ctl_new1(&avd_drift_config_controls[2],
  2349. dai));
  2350. break;
  2351. case RT_PROXY_DAI_001_RX:
  2352. rc = snd_ctl_add(dai->component->card->snd_card,
  2353. snd_ctl_new1(&rt_proxy_config_controls[0],
  2354. dai_data));
  2355. break;
  2356. case RT_PROXY_DAI_001_TX:
  2357. rc = snd_ctl_add(dai->component->card->snd_card,
  2358. snd_ctl_new1(&rt_proxy_config_controls[1],
  2359. dai_data));
  2360. break;
  2361. case AFE_PORT_ID_USB_RX:
  2362. rc = snd_ctl_add(dai->component->card->snd_card,
  2363. snd_ctl_new1(&usb_audio_cfg_controls[0],
  2364. dai_data));
  2365. rc = snd_ctl_add(dai->component->card->snd_card,
  2366. snd_ctl_new1(&usb_audio_cfg_controls[1],
  2367. dai_data));
  2368. break;
  2369. case AFE_PORT_ID_USB_TX:
  2370. rc = snd_ctl_add(dai->component->card->snd_card,
  2371. snd_ctl_new1(&usb_audio_cfg_controls[2],
  2372. dai_data));
  2373. rc = snd_ctl_add(dai->component->card->snd_card,
  2374. snd_ctl_new1(&usb_audio_cfg_controls[3],
  2375. dai_data));
  2376. break;
  2377. case SLIMBUS_0_RX:
  2378. rc = snd_ctl_add(dai->component->card->snd_card,
  2379. snd_ctl_new1(&avd_drift_config_controls[0],
  2380. dai));
  2381. break;
  2382. case SLIMBUS_6_RX:
  2383. rc = snd_ctl_add(dai->component->card->snd_card,
  2384. snd_ctl_new1(&avd_drift_config_controls[1],
  2385. dai));
  2386. break;
  2387. }
  2388. if (rc < 0)
  2389. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  2390. __func__, dai->name);
  2391. rc = msm_dai_q6_dai_add_route(dai);
  2392. return rc;
  2393. }
  2394. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  2395. {
  2396. struct msm_dai_q6_dai_data *dai_data;
  2397. int rc;
  2398. dai_data = dev_get_drvdata(dai->dev);
  2399. /* If AFE port is still up, close it */
  2400. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2401. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2402. rc = afe_close(dai->id); /* can block */
  2403. if (rc < 0)
  2404. dev_err(dai->dev, "fail to close AFE port\n");
  2405. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2406. }
  2407. kfree(dai_data);
  2408. return 0;
  2409. }
  2410. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  2411. {
  2412. .playback = {
  2413. .stream_name = "AFE Playback",
  2414. .aif_name = "PCM_RX",
  2415. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2416. SNDRV_PCM_RATE_16000,
  2417. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2418. SNDRV_PCM_FMTBIT_S24_LE,
  2419. .channels_min = 1,
  2420. .channels_max = 2,
  2421. .rate_min = 8000,
  2422. .rate_max = 48000,
  2423. },
  2424. .ops = &msm_dai_q6_ops,
  2425. .id = RT_PROXY_DAI_001_RX,
  2426. .probe = msm_dai_q6_dai_probe,
  2427. .remove = msm_dai_q6_dai_remove,
  2428. },
  2429. {
  2430. .playback = {
  2431. .stream_name = "AFE-PROXY RX",
  2432. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2433. SNDRV_PCM_RATE_16000,
  2434. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2435. SNDRV_PCM_FMTBIT_S24_LE,
  2436. .channels_min = 1,
  2437. .channels_max = 2,
  2438. .rate_min = 8000,
  2439. .rate_max = 48000,
  2440. },
  2441. .ops = &msm_dai_q6_ops,
  2442. .id = RT_PROXY_DAI_002_RX,
  2443. .probe = msm_dai_q6_dai_probe,
  2444. .remove = msm_dai_q6_dai_remove,
  2445. },
  2446. };
  2447. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  2448. {
  2449. .capture = {
  2450. .stream_name = "AFE Capture",
  2451. .aif_name = "PCM_TX",
  2452. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2453. SNDRV_PCM_RATE_16000,
  2454. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2455. .channels_min = 1,
  2456. .channels_max = 8,
  2457. .rate_min = 8000,
  2458. .rate_max = 48000,
  2459. },
  2460. .ops = &msm_dai_q6_ops,
  2461. .id = RT_PROXY_DAI_002_TX,
  2462. .probe = msm_dai_q6_dai_probe,
  2463. .remove = msm_dai_q6_dai_remove,
  2464. },
  2465. {
  2466. .capture = {
  2467. .stream_name = "AFE-PROXY TX",
  2468. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2469. SNDRV_PCM_RATE_16000,
  2470. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2471. .channels_min = 1,
  2472. .channels_max = 8,
  2473. .rate_min = 8000,
  2474. .rate_max = 48000,
  2475. },
  2476. .ops = &msm_dai_q6_ops,
  2477. .id = RT_PROXY_DAI_001_TX,
  2478. .probe = msm_dai_q6_dai_probe,
  2479. .remove = msm_dai_q6_dai_remove,
  2480. },
  2481. };
  2482. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  2483. .playback = {
  2484. .stream_name = "Internal BT-SCO Playback",
  2485. .aif_name = "INT_BT_SCO_RX",
  2486. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  2487. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2488. .channels_min = 1,
  2489. .channels_max = 1,
  2490. .rate_max = 16000,
  2491. .rate_min = 8000,
  2492. },
  2493. .ops = &msm_dai_q6_ops,
  2494. .id = INT_BT_SCO_RX,
  2495. .probe = msm_dai_q6_dai_probe,
  2496. .remove = msm_dai_q6_dai_remove,
  2497. };
  2498. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  2499. .playback = {
  2500. .stream_name = "Internal BT-A2DP Playback",
  2501. .aif_name = "INT_BT_A2DP_RX",
  2502. .rates = SNDRV_PCM_RATE_48000,
  2503. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2504. .channels_min = 1,
  2505. .channels_max = 2,
  2506. .rate_max = 48000,
  2507. .rate_min = 48000,
  2508. },
  2509. .ops = &msm_dai_q6_ops,
  2510. .id = INT_BT_A2DP_RX,
  2511. .probe = msm_dai_q6_dai_probe,
  2512. .remove = msm_dai_q6_dai_remove,
  2513. };
  2514. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  2515. .capture = {
  2516. .stream_name = "Internal BT-SCO Capture",
  2517. .aif_name = "INT_BT_SCO_TX",
  2518. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  2519. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2520. .channels_min = 1,
  2521. .channels_max = 1,
  2522. .rate_max = 16000,
  2523. .rate_min = 8000,
  2524. },
  2525. .ops = &msm_dai_q6_ops,
  2526. .id = INT_BT_SCO_TX,
  2527. .probe = msm_dai_q6_dai_probe,
  2528. .remove = msm_dai_q6_dai_remove,
  2529. };
  2530. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  2531. .playback = {
  2532. .stream_name = "Internal FM Playback",
  2533. .aif_name = "INT_FM_RX",
  2534. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2535. SNDRV_PCM_RATE_16000,
  2536. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2537. .channels_min = 2,
  2538. .channels_max = 2,
  2539. .rate_max = 48000,
  2540. .rate_min = 8000,
  2541. },
  2542. .ops = &msm_dai_q6_ops,
  2543. .id = INT_FM_RX,
  2544. .probe = msm_dai_q6_dai_probe,
  2545. .remove = msm_dai_q6_dai_remove,
  2546. };
  2547. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  2548. .capture = {
  2549. .stream_name = "Internal FM Capture",
  2550. .aif_name = "INT_FM_TX",
  2551. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2552. SNDRV_PCM_RATE_16000,
  2553. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2554. .channels_min = 2,
  2555. .channels_max = 2,
  2556. .rate_max = 48000,
  2557. .rate_min = 8000,
  2558. },
  2559. .ops = &msm_dai_q6_ops,
  2560. .id = INT_FM_TX,
  2561. .probe = msm_dai_q6_dai_probe,
  2562. .remove = msm_dai_q6_dai_remove,
  2563. };
  2564. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  2565. {
  2566. .playback = {
  2567. .stream_name = "Voice Farend Playback",
  2568. .aif_name = "VOICE_PLAYBACK_TX",
  2569. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2570. SNDRV_PCM_RATE_16000,
  2571. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2572. .channels_min = 1,
  2573. .channels_max = 2,
  2574. .rate_min = 8000,
  2575. .rate_max = 48000,
  2576. },
  2577. .ops = &msm_dai_q6_ops,
  2578. .id = VOICE_PLAYBACK_TX,
  2579. .probe = msm_dai_q6_dai_probe,
  2580. .remove = msm_dai_q6_dai_remove,
  2581. },
  2582. {
  2583. .playback = {
  2584. .stream_name = "Voice2 Farend Playback",
  2585. .aif_name = "VOICE2_PLAYBACK_TX",
  2586. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2587. SNDRV_PCM_RATE_16000,
  2588. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2589. .channels_min = 1,
  2590. .channels_max = 2,
  2591. .rate_min = 8000,
  2592. .rate_max = 48000,
  2593. },
  2594. .ops = &msm_dai_q6_ops,
  2595. .id = VOICE2_PLAYBACK_TX,
  2596. .probe = msm_dai_q6_dai_probe,
  2597. .remove = msm_dai_q6_dai_remove,
  2598. },
  2599. };
  2600. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  2601. {
  2602. .capture = {
  2603. .stream_name = "Voice Uplink Capture",
  2604. .aif_name = "INCALL_RECORD_TX",
  2605. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2606. SNDRV_PCM_RATE_16000,
  2607. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2608. .channels_min = 1,
  2609. .channels_max = 2,
  2610. .rate_min = 8000,
  2611. .rate_max = 48000,
  2612. },
  2613. .ops = &msm_dai_q6_ops,
  2614. .id = VOICE_RECORD_TX,
  2615. .probe = msm_dai_q6_dai_probe,
  2616. .remove = msm_dai_q6_dai_remove,
  2617. },
  2618. {
  2619. .capture = {
  2620. .stream_name = "Voice Downlink Capture",
  2621. .aif_name = "INCALL_RECORD_RX",
  2622. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2623. SNDRV_PCM_RATE_16000,
  2624. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2625. .channels_min = 1,
  2626. .channels_max = 2,
  2627. .rate_min = 8000,
  2628. .rate_max = 48000,
  2629. },
  2630. .ops = &msm_dai_q6_ops,
  2631. .id = VOICE_RECORD_RX,
  2632. .probe = msm_dai_q6_dai_probe,
  2633. .remove = msm_dai_q6_dai_remove,
  2634. },
  2635. };
  2636. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  2637. .playback = {
  2638. .stream_name = "USB Audio Playback",
  2639. .aif_name = "USB_AUDIO_RX",
  2640. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2641. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2642. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2643. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  2644. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  2645. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  2646. SNDRV_PCM_RATE_384000,
  2647. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  2648. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  2649. .channels_min = 1,
  2650. .channels_max = 8,
  2651. .rate_max = 384000,
  2652. .rate_min = 8000,
  2653. },
  2654. .ops = &msm_dai_q6_ops,
  2655. .id = AFE_PORT_ID_USB_RX,
  2656. .probe = msm_dai_q6_dai_probe,
  2657. .remove = msm_dai_q6_dai_remove,
  2658. };
  2659. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  2660. .capture = {
  2661. .stream_name = "USB Audio Capture",
  2662. .aif_name = "USB_AUDIO_TX",
  2663. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2664. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2665. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2666. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  2667. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  2668. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  2669. SNDRV_PCM_RATE_384000,
  2670. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  2671. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  2672. .channels_min = 1,
  2673. .channels_max = 8,
  2674. .rate_max = 384000,
  2675. .rate_min = 8000,
  2676. },
  2677. .ops = &msm_dai_q6_ops,
  2678. .id = AFE_PORT_ID_USB_TX,
  2679. .probe = msm_dai_q6_dai_probe,
  2680. .remove = msm_dai_q6_dai_remove,
  2681. };
  2682. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  2683. {
  2684. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  2685. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  2686. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  2687. uint32_t val = 0;
  2688. const char *intf_name;
  2689. int rc = 0, i = 0, len = 0;
  2690. const uint32_t *slot_mapping_array = NULL;
  2691. u32 array_length = 0;
  2692. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  2693. GFP_KERNEL);
  2694. if (!dai_data)
  2695. return -ENOMEM;
  2696. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  2697. GFP_KERNEL);
  2698. if (!auxpcm_pdata) {
  2699. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  2700. goto fail_pdata_nomem;
  2701. }
  2702. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  2703. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  2704. rc = of_property_read_u32_array(pdev->dev.of_node,
  2705. "qcom,msm-cpudai-auxpcm-mode",
  2706. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2707. if (rc) {
  2708. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  2709. __func__);
  2710. goto fail_invalid_dt;
  2711. }
  2712. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  2713. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  2714. rc = of_property_read_u32_array(pdev->dev.of_node,
  2715. "qcom,msm-cpudai-auxpcm-sync",
  2716. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2717. if (rc) {
  2718. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  2719. __func__);
  2720. goto fail_invalid_dt;
  2721. }
  2722. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  2723. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  2724. rc = of_property_read_u32_array(pdev->dev.of_node,
  2725. "qcom,msm-cpudai-auxpcm-frame",
  2726. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2727. if (rc) {
  2728. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  2729. __func__);
  2730. goto fail_invalid_dt;
  2731. }
  2732. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  2733. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  2734. rc = of_property_read_u32_array(pdev->dev.of_node,
  2735. "qcom,msm-cpudai-auxpcm-quant",
  2736. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2737. if (rc) {
  2738. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  2739. __func__);
  2740. goto fail_invalid_dt;
  2741. }
  2742. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  2743. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  2744. rc = of_property_read_u32_array(pdev->dev.of_node,
  2745. "qcom,msm-cpudai-auxpcm-num-slots",
  2746. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2747. if (rc) {
  2748. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  2749. __func__);
  2750. goto fail_invalid_dt;
  2751. }
  2752. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  2753. if (auxpcm_pdata->mode_8k.num_slots >
  2754. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  2755. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  2756. __func__,
  2757. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  2758. auxpcm_pdata->mode_8k.num_slots);
  2759. rc = -EINVAL;
  2760. goto fail_invalid_dt;
  2761. }
  2762. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  2763. if (auxpcm_pdata->mode_16k.num_slots >
  2764. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  2765. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  2766. __func__,
  2767. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  2768. auxpcm_pdata->mode_16k.num_slots);
  2769. rc = -EINVAL;
  2770. goto fail_invalid_dt;
  2771. }
  2772. slot_mapping_array = of_get_property(pdev->dev.of_node,
  2773. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  2774. if (slot_mapping_array == NULL) {
  2775. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  2776. __func__);
  2777. rc = -EINVAL;
  2778. goto fail_invalid_dt;
  2779. }
  2780. array_length = auxpcm_pdata->mode_8k.num_slots +
  2781. auxpcm_pdata->mode_16k.num_slots;
  2782. if (len != sizeof(uint32_t) * array_length) {
  2783. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  2784. __func__, len, sizeof(uint32_t) * array_length);
  2785. rc = -EINVAL;
  2786. goto fail_invalid_dt;
  2787. }
  2788. auxpcm_pdata->mode_8k.slot_mapping =
  2789. kzalloc(sizeof(uint16_t) *
  2790. auxpcm_pdata->mode_8k.num_slots,
  2791. GFP_KERNEL);
  2792. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  2793. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  2794. __func__);
  2795. rc = -ENOMEM;
  2796. goto fail_invalid_dt;
  2797. }
  2798. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  2799. auxpcm_pdata->mode_8k.slot_mapping[i] =
  2800. (u16)be32_to_cpu(slot_mapping_array[i]);
  2801. auxpcm_pdata->mode_16k.slot_mapping =
  2802. kzalloc(sizeof(uint16_t) *
  2803. auxpcm_pdata->mode_16k.num_slots,
  2804. GFP_KERNEL);
  2805. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  2806. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  2807. __func__);
  2808. rc = -ENOMEM;
  2809. goto fail_invalid_16k_slot_mapping;
  2810. }
  2811. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  2812. auxpcm_pdata->mode_16k.slot_mapping[i] =
  2813. (u16)be32_to_cpu(slot_mapping_array[i +
  2814. auxpcm_pdata->mode_8k.num_slots]);
  2815. rc = of_property_read_u32_array(pdev->dev.of_node,
  2816. "qcom,msm-cpudai-auxpcm-data",
  2817. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2818. if (rc) {
  2819. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  2820. __func__);
  2821. goto fail_invalid_dt1;
  2822. }
  2823. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  2824. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  2825. rc = of_property_read_u32_array(pdev->dev.of_node,
  2826. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  2827. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2828. if (rc) {
  2829. dev_err(&pdev->dev,
  2830. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  2831. __func__);
  2832. goto fail_invalid_dt1;
  2833. }
  2834. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  2835. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  2836. rc = of_property_read_string(pdev->dev.of_node,
  2837. "qcom,msm-auxpcm-interface", &intf_name);
  2838. if (rc) {
  2839. dev_err(&pdev->dev,
  2840. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  2841. __func__);
  2842. goto fail_nodev_intf;
  2843. }
  2844. if (!strcmp(intf_name, "primary")) {
  2845. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  2846. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  2847. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  2848. i = 0;
  2849. } else if (!strcmp(intf_name, "secondary")) {
  2850. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  2851. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  2852. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  2853. i = 1;
  2854. } else if (!strcmp(intf_name, "tertiary")) {
  2855. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  2856. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  2857. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  2858. i = 2;
  2859. } else if (!strcmp(intf_name, "quaternary")) {
  2860. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  2861. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  2862. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  2863. i = 3;
  2864. } else if (!strcmp(intf_name, "quinary")) {
  2865. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  2866. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  2867. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  2868. i = 4;
  2869. } else {
  2870. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  2871. __func__, intf_name);
  2872. goto fail_invalid_intf;
  2873. }
  2874. rc = of_property_read_u32(pdev->dev.of_node,
  2875. "qcom,msm-cpudai-afe-clk-ver", &val);
  2876. if (rc)
  2877. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  2878. else
  2879. dai_data->afe_clk_ver = val;
  2880. mutex_init(&dai_data->rlock);
  2881. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  2882. dev_set_drvdata(&pdev->dev, dai_data);
  2883. pdev->dev.platform_data = (void *) auxpcm_pdata;
  2884. rc = snd_soc_register_component(&pdev->dev,
  2885. &msm_dai_q6_aux_pcm_dai_component,
  2886. &msm_dai_q6_aux_pcm_dai[i], 1);
  2887. if (rc) {
  2888. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  2889. __func__, rc);
  2890. goto fail_reg_dai;
  2891. }
  2892. return rc;
  2893. fail_reg_dai:
  2894. fail_invalid_intf:
  2895. fail_nodev_intf:
  2896. fail_invalid_dt1:
  2897. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  2898. fail_invalid_16k_slot_mapping:
  2899. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  2900. fail_invalid_dt:
  2901. kfree(auxpcm_pdata);
  2902. fail_pdata_nomem:
  2903. kfree(dai_data);
  2904. return rc;
  2905. }
  2906. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  2907. {
  2908. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  2909. dai_data = dev_get_drvdata(&pdev->dev);
  2910. snd_soc_unregister_component(&pdev->dev);
  2911. mutex_destroy(&dai_data->rlock);
  2912. kfree(dai_data);
  2913. kfree(pdev->dev.platform_data);
  2914. return 0;
  2915. }
  2916. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  2917. { .compatible = "qcom,msm-auxpcm-dev", },
  2918. {}
  2919. };
  2920. static struct platform_driver msm_auxpcm_dev_driver = {
  2921. .probe = msm_auxpcm_dev_probe,
  2922. .remove = msm_auxpcm_dev_remove,
  2923. .driver = {
  2924. .name = "msm-auxpcm-dev",
  2925. .owner = THIS_MODULE,
  2926. .of_match_table = msm_auxpcm_dev_dt_match,
  2927. },
  2928. };
  2929. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  2930. {
  2931. .playback = {
  2932. .stream_name = "Slimbus Playback",
  2933. .aif_name = "SLIMBUS_0_RX",
  2934. .rates = SNDRV_PCM_RATE_8000_384000,
  2935. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2936. .channels_min = 1,
  2937. .channels_max = 8,
  2938. .rate_min = 8000,
  2939. .rate_max = 384000,
  2940. },
  2941. .ops = &msm_dai_q6_ops,
  2942. .id = SLIMBUS_0_RX,
  2943. .probe = msm_dai_q6_dai_probe,
  2944. .remove = msm_dai_q6_dai_remove,
  2945. },
  2946. {
  2947. .playback = {
  2948. .stream_name = "Slimbus1 Playback",
  2949. .aif_name = "SLIMBUS_1_RX",
  2950. .rates = SNDRV_PCM_RATE_8000_384000,
  2951. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2952. .channels_min = 1,
  2953. .channels_max = 2,
  2954. .rate_min = 8000,
  2955. .rate_max = 384000,
  2956. },
  2957. .ops = &msm_dai_q6_ops,
  2958. .id = SLIMBUS_1_RX,
  2959. .probe = msm_dai_q6_dai_probe,
  2960. .remove = msm_dai_q6_dai_remove,
  2961. },
  2962. {
  2963. .playback = {
  2964. .stream_name = "Slimbus2 Playback",
  2965. .aif_name = "SLIMBUS_2_RX",
  2966. .rates = SNDRV_PCM_RATE_8000_384000,
  2967. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2968. .channels_min = 1,
  2969. .channels_max = 8,
  2970. .rate_min = 8000,
  2971. .rate_max = 384000,
  2972. },
  2973. .ops = &msm_dai_q6_ops,
  2974. .id = SLIMBUS_2_RX,
  2975. .probe = msm_dai_q6_dai_probe,
  2976. .remove = msm_dai_q6_dai_remove,
  2977. },
  2978. {
  2979. .playback = {
  2980. .stream_name = "Slimbus3 Playback",
  2981. .aif_name = "SLIMBUS_3_RX",
  2982. .rates = SNDRV_PCM_RATE_8000_384000,
  2983. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2984. .channels_min = 1,
  2985. .channels_max = 2,
  2986. .rate_min = 8000,
  2987. .rate_max = 384000,
  2988. },
  2989. .ops = &msm_dai_q6_ops,
  2990. .id = SLIMBUS_3_RX,
  2991. .probe = msm_dai_q6_dai_probe,
  2992. .remove = msm_dai_q6_dai_remove,
  2993. },
  2994. {
  2995. .playback = {
  2996. .stream_name = "Slimbus4 Playback",
  2997. .aif_name = "SLIMBUS_4_RX",
  2998. .rates = SNDRV_PCM_RATE_8000_384000,
  2999. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3000. .channels_min = 1,
  3001. .channels_max = 2,
  3002. .rate_min = 8000,
  3003. .rate_max = 384000,
  3004. },
  3005. .ops = &msm_dai_q6_ops,
  3006. .id = SLIMBUS_4_RX,
  3007. .probe = msm_dai_q6_dai_probe,
  3008. .remove = msm_dai_q6_dai_remove,
  3009. },
  3010. {
  3011. .playback = {
  3012. .stream_name = "Slimbus6 Playback",
  3013. .aif_name = "SLIMBUS_6_RX",
  3014. .rates = SNDRV_PCM_RATE_8000_384000,
  3015. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3016. .channels_min = 1,
  3017. .channels_max = 2,
  3018. .rate_min = 8000,
  3019. .rate_max = 384000,
  3020. },
  3021. .ops = &msm_dai_q6_ops,
  3022. .id = SLIMBUS_6_RX,
  3023. .probe = msm_dai_q6_dai_probe,
  3024. .remove = msm_dai_q6_dai_remove,
  3025. },
  3026. {
  3027. .playback = {
  3028. .stream_name = "Slimbus5 Playback",
  3029. .aif_name = "SLIMBUS_5_RX",
  3030. .rates = SNDRV_PCM_RATE_8000_384000,
  3031. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3032. .channels_min = 1,
  3033. .channels_max = 2,
  3034. .rate_min = 8000,
  3035. .rate_max = 384000,
  3036. },
  3037. .ops = &msm_dai_q6_ops,
  3038. .id = SLIMBUS_5_RX,
  3039. .probe = msm_dai_q6_dai_probe,
  3040. .remove = msm_dai_q6_dai_remove,
  3041. },
  3042. {
  3043. .playback = {
  3044. .stream_name = "Slimbus7 Playback",
  3045. .aif_name = "SLIMBUS_7_RX",
  3046. .rates = SNDRV_PCM_RATE_8000_384000,
  3047. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3048. .channels_min = 1,
  3049. .channels_max = 8,
  3050. .rate_min = 8000,
  3051. .rate_max = 384000,
  3052. },
  3053. .ops = &msm_dai_q6_ops,
  3054. .id = SLIMBUS_7_RX,
  3055. .probe = msm_dai_q6_dai_probe,
  3056. .remove = msm_dai_q6_dai_remove,
  3057. },
  3058. {
  3059. .playback = {
  3060. .stream_name = "Slimbus8 Playback",
  3061. .aif_name = "SLIMBUS_8_RX",
  3062. .rates = SNDRV_PCM_RATE_8000_384000,
  3063. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3064. .channels_min = 1,
  3065. .channels_max = 8,
  3066. .rate_min = 8000,
  3067. .rate_max = 384000,
  3068. },
  3069. .ops = &msm_dai_q6_ops,
  3070. .id = SLIMBUS_8_RX,
  3071. .probe = msm_dai_q6_dai_probe,
  3072. .remove = msm_dai_q6_dai_remove,
  3073. },
  3074. };
  3075. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  3076. {
  3077. .capture = {
  3078. .stream_name = "Slimbus Capture",
  3079. .aif_name = "SLIMBUS_0_TX",
  3080. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3081. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3082. SNDRV_PCM_RATE_192000,
  3083. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3084. SNDRV_PCM_FMTBIT_S24_LE |
  3085. SNDRV_PCM_FMTBIT_S24_3LE,
  3086. .channels_min = 1,
  3087. .channels_max = 8,
  3088. .rate_min = 8000,
  3089. .rate_max = 192000,
  3090. },
  3091. .ops = &msm_dai_q6_ops,
  3092. .id = SLIMBUS_0_TX,
  3093. .probe = msm_dai_q6_dai_probe,
  3094. .remove = msm_dai_q6_dai_remove,
  3095. },
  3096. {
  3097. .capture = {
  3098. .stream_name = "Slimbus1 Capture",
  3099. .aif_name = "SLIMBUS_1_TX",
  3100. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3101. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3102. SNDRV_PCM_RATE_192000,
  3103. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3104. SNDRV_PCM_FMTBIT_S24_LE |
  3105. SNDRV_PCM_FMTBIT_S24_3LE,
  3106. .channels_min = 1,
  3107. .channels_max = 2,
  3108. .rate_min = 8000,
  3109. .rate_max = 192000,
  3110. },
  3111. .ops = &msm_dai_q6_ops,
  3112. .id = SLIMBUS_1_TX,
  3113. .probe = msm_dai_q6_dai_probe,
  3114. .remove = msm_dai_q6_dai_remove,
  3115. },
  3116. {
  3117. .capture = {
  3118. .stream_name = "Slimbus2 Capture",
  3119. .aif_name = "SLIMBUS_2_TX",
  3120. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3121. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3122. SNDRV_PCM_RATE_192000,
  3123. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3124. SNDRV_PCM_FMTBIT_S24_LE,
  3125. .channels_min = 1,
  3126. .channels_max = 8,
  3127. .rate_min = 8000,
  3128. .rate_max = 192000,
  3129. },
  3130. .ops = &msm_dai_q6_ops,
  3131. .id = SLIMBUS_2_TX,
  3132. .probe = msm_dai_q6_dai_probe,
  3133. .remove = msm_dai_q6_dai_remove,
  3134. },
  3135. {
  3136. .capture = {
  3137. .stream_name = "Slimbus3 Capture",
  3138. .aif_name = "SLIMBUS_3_TX",
  3139. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3140. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3141. SNDRV_PCM_RATE_192000,
  3142. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3143. SNDRV_PCM_FMTBIT_S24_LE,
  3144. .channels_min = 2,
  3145. .channels_max = 4,
  3146. .rate_min = 8000,
  3147. .rate_max = 192000,
  3148. },
  3149. .ops = &msm_dai_q6_ops,
  3150. .id = SLIMBUS_3_TX,
  3151. .probe = msm_dai_q6_dai_probe,
  3152. .remove = msm_dai_q6_dai_remove,
  3153. },
  3154. {
  3155. .capture = {
  3156. .stream_name = "Slimbus4 Capture",
  3157. .aif_name = "SLIMBUS_4_TX",
  3158. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3159. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3160. SNDRV_PCM_RATE_192000,
  3161. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3162. SNDRV_PCM_FMTBIT_S24_LE |
  3163. SNDRV_PCM_FMTBIT_S32_LE,
  3164. .channels_min = 2,
  3165. .channels_max = 4,
  3166. .rate_min = 8000,
  3167. .rate_max = 192000,
  3168. },
  3169. .ops = &msm_dai_q6_ops,
  3170. .id = SLIMBUS_4_TX,
  3171. .probe = msm_dai_q6_dai_probe,
  3172. .remove = msm_dai_q6_dai_remove,
  3173. },
  3174. {
  3175. .capture = {
  3176. .stream_name = "Slimbus5 Capture",
  3177. .aif_name = "SLIMBUS_5_TX",
  3178. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3179. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3180. SNDRV_PCM_RATE_192000,
  3181. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3182. SNDRV_PCM_FMTBIT_S24_LE,
  3183. .channels_min = 1,
  3184. .channels_max = 8,
  3185. .rate_min = 8000,
  3186. .rate_max = 192000,
  3187. },
  3188. .ops = &msm_dai_q6_ops,
  3189. .id = SLIMBUS_5_TX,
  3190. .probe = msm_dai_q6_dai_probe,
  3191. .remove = msm_dai_q6_dai_remove,
  3192. },
  3193. {
  3194. .capture = {
  3195. .stream_name = "Slimbus6 Capture",
  3196. .aif_name = "SLIMBUS_6_TX",
  3197. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3198. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3199. SNDRV_PCM_RATE_192000,
  3200. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3201. SNDRV_PCM_FMTBIT_S24_LE,
  3202. .channels_min = 1,
  3203. .channels_max = 2,
  3204. .rate_min = 8000,
  3205. .rate_max = 192000,
  3206. },
  3207. .ops = &msm_dai_q6_ops,
  3208. .id = SLIMBUS_6_TX,
  3209. .probe = msm_dai_q6_dai_probe,
  3210. .remove = msm_dai_q6_dai_remove,
  3211. },
  3212. {
  3213. .capture = {
  3214. .stream_name = "Slimbus7 Capture",
  3215. .aif_name = "SLIMBUS_7_TX",
  3216. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3217. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3218. SNDRV_PCM_RATE_192000,
  3219. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3220. SNDRV_PCM_FMTBIT_S24_LE |
  3221. SNDRV_PCM_FMTBIT_S32_LE,
  3222. .channels_min = 1,
  3223. .channels_max = 8,
  3224. .rate_min = 8000,
  3225. .rate_max = 192000,
  3226. },
  3227. .ops = &msm_dai_q6_ops,
  3228. .id = SLIMBUS_7_TX,
  3229. .probe = msm_dai_q6_dai_probe,
  3230. .remove = msm_dai_q6_dai_remove,
  3231. },
  3232. {
  3233. .capture = {
  3234. .stream_name = "Slimbus8 Capture",
  3235. .aif_name = "SLIMBUS_8_TX",
  3236. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3237. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3238. SNDRV_PCM_RATE_192000,
  3239. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3240. SNDRV_PCM_FMTBIT_S24_LE |
  3241. SNDRV_PCM_FMTBIT_S32_LE,
  3242. .channels_min = 1,
  3243. .channels_max = 8,
  3244. .rate_min = 8000,
  3245. .rate_max = 192000,
  3246. },
  3247. .ops = &msm_dai_q6_ops,
  3248. .id = SLIMBUS_8_TX,
  3249. .probe = msm_dai_q6_dai_probe,
  3250. .remove = msm_dai_q6_dai_remove,
  3251. },
  3252. };
  3253. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  3254. struct snd_ctl_elem_value *ucontrol)
  3255. {
  3256. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3257. int value = ucontrol->value.integer.value[0];
  3258. dai_data->port_config.i2s.data_format = value;
  3259. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  3260. __func__, value, dai_data->port_config.i2s.mono_stereo,
  3261. dai_data->port_config.i2s.channel_mode);
  3262. return 0;
  3263. }
  3264. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  3265. struct snd_ctl_elem_value *ucontrol)
  3266. {
  3267. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3268. ucontrol->value.integer.value[0] =
  3269. dai_data->port_config.i2s.data_format;
  3270. return 0;
  3271. }
  3272. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  3273. struct snd_ctl_elem_value *ucontrol)
  3274. {
  3275. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3276. int value = ucontrol->value.integer.value[0];
  3277. dai_data->vi_feed_mono = value;
  3278. pr_debug("%s: value = %d\n", __func__, value);
  3279. return 0;
  3280. }
  3281. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  3282. struct snd_ctl_elem_value *ucontrol)
  3283. {
  3284. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3285. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  3286. return 0;
  3287. }
  3288. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  3289. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  3290. msm_dai_q6_mi2s_format_get,
  3291. msm_dai_q6_mi2s_format_put),
  3292. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  3293. msm_dai_q6_mi2s_format_get,
  3294. msm_dai_q6_mi2s_format_put),
  3295. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  3296. msm_dai_q6_mi2s_format_get,
  3297. msm_dai_q6_mi2s_format_put),
  3298. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  3299. msm_dai_q6_mi2s_format_get,
  3300. msm_dai_q6_mi2s_format_put),
  3301. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  3302. msm_dai_q6_mi2s_format_get,
  3303. msm_dai_q6_mi2s_format_put),
  3304. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  3305. msm_dai_q6_mi2s_format_get,
  3306. msm_dai_q6_mi2s_format_put),
  3307. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  3308. msm_dai_q6_mi2s_format_get,
  3309. msm_dai_q6_mi2s_format_put),
  3310. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  3311. msm_dai_q6_mi2s_format_get,
  3312. msm_dai_q6_mi2s_format_put),
  3313. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  3314. msm_dai_q6_mi2s_format_get,
  3315. msm_dai_q6_mi2s_format_put),
  3316. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  3317. msm_dai_q6_mi2s_format_get,
  3318. msm_dai_q6_mi2s_format_put),
  3319. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  3320. msm_dai_q6_mi2s_format_get,
  3321. msm_dai_q6_mi2s_format_put),
  3322. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  3323. msm_dai_q6_mi2s_format_get,
  3324. msm_dai_q6_mi2s_format_put),
  3325. };
  3326. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  3327. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  3328. msm_dai_q6_mi2s_vi_feed_mono_get,
  3329. msm_dai_q6_mi2s_vi_feed_mono_put),
  3330. };
  3331. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  3332. {
  3333. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3334. dev_get_drvdata(dai->dev);
  3335. struct msm_mi2s_pdata *mi2s_pdata =
  3336. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  3337. struct snd_kcontrol *kcontrol = NULL;
  3338. int rc = 0;
  3339. const struct snd_kcontrol_new *ctrl = NULL;
  3340. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  3341. dai->id = mi2s_pdata->intf_id;
  3342. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3343. if (dai->id == MSM_PRIM_MI2S)
  3344. ctrl = &mi2s_config_controls[0];
  3345. if (dai->id == MSM_SEC_MI2S)
  3346. ctrl = &mi2s_config_controls[1];
  3347. if (dai->id == MSM_TERT_MI2S)
  3348. ctrl = &mi2s_config_controls[2];
  3349. if (dai->id == MSM_QUAT_MI2S)
  3350. ctrl = &mi2s_config_controls[3];
  3351. if (dai->id == MSM_QUIN_MI2S)
  3352. ctrl = &mi2s_config_controls[4];
  3353. }
  3354. if (ctrl) {
  3355. kcontrol = snd_ctl_new1(ctrl,
  3356. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  3357. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  3358. if (rc < 0) {
  3359. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  3360. __func__, dai->name);
  3361. goto rtn;
  3362. }
  3363. }
  3364. ctrl = NULL;
  3365. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3366. if (dai->id == MSM_PRIM_MI2S)
  3367. ctrl = &mi2s_config_controls[5];
  3368. if (dai->id == MSM_SEC_MI2S)
  3369. ctrl = &mi2s_config_controls[6];
  3370. if (dai->id == MSM_TERT_MI2S)
  3371. ctrl = &mi2s_config_controls[7];
  3372. if (dai->id == MSM_QUAT_MI2S)
  3373. ctrl = &mi2s_config_controls[8];
  3374. if (dai->id == MSM_QUIN_MI2S)
  3375. ctrl = &mi2s_config_controls[9];
  3376. if (dai->id == MSM_SENARY_MI2S)
  3377. ctrl = &mi2s_config_controls[10];
  3378. if (dai->id == MSM_INT5_MI2S)
  3379. ctrl = &mi2s_config_controls[11];
  3380. }
  3381. if (ctrl) {
  3382. rc = snd_ctl_add(dai->component->card->snd_card,
  3383. snd_ctl_new1(ctrl,
  3384. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3385. if (rc < 0) {
  3386. if (kcontrol)
  3387. snd_ctl_remove(dai->component->card->snd_card,
  3388. kcontrol);
  3389. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  3390. __func__, dai->name);
  3391. }
  3392. }
  3393. if (dai->id == MSM_INT5_MI2S)
  3394. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  3395. if (vi_feed_ctrl) {
  3396. rc = snd_ctl_add(dai->component->card->snd_card,
  3397. snd_ctl_new1(vi_feed_ctrl,
  3398. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3399. if (rc < 0) {
  3400. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  3401. __func__, dai->name);
  3402. }
  3403. }
  3404. rc = msm_dai_q6_dai_add_route(dai);
  3405. rtn:
  3406. return rc;
  3407. }
  3408. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  3409. {
  3410. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3411. dev_get_drvdata(dai->dev);
  3412. int rc;
  3413. /* If AFE port is still up, close it */
  3414. if (test_bit(STATUS_PORT_STARTED,
  3415. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  3416. rc = afe_close(MI2S_RX); /* can block */
  3417. if (rc < 0)
  3418. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  3419. clear_bit(STATUS_PORT_STARTED,
  3420. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  3421. }
  3422. if (test_bit(STATUS_PORT_STARTED,
  3423. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  3424. rc = afe_close(MI2S_TX); /* can block */
  3425. if (rc < 0)
  3426. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  3427. clear_bit(STATUS_PORT_STARTED,
  3428. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  3429. }
  3430. return 0;
  3431. }
  3432. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  3433. struct snd_soc_dai *dai)
  3434. {
  3435. return 0;
  3436. }
  3437. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  3438. {
  3439. int ret = 0;
  3440. switch (stream) {
  3441. case SNDRV_PCM_STREAM_PLAYBACK:
  3442. switch (mi2s_id) {
  3443. case MSM_PRIM_MI2S:
  3444. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  3445. break;
  3446. case MSM_SEC_MI2S:
  3447. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  3448. break;
  3449. case MSM_TERT_MI2S:
  3450. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  3451. break;
  3452. case MSM_QUAT_MI2S:
  3453. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  3454. break;
  3455. case MSM_SEC_MI2S_SD1:
  3456. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  3457. break;
  3458. case MSM_QUIN_MI2S:
  3459. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  3460. break;
  3461. case MSM_INT0_MI2S:
  3462. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  3463. break;
  3464. case MSM_INT1_MI2S:
  3465. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  3466. break;
  3467. case MSM_INT2_MI2S:
  3468. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  3469. break;
  3470. case MSM_INT3_MI2S:
  3471. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  3472. break;
  3473. case MSM_INT4_MI2S:
  3474. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  3475. break;
  3476. case MSM_INT5_MI2S:
  3477. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  3478. break;
  3479. case MSM_INT6_MI2S:
  3480. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  3481. break;
  3482. default:
  3483. pr_err("%s: playback err id 0x%x\n",
  3484. __func__, mi2s_id);
  3485. ret = -1;
  3486. break;
  3487. }
  3488. break;
  3489. case SNDRV_PCM_STREAM_CAPTURE:
  3490. switch (mi2s_id) {
  3491. case MSM_PRIM_MI2S:
  3492. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  3493. break;
  3494. case MSM_SEC_MI2S:
  3495. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  3496. break;
  3497. case MSM_TERT_MI2S:
  3498. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  3499. break;
  3500. case MSM_QUAT_MI2S:
  3501. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  3502. break;
  3503. case MSM_QUIN_MI2S:
  3504. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  3505. break;
  3506. case MSM_SENARY_MI2S:
  3507. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  3508. break;
  3509. case MSM_INT0_MI2S:
  3510. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  3511. break;
  3512. case MSM_INT1_MI2S:
  3513. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  3514. break;
  3515. case MSM_INT2_MI2S:
  3516. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  3517. break;
  3518. case MSM_INT3_MI2S:
  3519. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  3520. break;
  3521. case MSM_INT4_MI2S:
  3522. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  3523. break;
  3524. case MSM_INT5_MI2S:
  3525. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  3526. break;
  3527. case MSM_INT6_MI2S:
  3528. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  3529. break;
  3530. default:
  3531. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  3532. ret = -1;
  3533. break;
  3534. }
  3535. break;
  3536. default:
  3537. pr_err("%s: default err %d\n", __func__, stream);
  3538. ret = -1;
  3539. break;
  3540. }
  3541. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  3542. return ret;
  3543. }
  3544. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  3545. struct snd_soc_dai *dai)
  3546. {
  3547. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3548. dev_get_drvdata(dai->dev);
  3549. struct msm_dai_q6_dai_data *dai_data =
  3550. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3551. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  3552. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  3553. u16 port_id = 0;
  3554. int rc = 0;
  3555. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  3556. &port_id) != 0) {
  3557. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  3558. __func__, port_id);
  3559. return -EINVAL;
  3560. }
  3561. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  3562. "dai_data->channels = %u sample_rate = %u\n", __func__,
  3563. dai->id, port_id, dai_data->channels, dai_data->rate);
  3564. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3565. /* PORT START should be set if prepare called
  3566. * in active state.
  3567. */
  3568. rc = afe_port_start(port_id, &dai_data->port_config,
  3569. dai_data->rate);
  3570. if (rc < 0)
  3571. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  3572. dai->id);
  3573. else
  3574. set_bit(STATUS_PORT_STARTED,
  3575. dai_data->status_mask);
  3576. }
  3577. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  3578. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  3579. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  3580. __func__);
  3581. }
  3582. return rc;
  3583. }
  3584. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  3585. struct snd_pcm_hw_params *params,
  3586. struct snd_soc_dai *dai)
  3587. {
  3588. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3589. dev_get_drvdata(dai->dev);
  3590. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  3591. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3592. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  3593. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  3594. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  3595. dai_data->channels = params_channels(params);
  3596. switch (dai_data->channels) {
  3597. case 8:
  3598. case 7:
  3599. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  3600. goto error_invalid_data;
  3601. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_8CHS;
  3602. break;
  3603. case 6:
  3604. case 5:
  3605. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  3606. goto error_invalid_data;
  3607. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  3608. break;
  3609. case 4:
  3610. case 3:
  3611. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_QUAD01)
  3612. goto error_invalid_data;
  3613. if (mi2s_dai_config->pdata_mi2s_lines == AFE_PORT_I2S_QUAD23)
  3614. dai_data->port_config.i2s.channel_mode =
  3615. mi2s_dai_config->pdata_mi2s_lines;
  3616. else
  3617. dai_data->port_config.i2s.channel_mode =
  3618. AFE_PORT_I2S_QUAD01;
  3619. break;
  3620. case 2:
  3621. case 1:
  3622. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  3623. goto error_invalid_data;
  3624. switch (mi2s_dai_config->pdata_mi2s_lines) {
  3625. case AFE_PORT_I2S_SD0:
  3626. case AFE_PORT_I2S_SD1:
  3627. case AFE_PORT_I2S_SD2:
  3628. case AFE_PORT_I2S_SD3:
  3629. dai_data->port_config.i2s.channel_mode =
  3630. mi2s_dai_config->pdata_mi2s_lines;
  3631. break;
  3632. case AFE_PORT_I2S_QUAD01:
  3633. case AFE_PORT_I2S_6CHS:
  3634. case AFE_PORT_I2S_8CHS:
  3635. if (dai_data->vi_feed_mono == SPKR_1)
  3636. dai_data->port_config.i2s.channel_mode =
  3637. AFE_PORT_I2S_SD0;
  3638. else
  3639. dai_data->port_config.i2s.channel_mode =
  3640. AFE_PORT_I2S_SD1;
  3641. break;
  3642. case AFE_PORT_I2S_QUAD23:
  3643. dai_data->port_config.i2s.channel_mode =
  3644. AFE_PORT_I2S_SD2;
  3645. break;
  3646. }
  3647. if (dai_data->channels == 2)
  3648. dai_data->port_config.i2s.mono_stereo =
  3649. MSM_AFE_CH_STEREO;
  3650. else
  3651. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  3652. break;
  3653. default:
  3654. pr_err("%s: default err channels %d\n",
  3655. __func__, dai_data->channels);
  3656. goto error_invalid_data;
  3657. }
  3658. dai_data->rate = params_rate(params);
  3659. switch (params_format(params)) {
  3660. case SNDRV_PCM_FORMAT_S16_LE:
  3661. case SNDRV_PCM_FORMAT_SPECIAL:
  3662. dai_data->port_config.i2s.bit_width = 16;
  3663. dai_data->bitwidth = 16;
  3664. break;
  3665. case SNDRV_PCM_FORMAT_S24_LE:
  3666. case SNDRV_PCM_FORMAT_S24_3LE:
  3667. dai_data->port_config.i2s.bit_width = 24;
  3668. dai_data->bitwidth = 24;
  3669. break;
  3670. default:
  3671. pr_err("%s: format %d\n",
  3672. __func__, params_format(params));
  3673. return -EINVAL;
  3674. }
  3675. dai_data->port_config.i2s.i2s_cfg_minor_version =
  3676. AFE_API_VERSION_I2S_CONFIG;
  3677. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  3678. if ((test_bit(STATUS_PORT_STARTED,
  3679. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  3680. test_bit(STATUS_PORT_STARTED,
  3681. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  3682. (test_bit(STATUS_PORT_STARTED,
  3683. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  3684. test_bit(STATUS_PORT_STARTED,
  3685. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  3686. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  3687. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  3688. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  3689. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  3690. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  3691. "Tx sample_rate = %u bit_width = %hu\n"
  3692. "Rx sample_rate = %u bit_width = %hu\n"
  3693. , __func__,
  3694. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  3695. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  3696. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  3697. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  3698. return -EINVAL;
  3699. }
  3700. }
  3701. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  3702. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  3703. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  3704. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  3705. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  3706. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  3707. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  3708. i2s->sample_rate, i2s->data_format, i2s->reserved);
  3709. return 0;
  3710. error_invalid_data:
  3711. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  3712. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  3713. return -EINVAL;
  3714. }
  3715. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  3716. {
  3717. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3718. dev_get_drvdata(dai->dev);
  3719. if (test_bit(STATUS_PORT_STARTED,
  3720. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  3721. test_bit(STATUS_PORT_STARTED,
  3722. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  3723. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  3724. __func__);
  3725. return -EPERM;
  3726. }
  3727. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  3728. case SND_SOC_DAIFMT_CBS_CFS:
  3729. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  3730. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  3731. break;
  3732. case SND_SOC_DAIFMT_CBM_CFM:
  3733. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  3734. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  3735. break;
  3736. default:
  3737. pr_err("%s: fmt %d\n",
  3738. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  3739. return -EINVAL;
  3740. }
  3741. return 0;
  3742. }
  3743. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  3744. struct snd_soc_dai *dai)
  3745. {
  3746. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3747. dev_get_drvdata(dai->dev);
  3748. struct msm_dai_q6_dai_data *dai_data =
  3749. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3750. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  3751. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  3752. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  3753. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  3754. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  3755. }
  3756. return 0;
  3757. }
  3758. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  3759. struct snd_soc_dai *dai)
  3760. {
  3761. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3762. dev_get_drvdata(dai->dev);
  3763. struct msm_dai_q6_dai_data *dai_data =
  3764. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3765. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  3766. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  3767. u16 port_id = 0;
  3768. int rc = 0;
  3769. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  3770. &port_id) != 0) {
  3771. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  3772. __func__, port_id);
  3773. }
  3774. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  3775. __func__, port_id);
  3776. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3777. rc = afe_close(port_id);
  3778. if (rc < 0)
  3779. dev_err(dai->dev, "fail to close AFE port\n");
  3780. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  3781. }
  3782. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  3783. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  3784. }
  3785. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  3786. .startup = msm_dai_q6_mi2s_startup,
  3787. .prepare = msm_dai_q6_mi2s_prepare,
  3788. .hw_params = msm_dai_q6_mi2s_hw_params,
  3789. .hw_free = msm_dai_q6_mi2s_hw_free,
  3790. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  3791. .shutdown = msm_dai_q6_mi2s_shutdown,
  3792. };
  3793. /* Channel min and max are initialized base on platform data */
  3794. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  3795. {
  3796. .playback = {
  3797. .stream_name = "Primary MI2S Playback",
  3798. .aif_name = "PRI_MI2S_RX",
  3799. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3800. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3801. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3802. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3803. SNDRV_PCM_RATE_192000,
  3804. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3805. SNDRV_PCM_FMTBIT_S24_LE |
  3806. SNDRV_PCM_FMTBIT_S24_3LE,
  3807. .rate_min = 8000,
  3808. .rate_max = 192000,
  3809. },
  3810. .capture = {
  3811. .stream_name = "Primary MI2S Capture",
  3812. .aif_name = "PRI_MI2S_TX",
  3813. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3814. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3815. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3816. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3817. SNDRV_PCM_RATE_192000,
  3818. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3819. .rate_min = 8000,
  3820. .rate_max = 192000,
  3821. },
  3822. .ops = &msm_dai_q6_mi2s_ops,
  3823. .id = MSM_PRIM_MI2S,
  3824. .probe = msm_dai_q6_dai_mi2s_probe,
  3825. .remove = msm_dai_q6_dai_mi2s_remove,
  3826. },
  3827. {
  3828. .playback = {
  3829. .stream_name = "Secondary MI2S Playback",
  3830. .aif_name = "SEC_MI2S_RX",
  3831. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3832. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3833. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3834. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3835. SNDRV_PCM_RATE_192000,
  3836. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3837. .rate_min = 8000,
  3838. .rate_max = 192000,
  3839. },
  3840. .capture = {
  3841. .stream_name = "Secondary MI2S Capture",
  3842. .aif_name = "SEC_MI2S_TX",
  3843. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3844. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3845. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3846. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3847. SNDRV_PCM_RATE_192000,
  3848. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3849. .rate_min = 8000,
  3850. .rate_max = 192000,
  3851. },
  3852. .ops = &msm_dai_q6_mi2s_ops,
  3853. .id = MSM_SEC_MI2S,
  3854. .probe = msm_dai_q6_dai_mi2s_probe,
  3855. .remove = msm_dai_q6_dai_mi2s_remove,
  3856. },
  3857. {
  3858. .playback = {
  3859. .stream_name = "Tertiary MI2S Playback",
  3860. .aif_name = "TERT_MI2S_RX",
  3861. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3862. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3863. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3864. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3865. SNDRV_PCM_RATE_192000,
  3866. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3867. .rate_min = 8000,
  3868. .rate_max = 192000,
  3869. },
  3870. .capture = {
  3871. .stream_name = "Tertiary MI2S Capture",
  3872. .aif_name = "TERT_MI2S_TX",
  3873. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3874. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3875. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3876. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3877. SNDRV_PCM_RATE_192000,
  3878. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3879. .rate_min = 8000,
  3880. .rate_max = 192000,
  3881. },
  3882. .ops = &msm_dai_q6_mi2s_ops,
  3883. .id = MSM_TERT_MI2S,
  3884. .probe = msm_dai_q6_dai_mi2s_probe,
  3885. .remove = msm_dai_q6_dai_mi2s_remove,
  3886. },
  3887. {
  3888. .playback = {
  3889. .stream_name = "Quaternary MI2S Playback",
  3890. .aif_name = "QUAT_MI2S_RX",
  3891. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3892. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3893. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3894. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3895. SNDRV_PCM_RATE_192000,
  3896. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3897. .rate_min = 8000,
  3898. .rate_max = 192000,
  3899. },
  3900. .capture = {
  3901. .stream_name = "Quaternary MI2S Capture",
  3902. .aif_name = "QUAT_MI2S_TX",
  3903. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3904. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3905. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3906. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3907. SNDRV_PCM_RATE_192000,
  3908. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3909. .rate_min = 8000,
  3910. .rate_max = 192000,
  3911. },
  3912. .ops = &msm_dai_q6_mi2s_ops,
  3913. .id = MSM_QUAT_MI2S,
  3914. .probe = msm_dai_q6_dai_mi2s_probe,
  3915. .remove = msm_dai_q6_dai_mi2s_remove,
  3916. },
  3917. {
  3918. .playback = {
  3919. .stream_name = "Quinary MI2S Playback",
  3920. .aif_name = "QUIN_MI2S_RX",
  3921. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3922. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3923. SNDRV_PCM_RATE_192000,
  3924. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3925. .rate_min = 8000,
  3926. .rate_max = 192000,
  3927. },
  3928. .capture = {
  3929. .stream_name = "Quinary MI2S Capture",
  3930. .aif_name = "QUIN_MI2S_TX",
  3931. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3932. SNDRV_PCM_RATE_16000,
  3933. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3934. .rate_min = 8000,
  3935. .rate_max = 48000,
  3936. },
  3937. .ops = &msm_dai_q6_mi2s_ops,
  3938. .id = MSM_QUIN_MI2S,
  3939. .probe = msm_dai_q6_dai_mi2s_probe,
  3940. .remove = msm_dai_q6_dai_mi2s_remove,
  3941. },
  3942. {
  3943. .playback = {
  3944. .stream_name = "Secondary MI2S Playback SD1",
  3945. .aif_name = "SEC_MI2S_RX_SD1",
  3946. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3947. SNDRV_PCM_RATE_16000,
  3948. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3949. .rate_min = 8000,
  3950. .rate_max = 48000,
  3951. },
  3952. .id = MSM_SEC_MI2S_SD1,
  3953. },
  3954. {
  3955. .capture = {
  3956. .stream_name = "Senary_mi2s Capture",
  3957. .aif_name = "SENARY_TX",
  3958. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3959. SNDRV_PCM_RATE_16000,
  3960. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3961. .rate_min = 8000,
  3962. .rate_max = 48000,
  3963. },
  3964. .ops = &msm_dai_q6_mi2s_ops,
  3965. .id = MSM_SENARY_MI2S,
  3966. .probe = msm_dai_q6_dai_mi2s_probe,
  3967. .remove = msm_dai_q6_dai_mi2s_remove,
  3968. },
  3969. {
  3970. .playback = {
  3971. .stream_name = "INT0 MI2S Playback",
  3972. .aif_name = "INT0_MI2S_RX",
  3973. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3974. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  3975. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  3976. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3977. SNDRV_PCM_FMTBIT_S24_LE |
  3978. SNDRV_PCM_FMTBIT_S24_3LE,
  3979. .rate_min = 8000,
  3980. .rate_max = 192000,
  3981. },
  3982. .capture = {
  3983. .stream_name = "INT0 MI2S Capture",
  3984. .aif_name = "INT0_MI2S_TX",
  3985. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3986. SNDRV_PCM_RATE_16000,
  3987. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3988. .rate_min = 8000,
  3989. .rate_max = 48000,
  3990. },
  3991. .ops = &msm_dai_q6_mi2s_ops,
  3992. .id = MSM_INT0_MI2S,
  3993. .probe = msm_dai_q6_dai_mi2s_probe,
  3994. .remove = msm_dai_q6_dai_mi2s_remove,
  3995. },
  3996. {
  3997. .playback = {
  3998. .stream_name = "INT1 MI2S Playback",
  3999. .aif_name = "INT1_MI2S_RX",
  4000. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4001. SNDRV_PCM_RATE_16000,
  4002. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4003. SNDRV_PCM_FMTBIT_S24_LE |
  4004. SNDRV_PCM_FMTBIT_S24_3LE,
  4005. .rate_min = 8000,
  4006. .rate_max = 48000,
  4007. },
  4008. .capture = {
  4009. .stream_name = "INT1 MI2S Capture",
  4010. .aif_name = "INT1_MI2S_TX",
  4011. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4012. SNDRV_PCM_RATE_16000,
  4013. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4014. .rate_min = 8000,
  4015. .rate_max = 48000,
  4016. },
  4017. .ops = &msm_dai_q6_mi2s_ops,
  4018. .id = MSM_INT1_MI2S,
  4019. .probe = msm_dai_q6_dai_mi2s_probe,
  4020. .remove = msm_dai_q6_dai_mi2s_remove,
  4021. },
  4022. {
  4023. .playback = {
  4024. .stream_name = "INT2 MI2S Playback",
  4025. .aif_name = "INT2_MI2S_RX",
  4026. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4027. SNDRV_PCM_RATE_16000,
  4028. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4029. SNDRV_PCM_FMTBIT_S24_LE |
  4030. SNDRV_PCM_FMTBIT_S24_3LE,
  4031. .rate_min = 8000,
  4032. .rate_max = 48000,
  4033. },
  4034. .capture = {
  4035. .stream_name = "INT2 MI2S Capture",
  4036. .aif_name = "INT2_MI2S_TX",
  4037. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4038. SNDRV_PCM_RATE_16000,
  4039. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4040. .rate_min = 8000,
  4041. .rate_max = 48000,
  4042. },
  4043. .ops = &msm_dai_q6_mi2s_ops,
  4044. .id = MSM_INT2_MI2S,
  4045. .probe = msm_dai_q6_dai_mi2s_probe,
  4046. .remove = msm_dai_q6_dai_mi2s_remove,
  4047. },
  4048. {
  4049. .playback = {
  4050. .stream_name = "INT3 MI2S Playback",
  4051. .aif_name = "INT3_MI2S_RX",
  4052. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4053. SNDRV_PCM_RATE_16000,
  4054. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4055. SNDRV_PCM_FMTBIT_S24_LE |
  4056. SNDRV_PCM_FMTBIT_S24_3LE,
  4057. .rate_min = 8000,
  4058. .rate_max = 48000,
  4059. },
  4060. .capture = {
  4061. .stream_name = "INT3 MI2S Capture",
  4062. .aif_name = "INT3_MI2S_TX",
  4063. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4064. SNDRV_PCM_RATE_16000,
  4065. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4066. .rate_min = 8000,
  4067. .rate_max = 48000,
  4068. },
  4069. .ops = &msm_dai_q6_mi2s_ops,
  4070. .id = MSM_INT3_MI2S,
  4071. .probe = msm_dai_q6_dai_mi2s_probe,
  4072. .remove = msm_dai_q6_dai_mi2s_remove,
  4073. },
  4074. {
  4075. .playback = {
  4076. .stream_name = "INT4 MI2S Playback",
  4077. .aif_name = "INT4_MI2S_RX",
  4078. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4079. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4080. SNDRV_PCM_RATE_192000,
  4081. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4082. SNDRV_PCM_FMTBIT_S24_LE |
  4083. SNDRV_PCM_FMTBIT_S24_3LE,
  4084. .rate_min = 8000,
  4085. .rate_max = 192000,
  4086. },
  4087. .capture = {
  4088. .stream_name = "INT4 MI2S Capture",
  4089. .aif_name = "INT4_MI2S_TX",
  4090. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4091. SNDRV_PCM_RATE_16000,
  4092. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4093. .rate_min = 8000,
  4094. .rate_max = 48000,
  4095. },
  4096. .ops = &msm_dai_q6_mi2s_ops,
  4097. .id = MSM_INT4_MI2S,
  4098. .probe = msm_dai_q6_dai_mi2s_probe,
  4099. .remove = msm_dai_q6_dai_mi2s_remove,
  4100. },
  4101. {
  4102. .playback = {
  4103. .stream_name = "INT5 MI2S Playback",
  4104. .aif_name = "INT5_MI2S_RX",
  4105. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4106. SNDRV_PCM_RATE_16000,
  4107. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4108. SNDRV_PCM_FMTBIT_S24_LE |
  4109. SNDRV_PCM_FMTBIT_S24_3LE,
  4110. .rate_min = 8000,
  4111. .rate_max = 48000,
  4112. },
  4113. .capture = {
  4114. .stream_name = "INT5 MI2S Capture",
  4115. .aif_name = "INT5_MI2S_TX",
  4116. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4117. SNDRV_PCM_RATE_16000,
  4118. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4119. .rate_min = 8000,
  4120. .rate_max = 48000,
  4121. },
  4122. .ops = &msm_dai_q6_mi2s_ops,
  4123. .id = MSM_INT5_MI2S,
  4124. .probe = msm_dai_q6_dai_mi2s_probe,
  4125. .remove = msm_dai_q6_dai_mi2s_remove,
  4126. },
  4127. {
  4128. .playback = {
  4129. .stream_name = "INT6 MI2S Playback",
  4130. .aif_name = "INT6_MI2S_RX",
  4131. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4132. SNDRV_PCM_RATE_16000,
  4133. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4134. SNDRV_PCM_FMTBIT_S24_LE |
  4135. SNDRV_PCM_FMTBIT_S24_3LE,
  4136. .rate_min = 8000,
  4137. .rate_max = 48000,
  4138. },
  4139. .capture = {
  4140. .stream_name = "INT6 MI2S Capture",
  4141. .aif_name = "INT6_MI2S_TX",
  4142. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4143. SNDRV_PCM_RATE_16000,
  4144. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4145. .rate_min = 8000,
  4146. .rate_max = 48000,
  4147. },
  4148. .ops = &msm_dai_q6_mi2s_ops,
  4149. .id = MSM_INT6_MI2S,
  4150. .probe = msm_dai_q6_dai_mi2s_probe,
  4151. .remove = msm_dai_q6_dai_mi2s_remove,
  4152. },
  4153. };
  4154. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  4155. unsigned int *ch_cnt)
  4156. {
  4157. u8 num_of_sd_lines;
  4158. num_of_sd_lines = num_of_bits_set(sd_lines);
  4159. switch (num_of_sd_lines) {
  4160. case 0:
  4161. pr_debug("%s: no line is assigned\n", __func__);
  4162. break;
  4163. case 1:
  4164. switch (sd_lines) {
  4165. case MSM_MI2S_SD0:
  4166. *config_ptr = AFE_PORT_I2S_SD0;
  4167. break;
  4168. case MSM_MI2S_SD1:
  4169. *config_ptr = AFE_PORT_I2S_SD1;
  4170. break;
  4171. case MSM_MI2S_SD2:
  4172. *config_ptr = AFE_PORT_I2S_SD2;
  4173. break;
  4174. case MSM_MI2S_SD3:
  4175. *config_ptr = AFE_PORT_I2S_SD3;
  4176. break;
  4177. default:
  4178. pr_err("%s: invalid SD lines %d\n",
  4179. __func__, sd_lines);
  4180. goto error_invalid_data;
  4181. }
  4182. break;
  4183. case 2:
  4184. switch (sd_lines) {
  4185. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  4186. *config_ptr = AFE_PORT_I2S_QUAD01;
  4187. break;
  4188. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4189. *config_ptr = AFE_PORT_I2S_QUAD23;
  4190. break;
  4191. default:
  4192. pr_err("%s: invalid SD lines %d\n",
  4193. __func__, sd_lines);
  4194. goto error_invalid_data;
  4195. }
  4196. break;
  4197. case 3:
  4198. switch (sd_lines) {
  4199. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  4200. *config_ptr = AFE_PORT_I2S_6CHS;
  4201. break;
  4202. default:
  4203. pr_err("%s: invalid SD lines %d\n",
  4204. __func__, sd_lines);
  4205. goto error_invalid_data;
  4206. }
  4207. break;
  4208. case 4:
  4209. switch (sd_lines) {
  4210. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4211. *config_ptr = AFE_PORT_I2S_8CHS;
  4212. break;
  4213. default:
  4214. pr_err("%s: invalid SD lines %d\n",
  4215. __func__, sd_lines);
  4216. goto error_invalid_data;
  4217. }
  4218. break;
  4219. default:
  4220. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  4221. goto error_invalid_data;
  4222. }
  4223. *ch_cnt = num_of_sd_lines;
  4224. return 0;
  4225. error_invalid_data:
  4226. pr_err("%s: invalid data\n", __func__);
  4227. return -EINVAL;
  4228. }
  4229. static int msm_dai_q6_mi2s_platform_data_validation(
  4230. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  4231. {
  4232. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  4233. struct msm_mi2s_pdata *mi2s_pdata =
  4234. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  4235. unsigned int ch_cnt;
  4236. int rc = 0;
  4237. u16 sd_line;
  4238. if (mi2s_pdata == NULL) {
  4239. pr_err("%s: mi2s_pdata NULL", __func__);
  4240. return -EINVAL;
  4241. }
  4242. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  4243. &sd_line, &ch_cnt);
  4244. if (rc < 0) {
  4245. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  4246. goto rtn;
  4247. }
  4248. if (ch_cnt) {
  4249. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4250. sd_line;
  4251. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  4252. dai_driver->playback.channels_min = 1;
  4253. dai_driver->playback.channels_max = ch_cnt << 1;
  4254. } else {
  4255. dai_driver->playback.channels_min = 0;
  4256. dai_driver->playback.channels_max = 0;
  4257. }
  4258. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  4259. &sd_line, &ch_cnt);
  4260. if (rc < 0) {
  4261. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  4262. goto rtn;
  4263. }
  4264. if (ch_cnt) {
  4265. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4266. sd_line;
  4267. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  4268. dai_driver->capture.channels_min = 1;
  4269. dai_driver->capture.channels_max = ch_cnt << 1;
  4270. } else {
  4271. dai_driver->capture.channels_min = 0;
  4272. dai_driver->capture.channels_max = 0;
  4273. }
  4274. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  4275. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  4276. dai_data->tx_dai.pdata_mi2s_lines);
  4277. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  4278. __func__, dai_driver->playback.channels_max,
  4279. dai_driver->capture.channels_max);
  4280. rtn:
  4281. return rc;
  4282. }
  4283. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  4284. .name = "msm-dai-q6-mi2s",
  4285. };
  4286. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  4287. {
  4288. struct msm_dai_q6_mi2s_dai_data *dai_data;
  4289. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  4290. u32 tx_line = 0;
  4291. u32 rx_line = 0;
  4292. u32 mi2s_intf = 0;
  4293. struct msm_mi2s_pdata *mi2s_pdata;
  4294. int rc;
  4295. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  4296. &mi2s_intf);
  4297. if (rc) {
  4298. dev_err(&pdev->dev,
  4299. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  4300. goto rtn;
  4301. }
  4302. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  4303. mi2s_intf);
  4304. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  4305. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  4306. dev_err(&pdev->dev,
  4307. "%s: Invalid MI2S ID %u from Device Tree\n",
  4308. __func__, mi2s_intf);
  4309. rc = -ENXIO;
  4310. goto rtn;
  4311. }
  4312. pdev->id = mi2s_intf;
  4313. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  4314. if (!mi2s_pdata) {
  4315. rc = -ENOMEM;
  4316. goto rtn;
  4317. }
  4318. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  4319. &rx_line);
  4320. if (rc) {
  4321. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  4322. "qcom,msm-mi2s-rx-lines");
  4323. goto free_pdata;
  4324. }
  4325. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  4326. &tx_line);
  4327. if (rc) {
  4328. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  4329. "qcom,msm-mi2s-tx-lines");
  4330. goto free_pdata;
  4331. }
  4332. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  4333. dev_name(&pdev->dev), rx_line, tx_line);
  4334. mi2s_pdata->rx_sd_lines = rx_line;
  4335. mi2s_pdata->tx_sd_lines = tx_line;
  4336. mi2s_pdata->intf_id = mi2s_intf;
  4337. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  4338. GFP_KERNEL);
  4339. if (!dai_data) {
  4340. rc = -ENOMEM;
  4341. goto free_pdata;
  4342. } else
  4343. dev_set_drvdata(&pdev->dev, dai_data);
  4344. pdev->dev.platform_data = mi2s_pdata;
  4345. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  4346. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  4347. if (rc < 0)
  4348. goto free_dai_data;
  4349. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  4350. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  4351. if (rc < 0)
  4352. goto err_register;
  4353. return 0;
  4354. err_register:
  4355. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  4356. free_dai_data:
  4357. kfree(dai_data);
  4358. free_pdata:
  4359. kfree(mi2s_pdata);
  4360. rtn:
  4361. return rc;
  4362. }
  4363. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  4364. {
  4365. snd_soc_unregister_component(&pdev->dev);
  4366. return 0;
  4367. }
  4368. static const struct snd_soc_component_driver msm_dai_q6_component = {
  4369. .name = "msm-dai-q6-dev",
  4370. };
  4371. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  4372. {
  4373. int rc, id, i, len;
  4374. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  4375. char stream_name[80];
  4376. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  4377. if (rc) {
  4378. dev_err(&pdev->dev,
  4379. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  4380. return rc;
  4381. }
  4382. pdev->id = id;
  4383. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4384. dev_name(&pdev->dev), pdev->id);
  4385. switch (id) {
  4386. case SLIMBUS_0_RX:
  4387. strlcpy(stream_name, "Slimbus Playback", 80);
  4388. goto register_slim_playback;
  4389. case SLIMBUS_2_RX:
  4390. strlcpy(stream_name, "Slimbus2 Playback", 80);
  4391. goto register_slim_playback;
  4392. case SLIMBUS_1_RX:
  4393. strlcpy(stream_name, "Slimbus1 Playback", 80);
  4394. goto register_slim_playback;
  4395. case SLIMBUS_3_RX:
  4396. strlcpy(stream_name, "Slimbus3 Playback", 80);
  4397. goto register_slim_playback;
  4398. case SLIMBUS_4_RX:
  4399. strlcpy(stream_name, "Slimbus4 Playback", 80);
  4400. goto register_slim_playback;
  4401. case SLIMBUS_5_RX:
  4402. strlcpy(stream_name, "Slimbus5 Playback", 80);
  4403. goto register_slim_playback;
  4404. case SLIMBUS_6_RX:
  4405. strlcpy(stream_name, "Slimbus6 Playback", 80);
  4406. goto register_slim_playback;
  4407. case SLIMBUS_7_RX:
  4408. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  4409. goto register_slim_playback;
  4410. case SLIMBUS_8_RX:
  4411. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  4412. goto register_slim_playback;
  4413. register_slim_playback:
  4414. rc = -ENODEV;
  4415. len = strnlen(stream_name, 80);
  4416. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  4417. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  4418. !strcmp(stream_name,
  4419. msm_dai_q6_slimbus_rx_dai[i]
  4420. .playback.stream_name)) {
  4421. rc = snd_soc_register_component(&pdev->dev,
  4422. &msm_dai_q6_component,
  4423. &msm_dai_q6_slimbus_rx_dai[i], 1);
  4424. break;
  4425. }
  4426. }
  4427. if (rc)
  4428. pr_err("%s: Device not found stream name %s\n",
  4429. __func__, stream_name);
  4430. break;
  4431. case SLIMBUS_0_TX:
  4432. strlcpy(stream_name, "Slimbus Capture", 80);
  4433. goto register_slim_capture;
  4434. case SLIMBUS_1_TX:
  4435. strlcpy(stream_name, "Slimbus1 Capture", 80);
  4436. goto register_slim_capture;
  4437. case SLIMBUS_2_TX:
  4438. strlcpy(stream_name, "Slimbus2 Capture", 80);
  4439. goto register_slim_capture;
  4440. case SLIMBUS_3_TX:
  4441. strlcpy(stream_name, "Slimbus3 Capture", 80);
  4442. goto register_slim_capture;
  4443. case SLIMBUS_4_TX:
  4444. strlcpy(stream_name, "Slimbus4 Capture", 80);
  4445. goto register_slim_capture;
  4446. case SLIMBUS_5_TX:
  4447. strlcpy(stream_name, "Slimbus5 Capture", 80);
  4448. goto register_slim_capture;
  4449. case SLIMBUS_6_TX:
  4450. strlcpy(stream_name, "Slimbus6 Capture", 80);
  4451. goto register_slim_capture;
  4452. case SLIMBUS_7_TX:
  4453. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  4454. goto register_slim_capture;
  4455. case SLIMBUS_8_TX:
  4456. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  4457. goto register_slim_capture;
  4458. register_slim_capture:
  4459. rc = -ENODEV;
  4460. len = strnlen(stream_name, 80);
  4461. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  4462. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  4463. !strcmp(stream_name,
  4464. msm_dai_q6_slimbus_tx_dai[i]
  4465. .capture.stream_name)) {
  4466. rc = snd_soc_register_component(&pdev->dev,
  4467. &msm_dai_q6_component,
  4468. &msm_dai_q6_slimbus_tx_dai[i], 1);
  4469. break;
  4470. }
  4471. }
  4472. if (rc)
  4473. pr_err("%s: Device not found stream name %s\n",
  4474. __func__, stream_name);
  4475. break;
  4476. case INT_BT_SCO_RX:
  4477. rc = snd_soc_register_component(&pdev->dev,
  4478. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  4479. break;
  4480. case INT_BT_SCO_TX:
  4481. rc = snd_soc_register_component(&pdev->dev,
  4482. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  4483. break;
  4484. case INT_BT_A2DP_RX:
  4485. rc = snd_soc_register_component(&pdev->dev,
  4486. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  4487. break;
  4488. case INT_FM_RX:
  4489. rc = snd_soc_register_component(&pdev->dev,
  4490. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  4491. break;
  4492. case INT_FM_TX:
  4493. rc = snd_soc_register_component(&pdev->dev,
  4494. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  4495. break;
  4496. case AFE_PORT_ID_USB_RX:
  4497. rc = snd_soc_register_component(&pdev->dev,
  4498. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  4499. break;
  4500. case AFE_PORT_ID_USB_TX:
  4501. rc = snd_soc_register_component(&pdev->dev,
  4502. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  4503. break;
  4504. case RT_PROXY_DAI_001_RX:
  4505. strlcpy(stream_name, "AFE Playback", 80);
  4506. goto register_afe_playback;
  4507. case RT_PROXY_DAI_002_RX:
  4508. strlcpy(stream_name, "AFE-PROXY RX", 80);
  4509. register_afe_playback:
  4510. rc = -ENODEV;
  4511. len = strnlen(stream_name, 80);
  4512. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  4513. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  4514. !strcmp(stream_name,
  4515. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  4516. rc = snd_soc_register_component(&pdev->dev,
  4517. &msm_dai_q6_component,
  4518. &msm_dai_q6_afe_rx_dai[i], 1);
  4519. break;
  4520. }
  4521. }
  4522. if (rc)
  4523. pr_err("%s: Device not found stream name %s\n",
  4524. __func__, stream_name);
  4525. break;
  4526. case RT_PROXY_DAI_001_TX:
  4527. strlcpy(stream_name, "AFE-PROXY TX", 80);
  4528. goto register_afe_capture;
  4529. case RT_PROXY_DAI_002_TX:
  4530. strlcpy(stream_name, "AFE Capture", 80);
  4531. register_afe_capture:
  4532. rc = -ENODEV;
  4533. len = strnlen(stream_name, 80);
  4534. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  4535. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  4536. !strcmp(stream_name,
  4537. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  4538. rc = snd_soc_register_component(&pdev->dev,
  4539. &msm_dai_q6_component,
  4540. &msm_dai_q6_afe_tx_dai[i], 1);
  4541. break;
  4542. }
  4543. }
  4544. if (rc)
  4545. pr_err("%s: Device not found stream name %s\n",
  4546. __func__, stream_name);
  4547. break;
  4548. case VOICE_PLAYBACK_TX:
  4549. strlcpy(stream_name, "Voice Farend Playback", 80);
  4550. goto register_voice_playback;
  4551. case VOICE2_PLAYBACK_TX:
  4552. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  4553. register_voice_playback:
  4554. rc = -ENODEV;
  4555. len = strnlen(stream_name, 80);
  4556. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  4557. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  4558. && !strcmp(stream_name,
  4559. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  4560. rc = snd_soc_register_component(&pdev->dev,
  4561. &msm_dai_q6_component,
  4562. &msm_dai_q6_voc_playback_dai[i], 1);
  4563. break;
  4564. }
  4565. }
  4566. if (rc)
  4567. pr_err("%s Device not found stream name %s\n",
  4568. __func__, stream_name);
  4569. break;
  4570. case VOICE_RECORD_RX:
  4571. strlcpy(stream_name, "Voice Downlink Capture", 80);
  4572. goto register_uplink_capture;
  4573. case VOICE_RECORD_TX:
  4574. strlcpy(stream_name, "Voice Uplink Capture", 80);
  4575. register_uplink_capture:
  4576. rc = -ENODEV;
  4577. len = strnlen(stream_name, 80);
  4578. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  4579. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  4580. && !strcmp(stream_name,
  4581. msm_dai_q6_incall_record_dai[i].
  4582. capture.stream_name)) {
  4583. rc = snd_soc_register_component(&pdev->dev,
  4584. &msm_dai_q6_component,
  4585. &msm_dai_q6_incall_record_dai[i], 1);
  4586. break;
  4587. }
  4588. }
  4589. if (rc)
  4590. pr_err("%s: Device not found stream name %s\n",
  4591. __func__, stream_name);
  4592. break;
  4593. default:
  4594. rc = -ENODEV;
  4595. break;
  4596. }
  4597. return rc;
  4598. }
  4599. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  4600. {
  4601. snd_soc_unregister_component(&pdev->dev);
  4602. return 0;
  4603. }
  4604. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  4605. { .compatible = "qcom,msm-dai-q6-dev", },
  4606. { }
  4607. };
  4608. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  4609. static struct platform_driver msm_dai_q6_dev = {
  4610. .probe = msm_dai_q6_dev_probe,
  4611. .remove = msm_dai_q6_dev_remove,
  4612. .driver = {
  4613. .name = "msm-dai-q6-dev",
  4614. .owner = THIS_MODULE,
  4615. .of_match_table = msm_dai_q6_dev_dt_match,
  4616. },
  4617. };
  4618. static int msm_dai_q6_probe(struct platform_device *pdev)
  4619. {
  4620. int rc;
  4621. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4622. dev_name(&pdev->dev), pdev->id);
  4623. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4624. if (rc) {
  4625. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4626. __func__, rc);
  4627. } else
  4628. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4629. return rc;
  4630. }
  4631. static int msm_dai_q6_remove(struct platform_device *pdev)
  4632. {
  4633. return 0;
  4634. }
  4635. static const struct of_device_id msm_dai_q6_dt_match[] = {
  4636. { .compatible = "qcom,msm-dai-q6", },
  4637. { }
  4638. };
  4639. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  4640. static struct platform_driver msm_dai_q6 = {
  4641. .probe = msm_dai_q6_probe,
  4642. .remove = msm_dai_q6_remove,
  4643. .driver = {
  4644. .name = "msm-dai-q6",
  4645. .owner = THIS_MODULE,
  4646. .of_match_table = msm_dai_q6_dt_match,
  4647. },
  4648. };
  4649. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  4650. {
  4651. int rc;
  4652. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4653. if (rc) {
  4654. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4655. __func__, rc);
  4656. } else
  4657. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4658. return rc;
  4659. }
  4660. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  4661. {
  4662. return 0;
  4663. }
  4664. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  4665. { .compatible = "qcom,msm-dai-mi2s", },
  4666. { }
  4667. };
  4668. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  4669. static struct platform_driver msm_dai_mi2s_q6 = {
  4670. .probe = msm_dai_mi2s_q6_probe,
  4671. .remove = msm_dai_mi2s_q6_remove,
  4672. .driver = {
  4673. .name = "msm-dai-mi2s",
  4674. .owner = THIS_MODULE,
  4675. .of_match_table = msm_dai_mi2s_dt_match,
  4676. },
  4677. };
  4678. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  4679. { .compatible = "qcom,msm-dai-q6-mi2s", },
  4680. { }
  4681. };
  4682. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  4683. static struct platform_driver msm_dai_q6_mi2s_driver = {
  4684. .probe = msm_dai_q6_mi2s_dev_probe,
  4685. .remove = msm_dai_q6_mi2s_dev_remove,
  4686. .driver = {
  4687. .name = "msm-dai-q6-mi2s",
  4688. .owner = THIS_MODULE,
  4689. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  4690. },
  4691. };
  4692. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  4693. {
  4694. int rc;
  4695. pdev->id = AFE_PORT_ID_SPDIF_RX;
  4696. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4697. dev_name(&pdev->dev), pdev->id);
  4698. rc = snd_soc_register_component(&pdev->dev,
  4699. &msm_dai_spdif_q6_component,
  4700. &msm_dai_q6_spdif_spdif_rx_dai, 1);
  4701. return rc;
  4702. }
  4703. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  4704. {
  4705. snd_soc_unregister_component(&pdev->dev);
  4706. return 0;
  4707. }
  4708. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  4709. {.compatible = "qcom,msm-dai-q6-spdif"},
  4710. {}
  4711. };
  4712. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  4713. static struct platform_driver msm_dai_q6_spdif_driver = {
  4714. .probe = msm_dai_q6_spdif_dev_probe,
  4715. .remove = msm_dai_q6_spdif_dev_remove,
  4716. .driver = {
  4717. .name = "msm-dai-q6-spdif",
  4718. .owner = THIS_MODULE,
  4719. .of_match_table = msm_dai_q6_spdif_dt_match,
  4720. },
  4721. };
  4722. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  4723. struct afe_clk_set *clk_set, u32 mode)
  4724. {
  4725. switch (group_id) {
  4726. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  4727. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  4728. if (mode)
  4729. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  4730. else
  4731. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  4732. break;
  4733. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  4734. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  4735. if (mode)
  4736. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  4737. else
  4738. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  4739. break;
  4740. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  4741. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  4742. if (mode)
  4743. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  4744. else
  4745. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  4746. break;
  4747. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  4748. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  4749. if (mode)
  4750. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  4751. else
  4752. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  4753. break;
  4754. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  4755. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  4756. if (mode)
  4757. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  4758. else
  4759. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  4760. break;
  4761. default:
  4762. return -EINVAL;
  4763. }
  4764. return 0;
  4765. }
  4766. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  4767. {
  4768. int rc = 0;
  4769. const uint32_t *port_id_array = NULL;
  4770. uint32_t array_length = 0;
  4771. int i = 0;
  4772. int group_idx = 0;
  4773. u32 clk_mode = 0;
  4774. /* extract tdm group info into static */
  4775. rc = of_property_read_u32(pdev->dev.of_node,
  4776. "qcom,msm-cpudai-tdm-group-id",
  4777. (u32 *)&tdm_group_cfg.group_id);
  4778. if (rc) {
  4779. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  4780. __func__, "qcom,msm-cpudai-tdm-group-id");
  4781. goto rtn;
  4782. }
  4783. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  4784. __func__, tdm_group_cfg.group_id);
  4785. dev_info(&pdev->dev, "%s: dev_name: %s group_id: 0x%x\n",
  4786. __func__, dev_name(&pdev->dev), tdm_group_cfg.group_id);
  4787. rc = of_property_read_u32(pdev->dev.of_node,
  4788. "qcom,msm-cpudai-tdm-group-num-ports",
  4789. &num_tdm_group_ports);
  4790. if (rc) {
  4791. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  4792. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  4793. goto rtn;
  4794. }
  4795. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  4796. __func__, num_tdm_group_ports);
  4797. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  4798. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  4799. __func__, num_tdm_group_ports,
  4800. AFE_GROUP_DEVICE_NUM_PORTS);
  4801. rc = -EINVAL;
  4802. goto rtn;
  4803. }
  4804. port_id_array = of_get_property(pdev->dev.of_node,
  4805. "qcom,msm-cpudai-tdm-group-port-id",
  4806. &array_length);
  4807. if (port_id_array == NULL) {
  4808. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  4809. __func__);
  4810. rc = -EINVAL;
  4811. goto rtn;
  4812. }
  4813. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  4814. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  4815. __func__, array_length,
  4816. sizeof(uint32_t) * num_tdm_group_ports);
  4817. rc = -EINVAL;
  4818. goto rtn;
  4819. }
  4820. for (i = 0; i < num_tdm_group_ports; i++)
  4821. tdm_group_cfg.port_id[i] =
  4822. (u16)be32_to_cpu(port_id_array[i]);
  4823. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  4824. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  4825. tdm_group_cfg.port_id[i] =
  4826. AFE_PORT_INVALID;
  4827. /* extract tdm clk info into static */
  4828. rc = of_property_read_u32(pdev->dev.of_node,
  4829. "qcom,msm-cpudai-tdm-clk-rate",
  4830. &tdm_clk_set.clk_freq_in_hz);
  4831. if (rc) {
  4832. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  4833. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  4834. goto rtn;
  4835. }
  4836. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  4837. __func__, tdm_clk_set.clk_freq_in_hz);
  4838. /* initialize static tdm clk attribute to default value */
  4839. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  4840. /* extract tdm clk attribute into static */
  4841. if (of_find_property(pdev->dev.of_node,
  4842. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  4843. rc = of_property_read_u16(pdev->dev.of_node,
  4844. "qcom,msm-cpudai-tdm-clk-attribute",
  4845. &tdm_clk_set.clk_attri);
  4846. if (rc) {
  4847. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  4848. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  4849. goto rtn;
  4850. }
  4851. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  4852. __func__, tdm_clk_set.clk_attri);
  4853. } else
  4854. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  4855. /* extract tdm clk src master/slave info into static */
  4856. rc = of_property_read_u32(pdev->dev.of_node,
  4857. "qcom,msm-cpudai-tdm-clk-internal",
  4858. &clk_mode);
  4859. if (rc) {
  4860. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  4861. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  4862. goto rtn;
  4863. }
  4864. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  4865. __func__, clk_mode);
  4866. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  4867. &tdm_clk_set, clk_mode);
  4868. if (rc) {
  4869. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  4870. __func__, tdm_group_cfg.group_id);
  4871. goto rtn;
  4872. }
  4873. /* other initializations within device group */
  4874. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  4875. if (group_idx < 0) {
  4876. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  4877. __func__, tdm_group_cfg.group_id);
  4878. rc = -EINVAL;
  4879. goto rtn;
  4880. }
  4881. atomic_set(&tdm_group_ref[group_idx], 0);
  4882. /* probe child node info */
  4883. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4884. if (rc) {
  4885. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4886. __func__, rc);
  4887. goto rtn;
  4888. } else
  4889. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4890. rtn:
  4891. return rc;
  4892. }
  4893. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  4894. {
  4895. return 0;
  4896. }
  4897. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  4898. { .compatible = "qcom,msm-dai-tdm", },
  4899. {}
  4900. };
  4901. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  4902. static struct platform_driver msm_dai_tdm_q6 = {
  4903. .probe = msm_dai_tdm_q6_probe,
  4904. .remove = msm_dai_tdm_q6_remove,
  4905. .driver = {
  4906. .name = "msm-dai-tdm",
  4907. .owner = THIS_MODULE,
  4908. .of_match_table = msm_dai_tdm_dt_match,
  4909. },
  4910. };
  4911. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  4912. struct snd_ctl_elem_value *ucontrol)
  4913. {
  4914. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4915. int value = ucontrol->value.integer.value[0];
  4916. switch (value) {
  4917. case 0:
  4918. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  4919. break;
  4920. case 1:
  4921. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  4922. break;
  4923. case 2:
  4924. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  4925. break;
  4926. default:
  4927. pr_err("%s: data_format invalid\n", __func__);
  4928. break;
  4929. }
  4930. pr_debug("%s: data_format = %d\n",
  4931. __func__, dai_data->port_cfg.tdm.data_format);
  4932. return 0;
  4933. }
  4934. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  4935. struct snd_ctl_elem_value *ucontrol)
  4936. {
  4937. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4938. ucontrol->value.integer.value[0] =
  4939. dai_data->port_cfg.tdm.data_format;
  4940. pr_debug("%s: data_format = %d\n",
  4941. __func__, dai_data->port_cfg.tdm.data_format);
  4942. return 0;
  4943. }
  4944. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  4945. struct snd_ctl_elem_value *ucontrol)
  4946. {
  4947. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4948. int value = ucontrol->value.integer.value[0];
  4949. dai_data->port_cfg.custom_tdm_header.header_type = value;
  4950. pr_debug("%s: header_type = %d\n",
  4951. __func__,
  4952. dai_data->port_cfg.custom_tdm_header.header_type);
  4953. return 0;
  4954. }
  4955. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  4956. struct snd_ctl_elem_value *ucontrol)
  4957. {
  4958. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4959. ucontrol->value.integer.value[0] =
  4960. dai_data->port_cfg.custom_tdm_header.header_type;
  4961. pr_debug("%s: header_type = %d\n",
  4962. __func__,
  4963. dai_data->port_cfg.custom_tdm_header.header_type);
  4964. return 0;
  4965. }
  4966. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  4967. struct snd_ctl_elem_value *ucontrol)
  4968. {
  4969. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4970. int i = 0;
  4971. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  4972. dai_data->port_cfg.custom_tdm_header.header[i] =
  4973. (u16)ucontrol->value.integer.value[i];
  4974. pr_debug("%s: header #%d = 0x%x\n",
  4975. __func__, i,
  4976. dai_data->port_cfg.custom_tdm_header.header[i]);
  4977. }
  4978. return 0;
  4979. }
  4980. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  4981. struct snd_ctl_elem_value *ucontrol)
  4982. {
  4983. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4984. int i = 0;
  4985. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  4986. ucontrol->value.integer.value[i] =
  4987. dai_data->port_cfg.custom_tdm_header.header[i];
  4988. pr_debug("%s: header #%d = 0x%x\n",
  4989. __func__, i,
  4990. dai_data->port_cfg.custom_tdm_header.header[i]);
  4991. }
  4992. return 0;
  4993. }
  4994. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  4995. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  4996. msm_dai_q6_tdm_data_format_get,
  4997. msm_dai_q6_tdm_data_format_put),
  4998. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  4999. msm_dai_q6_tdm_data_format_get,
  5000. msm_dai_q6_tdm_data_format_put),
  5001. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  5002. msm_dai_q6_tdm_data_format_get,
  5003. msm_dai_q6_tdm_data_format_put),
  5004. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  5005. msm_dai_q6_tdm_data_format_get,
  5006. msm_dai_q6_tdm_data_format_put),
  5007. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  5008. msm_dai_q6_tdm_data_format_get,
  5009. msm_dai_q6_tdm_data_format_put),
  5010. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  5011. msm_dai_q6_tdm_data_format_get,
  5012. msm_dai_q6_tdm_data_format_put),
  5013. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  5014. msm_dai_q6_tdm_data_format_get,
  5015. msm_dai_q6_tdm_data_format_put),
  5016. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  5017. msm_dai_q6_tdm_data_format_get,
  5018. msm_dai_q6_tdm_data_format_put),
  5019. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  5020. msm_dai_q6_tdm_data_format_get,
  5021. msm_dai_q6_tdm_data_format_put),
  5022. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  5023. msm_dai_q6_tdm_data_format_get,
  5024. msm_dai_q6_tdm_data_format_put),
  5025. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  5026. msm_dai_q6_tdm_data_format_get,
  5027. msm_dai_q6_tdm_data_format_put),
  5028. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  5029. msm_dai_q6_tdm_data_format_get,
  5030. msm_dai_q6_tdm_data_format_put),
  5031. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  5032. msm_dai_q6_tdm_data_format_get,
  5033. msm_dai_q6_tdm_data_format_put),
  5034. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  5035. msm_dai_q6_tdm_data_format_get,
  5036. msm_dai_q6_tdm_data_format_put),
  5037. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  5038. msm_dai_q6_tdm_data_format_get,
  5039. msm_dai_q6_tdm_data_format_put),
  5040. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  5041. msm_dai_q6_tdm_data_format_get,
  5042. msm_dai_q6_tdm_data_format_put),
  5043. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  5044. msm_dai_q6_tdm_data_format_get,
  5045. msm_dai_q6_tdm_data_format_put),
  5046. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  5047. msm_dai_q6_tdm_data_format_get,
  5048. msm_dai_q6_tdm_data_format_put),
  5049. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  5050. msm_dai_q6_tdm_data_format_get,
  5051. msm_dai_q6_tdm_data_format_put),
  5052. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  5053. msm_dai_q6_tdm_data_format_get,
  5054. msm_dai_q6_tdm_data_format_put),
  5055. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  5056. msm_dai_q6_tdm_data_format_get,
  5057. msm_dai_q6_tdm_data_format_put),
  5058. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  5059. msm_dai_q6_tdm_data_format_get,
  5060. msm_dai_q6_tdm_data_format_put),
  5061. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  5062. msm_dai_q6_tdm_data_format_get,
  5063. msm_dai_q6_tdm_data_format_put),
  5064. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  5065. msm_dai_q6_tdm_data_format_get,
  5066. msm_dai_q6_tdm_data_format_put),
  5067. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  5068. msm_dai_q6_tdm_data_format_get,
  5069. msm_dai_q6_tdm_data_format_put),
  5070. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  5071. msm_dai_q6_tdm_data_format_get,
  5072. msm_dai_q6_tdm_data_format_put),
  5073. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  5074. msm_dai_q6_tdm_data_format_get,
  5075. msm_dai_q6_tdm_data_format_put),
  5076. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  5077. msm_dai_q6_tdm_data_format_get,
  5078. msm_dai_q6_tdm_data_format_put),
  5079. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  5080. msm_dai_q6_tdm_data_format_get,
  5081. msm_dai_q6_tdm_data_format_put),
  5082. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  5083. msm_dai_q6_tdm_data_format_get,
  5084. msm_dai_q6_tdm_data_format_put),
  5085. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  5086. msm_dai_q6_tdm_data_format_get,
  5087. msm_dai_q6_tdm_data_format_put),
  5088. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  5089. msm_dai_q6_tdm_data_format_get,
  5090. msm_dai_q6_tdm_data_format_put),
  5091. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5092. msm_dai_q6_tdm_data_format_get,
  5093. msm_dai_q6_tdm_data_format_put),
  5094. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5095. msm_dai_q6_tdm_data_format_get,
  5096. msm_dai_q6_tdm_data_format_put),
  5097. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5098. msm_dai_q6_tdm_data_format_get,
  5099. msm_dai_q6_tdm_data_format_put),
  5100. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5101. msm_dai_q6_tdm_data_format_get,
  5102. msm_dai_q6_tdm_data_format_put),
  5103. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5104. msm_dai_q6_tdm_data_format_get,
  5105. msm_dai_q6_tdm_data_format_put),
  5106. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5107. msm_dai_q6_tdm_data_format_get,
  5108. msm_dai_q6_tdm_data_format_put),
  5109. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5110. msm_dai_q6_tdm_data_format_get,
  5111. msm_dai_q6_tdm_data_format_put),
  5112. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5113. msm_dai_q6_tdm_data_format_get,
  5114. msm_dai_q6_tdm_data_format_put),
  5115. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5116. msm_dai_q6_tdm_data_format_get,
  5117. msm_dai_q6_tdm_data_format_put),
  5118. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5119. msm_dai_q6_tdm_data_format_get,
  5120. msm_dai_q6_tdm_data_format_put),
  5121. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5122. msm_dai_q6_tdm_data_format_get,
  5123. msm_dai_q6_tdm_data_format_put),
  5124. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5125. msm_dai_q6_tdm_data_format_get,
  5126. msm_dai_q6_tdm_data_format_put),
  5127. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5128. msm_dai_q6_tdm_data_format_get,
  5129. msm_dai_q6_tdm_data_format_put),
  5130. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5131. msm_dai_q6_tdm_data_format_get,
  5132. msm_dai_q6_tdm_data_format_put),
  5133. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5134. msm_dai_q6_tdm_data_format_get,
  5135. msm_dai_q6_tdm_data_format_put),
  5136. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5137. msm_dai_q6_tdm_data_format_get,
  5138. msm_dai_q6_tdm_data_format_put),
  5139. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5140. msm_dai_q6_tdm_data_format_get,
  5141. msm_dai_q6_tdm_data_format_put),
  5142. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5143. msm_dai_q6_tdm_data_format_get,
  5144. msm_dai_q6_tdm_data_format_put),
  5145. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5146. msm_dai_q6_tdm_data_format_get,
  5147. msm_dai_q6_tdm_data_format_put),
  5148. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5149. msm_dai_q6_tdm_data_format_get,
  5150. msm_dai_q6_tdm_data_format_put),
  5151. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5152. msm_dai_q6_tdm_data_format_get,
  5153. msm_dai_q6_tdm_data_format_put),
  5154. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5155. msm_dai_q6_tdm_data_format_get,
  5156. msm_dai_q6_tdm_data_format_put),
  5157. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5158. msm_dai_q6_tdm_data_format_get,
  5159. msm_dai_q6_tdm_data_format_put),
  5160. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5161. msm_dai_q6_tdm_data_format_get,
  5162. msm_dai_q6_tdm_data_format_put),
  5163. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5164. msm_dai_q6_tdm_data_format_get,
  5165. msm_dai_q6_tdm_data_format_put),
  5166. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5167. msm_dai_q6_tdm_data_format_get,
  5168. msm_dai_q6_tdm_data_format_put),
  5169. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5170. msm_dai_q6_tdm_data_format_get,
  5171. msm_dai_q6_tdm_data_format_put),
  5172. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5173. msm_dai_q6_tdm_data_format_get,
  5174. msm_dai_q6_tdm_data_format_put),
  5175. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5176. msm_dai_q6_tdm_data_format_get,
  5177. msm_dai_q6_tdm_data_format_put),
  5178. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5179. msm_dai_q6_tdm_data_format_get,
  5180. msm_dai_q6_tdm_data_format_put),
  5181. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5182. msm_dai_q6_tdm_data_format_get,
  5183. msm_dai_q6_tdm_data_format_put),
  5184. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5185. msm_dai_q6_tdm_data_format_get,
  5186. msm_dai_q6_tdm_data_format_put),
  5187. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  5188. msm_dai_q6_tdm_data_format_get,
  5189. msm_dai_q6_tdm_data_format_put),
  5190. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  5191. msm_dai_q6_tdm_data_format_get,
  5192. msm_dai_q6_tdm_data_format_put),
  5193. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  5194. msm_dai_q6_tdm_data_format_get,
  5195. msm_dai_q6_tdm_data_format_put),
  5196. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  5197. msm_dai_q6_tdm_data_format_get,
  5198. msm_dai_q6_tdm_data_format_put),
  5199. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  5200. msm_dai_q6_tdm_data_format_get,
  5201. msm_dai_q6_tdm_data_format_put),
  5202. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  5203. msm_dai_q6_tdm_data_format_get,
  5204. msm_dai_q6_tdm_data_format_put),
  5205. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  5206. msm_dai_q6_tdm_data_format_get,
  5207. msm_dai_q6_tdm_data_format_put),
  5208. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  5209. msm_dai_q6_tdm_data_format_get,
  5210. msm_dai_q6_tdm_data_format_put),
  5211. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  5212. msm_dai_q6_tdm_data_format_get,
  5213. msm_dai_q6_tdm_data_format_put),
  5214. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  5215. msm_dai_q6_tdm_data_format_get,
  5216. msm_dai_q6_tdm_data_format_put),
  5217. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  5218. msm_dai_q6_tdm_data_format_get,
  5219. msm_dai_q6_tdm_data_format_put),
  5220. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  5221. msm_dai_q6_tdm_data_format_get,
  5222. msm_dai_q6_tdm_data_format_put),
  5223. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  5224. msm_dai_q6_tdm_data_format_get,
  5225. msm_dai_q6_tdm_data_format_put),
  5226. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  5227. msm_dai_q6_tdm_data_format_get,
  5228. msm_dai_q6_tdm_data_format_put),
  5229. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  5230. msm_dai_q6_tdm_data_format_get,
  5231. msm_dai_q6_tdm_data_format_put),
  5232. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  5233. msm_dai_q6_tdm_data_format_get,
  5234. msm_dai_q6_tdm_data_format_put),
  5235. };
  5236. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  5237. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  5238. msm_dai_q6_tdm_header_type_get,
  5239. msm_dai_q6_tdm_header_type_put),
  5240. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  5241. msm_dai_q6_tdm_header_type_get,
  5242. msm_dai_q6_tdm_header_type_put),
  5243. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  5244. msm_dai_q6_tdm_header_type_get,
  5245. msm_dai_q6_tdm_header_type_put),
  5246. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  5247. msm_dai_q6_tdm_header_type_get,
  5248. msm_dai_q6_tdm_header_type_put),
  5249. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  5250. msm_dai_q6_tdm_header_type_get,
  5251. msm_dai_q6_tdm_header_type_put),
  5252. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  5253. msm_dai_q6_tdm_header_type_get,
  5254. msm_dai_q6_tdm_header_type_put),
  5255. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  5256. msm_dai_q6_tdm_header_type_get,
  5257. msm_dai_q6_tdm_header_type_put),
  5258. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  5259. msm_dai_q6_tdm_header_type_get,
  5260. msm_dai_q6_tdm_header_type_put),
  5261. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  5262. msm_dai_q6_tdm_header_type_get,
  5263. msm_dai_q6_tdm_header_type_put),
  5264. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  5265. msm_dai_q6_tdm_header_type_get,
  5266. msm_dai_q6_tdm_header_type_put),
  5267. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  5268. msm_dai_q6_tdm_header_type_get,
  5269. msm_dai_q6_tdm_header_type_put),
  5270. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  5271. msm_dai_q6_tdm_header_type_get,
  5272. msm_dai_q6_tdm_header_type_put),
  5273. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  5274. msm_dai_q6_tdm_header_type_get,
  5275. msm_dai_q6_tdm_header_type_put),
  5276. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  5277. msm_dai_q6_tdm_header_type_get,
  5278. msm_dai_q6_tdm_header_type_put),
  5279. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  5280. msm_dai_q6_tdm_header_type_get,
  5281. msm_dai_q6_tdm_header_type_put),
  5282. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  5283. msm_dai_q6_tdm_header_type_get,
  5284. msm_dai_q6_tdm_header_type_put),
  5285. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  5286. msm_dai_q6_tdm_header_type_get,
  5287. msm_dai_q6_tdm_header_type_put),
  5288. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  5289. msm_dai_q6_tdm_header_type_get,
  5290. msm_dai_q6_tdm_header_type_put),
  5291. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  5292. msm_dai_q6_tdm_header_type_get,
  5293. msm_dai_q6_tdm_header_type_put),
  5294. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  5295. msm_dai_q6_tdm_header_type_get,
  5296. msm_dai_q6_tdm_header_type_put),
  5297. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  5298. msm_dai_q6_tdm_header_type_get,
  5299. msm_dai_q6_tdm_header_type_put),
  5300. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  5301. msm_dai_q6_tdm_header_type_get,
  5302. msm_dai_q6_tdm_header_type_put),
  5303. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  5304. msm_dai_q6_tdm_header_type_get,
  5305. msm_dai_q6_tdm_header_type_put),
  5306. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  5307. msm_dai_q6_tdm_header_type_get,
  5308. msm_dai_q6_tdm_header_type_put),
  5309. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  5310. msm_dai_q6_tdm_header_type_get,
  5311. msm_dai_q6_tdm_header_type_put),
  5312. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  5313. msm_dai_q6_tdm_header_type_get,
  5314. msm_dai_q6_tdm_header_type_put),
  5315. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  5316. msm_dai_q6_tdm_header_type_get,
  5317. msm_dai_q6_tdm_header_type_put),
  5318. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  5319. msm_dai_q6_tdm_header_type_get,
  5320. msm_dai_q6_tdm_header_type_put),
  5321. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  5322. msm_dai_q6_tdm_header_type_get,
  5323. msm_dai_q6_tdm_header_type_put),
  5324. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  5325. msm_dai_q6_tdm_header_type_get,
  5326. msm_dai_q6_tdm_header_type_put),
  5327. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  5328. msm_dai_q6_tdm_header_type_get,
  5329. msm_dai_q6_tdm_header_type_put),
  5330. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  5331. msm_dai_q6_tdm_header_type_get,
  5332. msm_dai_q6_tdm_header_type_put),
  5333. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  5334. msm_dai_q6_tdm_header_type_get,
  5335. msm_dai_q6_tdm_header_type_put),
  5336. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  5337. msm_dai_q6_tdm_header_type_get,
  5338. msm_dai_q6_tdm_header_type_put),
  5339. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  5340. msm_dai_q6_tdm_header_type_get,
  5341. msm_dai_q6_tdm_header_type_put),
  5342. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  5343. msm_dai_q6_tdm_header_type_get,
  5344. msm_dai_q6_tdm_header_type_put),
  5345. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  5346. msm_dai_q6_tdm_header_type_get,
  5347. msm_dai_q6_tdm_header_type_put),
  5348. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  5349. msm_dai_q6_tdm_header_type_get,
  5350. msm_dai_q6_tdm_header_type_put),
  5351. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  5352. msm_dai_q6_tdm_header_type_get,
  5353. msm_dai_q6_tdm_header_type_put),
  5354. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  5355. msm_dai_q6_tdm_header_type_get,
  5356. msm_dai_q6_tdm_header_type_put),
  5357. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  5358. msm_dai_q6_tdm_header_type_get,
  5359. msm_dai_q6_tdm_header_type_put),
  5360. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  5361. msm_dai_q6_tdm_header_type_get,
  5362. msm_dai_q6_tdm_header_type_put),
  5363. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  5364. msm_dai_q6_tdm_header_type_get,
  5365. msm_dai_q6_tdm_header_type_put),
  5366. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  5367. msm_dai_q6_tdm_header_type_get,
  5368. msm_dai_q6_tdm_header_type_put),
  5369. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  5370. msm_dai_q6_tdm_header_type_get,
  5371. msm_dai_q6_tdm_header_type_put),
  5372. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  5373. msm_dai_q6_tdm_header_type_get,
  5374. msm_dai_q6_tdm_header_type_put),
  5375. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  5376. msm_dai_q6_tdm_header_type_get,
  5377. msm_dai_q6_tdm_header_type_put),
  5378. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  5379. msm_dai_q6_tdm_header_type_get,
  5380. msm_dai_q6_tdm_header_type_put),
  5381. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  5382. msm_dai_q6_tdm_header_type_get,
  5383. msm_dai_q6_tdm_header_type_put),
  5384. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  5385. msm_dai_q6_tdm_header_type_get,
  5386. msm_dai_q6_tdm_header_type_put),
  5387. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  5388. msm_dai_q6_tdm_header_type_get,
  5389. msm_dai_q6_tdm_header_type_put),
  5390. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  5391. msm_dai_q6_tdm_header_type_get,
  5392. msm_dai_q6_tdm_header_type_put),
  5393. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  5394. msm_dai_q6_tdm_header_type_get,
  5395. msm_dai_q6_tdm_header_type_put),
  5396. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  5397. msm_dai_q6_tdm_header_type_get,
  5398. msm_dai_q6_tdm_header_type_put),
  5399. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  5400. msm_dai_q6_tdm_header_type_get,
  5401. msm_dai_q6_tdm_header_type_put),
  5402. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  5403. msm_dai_q6_tdm_header_type_get,
  5404. msm_dai_q6_tdm_header_type_put),
  5405. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  5406. msm_dai_q6_tdm_header_type_get,
  5407. msm_dai_q6_tdm_header_type_put),
  5408. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  5409. msm_dai_q6_tdm_header_type_get,
  5410. msm_dai_q6_tdm_header_type_put),
  5411. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  5412. msm_dai_q6_tdm_header_type_get,
  5413. msm_dai_q6_tdm_header_type_put),
  5414. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  5415. msm_dai_q6_tdm_header_type_get,
  5416. msm_dai_q6_tdm_header_type_put),
  5417. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  5418. msm_dai_q6_tdm_header_type_get,
  5419. msm_dai_q6_tdm_header_type_put),
  5420. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  5421. msm_dai_q6_tdm_header_type_get,
  5422. msm_dai_q6_tdm_header_type_put),
  5423. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  5424. msm_dai_q6_tdm_header_type_get,
  5425. msm_dai_q6_tdm_header_type_put),
  5426. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  5427. msm_dai_q6_tdm_header_type_get,
  5428. msm_dai_q6_tdm_header_type_put),
  5429. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  5430. msm_dai_q6_tdm_header_type_get,
  5431. msm_dai_q6_tdm_header_type_put),
  5432. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  5433. msm_dai_q6_tdm_header_type_get,
  5434. msm_dai_q6_tdm_header_type_put),
  5435. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  5436. msm_dai_q6_tdm_header_type_get,
  5437. msm_dai_q6_tdm_header_type_put),
  5438. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  5439. msm_dai_q6_tdm_header_type_get,
  5440. msm_dai_q6_tdm_header_type_put),
  5441. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  5442. msm_dai_q6_tdm_header_type_get,
  5443. msm_dai_q6_tdm_header_type_put),
  5444. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  5445. msm_dai_q6_tdm_header_type_get,
  5446. msm_dai_q6_tdm_header_type_put),
  5447. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  5448. msm_dai_q6_tdm_header_type_get,
  5449. msm_dai_q6_tdm_header_type_put),
  5450. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  5451. msm_dai_q6_tdm_header_type_get,
  5452. msm_dai_q6_tdm_header_type_put),
  5453. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  5454. msm_dai_q6_tdm_header_type_get,
  5455. msm_dai_q6_tdm_header_type_put),
  5456. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  5457. msm_dai_q6_tdm_header_type_get,
  5458. msm_dai_q6_tdm_header_type_put),
  5459. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  5460. msm_dai_q6_tdm_header_type_get,
  5461. msm_dai_q6_tdm_header_type_put),
  5462. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  5463. msm_dai_q6_tdm_header_type_get,
  5464. msm_dai_q6_tdm_header_type_put),
  5465. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  5466. msm_dai_q6_tdm_header_type_get,
  5467. msm_dai_q6_tdm_header_type_put),
  5468. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  5469. msm_dai_q6_tdm_header_type_get,
  5470. msm_dai_q6_tdm_header_type_put),
  5471. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  5472. msm_dai_q6_tdm_header_type_get,
  5473. msm_dai_q6_tdm_header_type_put),
  5474. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  5475. msm_dai_q6_tdm_header_type_get,
  5476. msm_dai_q6_tdm_header_type_put),
  5477. };
  5478. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  5479. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  5480. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5481. msm_dai_q6_tdm_header_get,
  5482. msm_dai_q6_tdm_header_put),
  5483. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  5484. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5485. msm_dai_q6_tdm_header_get,
  5486. msm_dai_q6_tdm_header_put),
  5487. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  5488. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5489. msm_dai_q6_tdm_header_get,
  5490. msm_dai_q6_tdm_header_put),
  5491. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  5492. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5493. msm_dai_q6_tdm_header_get,
  5494. msm_dai_q6_tdm_header_put),
  5495. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  5496. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5497. msm_dai_q6_tdm_header_get,
  5498. msm_dai_q6_tdm_header_put),
  5499. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  5500. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5501. msm_dai_q6_tdm_header_get,
  5502. msm_dai_q6_tdm_header_put),
  5503. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  5504. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5505. msm_dai_q6_tdm_header_get,
  5506. msm_dai_q6_tdm_header_put),
  5507. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  5508. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5509. msm_dai_q6_tdm_header_get,
  5510. msm_dai_q6_tdm_header_put),
  5511. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  5512. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5513. msm_dai_q6_tdm_header_get,
  5514. msm_dai_q6_tdm_header_put),
  5515. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  5516. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5517. msm_dai_q6_tdm_header_get,
  5518. msm_dai_q6_tdm_header_put),
  5519. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  5520. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5521. msm_dai_q6_tdm_header_get,
  5522. msm_dai_q6_tdm_header_put),
  5523. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  5524. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5525. msm_dai_q6_tdm_header_get,
  5526. msm_dai_q6_tdm_header_put),
  5527. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  5528. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5529. msm_dai_q6_tdm_header_get,
  5530. msm_dai_q6_tdm_header_put),
  5531. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  5532. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5533. msm_dai_q6_tdm_header_get,
  5534. msm_dai_q6_tdm_header_put),
  5535. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  5536. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5537. msm_dai_q6_tdm_header_get,
  5538. msm_dai_q6_tdm_header_put),
  5539. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  5540. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5541. msm_dai_q6_tdm_header_get,
  5542. msm_dai_q6_tdm_header_put),
  5543. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  5544. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5545. msm_dai_q6_tdm_header_get,
  5546. msm_dai_q6_tdm_header_put),
  5547. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  5548. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5549. msm_dai_q6_tdm_header_get,
  5550. msm_dai_q6_tdm_header_put),
  5551. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  5552. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5553. msm_dai_q6_tdm_header_get,
  5554. msm_dai_q6_tdm_header_put),
  5555. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  5556. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5557. msm_dai_q6_tdm_header_get,
  5558. msm_dai_q6_tdm_header_put),
  5559. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  5560. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5561. msm_dai_q6_tdm_header_get,
  5562. msm_dai_q6_tdm_header_put),
  5563. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  5564. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5565. msm_dai_q6_tdm_header_get,
  5566. msm_dai_q6_tdm_header_put),
  5567. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  5568. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5569. msm_dai_q6_tdm_header_get,
  5570. msm_dai_q6_tdm_header_put),
  5571. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  5572. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5573. msm_dai_q6_tdm_header_get,
  5574. msm_dai_q6_tdm_header_put),
  5575. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  5576. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5577. msm_dai_q6_tdm_header_get,
  5578. msm_dai_q6_tdm_header_put),
  5579. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  5580. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5581. msm_dai_q6_tdm_header_get,
  5582. msm_dai_q6_tdm_header_put),
  5583. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  5584. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5585. msm_dai_q6_tdm_header_get,
  5586. msm_dai_q6_tdm_header_put),
  5587. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  5588. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5589. msm_dai_q6_tdm_header_get,
  5590. msm_dai_q6_tdm_header_put),
  5591. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  5592. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5593. msm_dai_q6_tdm_header_get,
  5594. msm_dai_q6_tdm_header_put),
  5595. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  5596. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5597. msm_dai_q6_tdm_header_get,
  5598. msm_dai_q6_tdm_header_put),
  5599. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  5600. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5601. msm_dai_q6_tdm_header_get,
  5602. msm_dai_q6_tdm_header_put),
  5603. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  5604. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5605. msm_dai_q6_tdm_header_get,
  5606. msm_dai_q6_tdm_header_put),
  5607. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  5608. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5609. msm_dai_q6_tdm_header_get,
  5610. msm_dai_q6_tdm_header_put),
  5611. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  5612. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5613. msm_dai_q6_tdm_header_get,
  5614. msm_dai_q6_tdm_header_put),
  5615. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  5616. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5617. msm_dai_q6_tdm_header_get,
  5618. msm_dai_q6_tdm_header_put),
  5619. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  5620. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5621. msm_dai_q6_tdm_header_get,
  5622. msm_dai_q6_tdm_header_put),
  5623. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  5624. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5625. msm_dai_q6_tdm_header_get,
  5626. msm_dai_q6_tdm_header_put),
  5627. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  5628. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5629. msm_dai_q6_tdm_header_get,
  5630. msm_dai_q6_tdm_header_put),
  5631. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  5632. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5633. msm_dai_q6_tdm_header_get,
  5634. msm_dai_q6_tdm_header_put),
  5635. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  5636. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5637. msm_dai_q6_tdm_header_get,
  5638. msm_dai_q6_tdm_header_put),
  5639. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  5640. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5641. msm_dai_q6_tdm_header_get,
  5642. msm_dai_q6_tdm_header_put),
  5643. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  5644. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5645. msm_dai_q6_tdm_header_get,
  5646. msm_dai_q6_tdm_header_put),
  5647. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  5648. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5649. msm_dai_q6_tdm_header_get,
  5650. msm_dai_q6_tdm_header_put),
  5651. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  5652. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5653. msm_dai_q6_tdm_header_get,
  5654. msm_dai_q6_tdm_header_put),
  5655. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  5656. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5657. msm_dai_q6_tdm_header_get,
  5658. msm_dai_q6_tdm_header_put),
  5659. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  5660. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5661. msm_dai_q6_tdm_header_get,
  5662. msm_dai_q6_tdm_header_put),
  5663. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  5664. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5665. msm_dai_q6_tdm_header_get,
  5666. msm_dai_q6_tdm_header_put),
  5667. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  5668. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5669. msm_dai_q6_tdm_header_get,
  5670. msm_dai_q6_tdm_header_put),
  5671. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  5672. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5673. msm_dai_q6_tdm_header_get,
  5674. msm_dai_q6_tdm_header_put),
  5675. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  5676. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5677. msm_dai_q6_tdm_header_get,
  5678. msm_dai_q6_tdm_header_put),
  5679. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  5680. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5681. msm_dai_q6_tdm_header_get,
  5682. msm_dai_q6_tdm_header_put),
  5683. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  5684. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5685. msm_dai_q6_tdm_header_get,
  5686. msm_dai_q6_tdm_header_put),
  5687. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  5688. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5689. msm_dai_q6_tdm_header_get,
  5690. msm_dai_q6_tdm_header_put),
  5691. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  5692. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5693. msm_dai_q6_tdm_header_get,
  5694. msm_dai_q6_tdm_header_put),
  5695. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  5696. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5697. msm_dai_q6_tdm_header_get,
  5698. msm_dai_q6_tdm_header_put),
  5699. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  5700. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5701. msm_dai_q6_tdm_header_get,
  5702. msm_dai_q6_tdm_header_put),
  5703. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  5704. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5705. msm_dai_q6_tdm_header_get,
  5706. msm_dai_q6_tdm_header_put),
  5707. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  5708. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5709. msm_dai_q6_tdm_header_get,
  5710. msm_dai_q6_tdm_header_put),
  5711. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  5712. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5713. msm_dai_q6_tdm_header_get,
  5714. msm_dai_q6_tdm_header_put),
  5715. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  5716. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5717. msm_dai_q6_tdm_header_get,
  5718. msm_dai_q6_tdm_header_put),
  5719. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  5720. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5721. msm_dai_q6_tdm_header_get,
  5722. msm_dai_q6_tdm_header_put),
  5723. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  5724. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5725. msm_dai_q6_tdm_header_get,
  5726. msm_dai_q6_tdm_header_put),
  5727. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  5728. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5729. msm_dai_q6_tdm_header_get,
  5730. msm_dai_q6_tdm_header_put),
  5731. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  5732. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5733. msm_dai_q6_tdm_header_get,
  5734. msm_dai_q6_tdm_header_put),
  5735. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  5736. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5737. msm_dai_q6_tdm_header_get,
  5738. msm_dai_q6_tdm_header_put),
  5739. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  5740. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5741. msm_dai_q6_tdm_header_get,
  5742. msm_dai_q6_tdm_header_put),
  5743. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  5744. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5745. msm_dai_q6_tdm_header_get,
  5746. msm_dai_q6_tdm_header_put),
  5747. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  5748. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5749. msm_dai_q6_tdm_header_get,
  5750. msm_dai_q6_tdm_header_put),
  5751. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  5752. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5753. msm_dai_q6_tdm_header_get,
  5754. msm_dai_q6_tdm_header_put),
  5755. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  5756. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5757. msm_dai_q6_tdm_header_get,
  5758. msm_dai_q6_tdm_header_put),
  5759. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  5760. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5761. msm_dai_q6_tdm_header_get,
  5762. msm_dai_q6_tdm_header_put),
  5763. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  5764. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5765. msm_dai_q6_tdm_header_get,
  5766. msm_dai_q6_tdm_header_put),
  5767. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  5768. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5769. msm_dai_q6_tdm_header_get,
  5770. msm_dai_q6_tdm_header_put),
  5771. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  5772. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5773. msm_dai_q6_tdm_header_get,
  5774. msm_dai_q6_tdm_header_put),
  5775. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  5776. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5777. msm_dai_q6_tdm_header_get,
  5778. msm_dai_q6_tdm_header_put),
  5779. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  5780. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5781. msm_dai_q6_tdm_header_get,
  5782. msm_dai_q6_tdm_header_put),
  5783. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  5784. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5785. msm_dai_q6_tdm_header_get,
  5786. msm_dai_q6_tdm_header_put),
  5787. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  5788. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5789. msm_dai_q6_tdm_header_get,
  5790. msm_dai_q6_tdm_header_put),
  5791. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  5792. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5793. msm_dai_q6_tdm_header_get,
  5794. msm_dai_q6_tdm_header_put),
  5795. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  5796. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5797. msm_dai_q6_tdm_header_get,
  5798. msm_dai_q6_tdm_header_put),
  5799. };
  5800. static int msm_dai_q6_tdm_set_clk(
  5801. struct msm_dai_q6_tdm_dai_data *dai_data,
  5802. u16 port_id, bool enable)
  5803. {
  5804. int rc = 0;
  5805. dai_data->clk_set.enable = enable;
  5806. rc = afe_set_lpass_clock_v2(port_id,
  5807. &dai_data->clk_set);
  5808. if (rc < 0)
  5809. pr_err("%s: afe lpass clock failed, err:%d\n",
  5810. __func__, rc);
  5811. return rc;
  5812. }
  5813. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  5814. {
  5815. int rc = 0;
  5816. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  5817. dev_get_drvdata(dai->dev);
  5818. struct snd_kcontrol *data_format_kcontrol = NULL;
  5819. struct snd_kcontrol *header_type_kcontrol = NULL;
  5820. struct snd_kcontrol *header_kcontrol = NULL;
  5821. int port_idx = 0;
  5822. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  5823. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  5824. const struct snd_kcontrol_new *header_ctrl = NULL;
  5825. msm_dai_q6_set_dai_id(dai);
  5826. port_idx = msm_dai_q6_get_port_idx(dai->id);
  5827. if (port_idx < 0) {
  5828. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  5829. __func__, dai->id);
  5830. rc = -EINVAL;
  5831. goto rtn;
  5832. }
  5833. data_format_ctrl =
  5834. &tdm_config_controls_data_format[port_idx];
  5835. header_type_ctrl =
  5836. &tdm_config_controls_header_type[port_idx];
  5837. header_ctrl =
  5838. &tdm_config_controls_header[port_idx];
  5839. if (data_format_ctrl) {
  5840. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  5841. tdm_dai_data);
  5842. rc = snd_ctl_add(dai->component->card->snd_card,
  5843. data_format_kcontrol);
  5844. if (rc < 0) {
  5845. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  5846. __func__, dai->name);
  5847. goto rtn;
  5848. }
  5849. }
  5850. if (header_type_ctrl) {
  5851. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  5852. tdm_dai_data);
  5853. rc = snd_ctl_add(dai->component->card->snd_card,
  5854. header_type_kcontrol);
  5855. if (rc < 0) {
  5856. if (data_format_kcontrol)
  5857. snd_ctl_remove(dai->component->card->snd_card,
  5858. data_format_kcontrol);
  5859. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  5860. __func__, dai->name);
  5861. goto rtn;
  5862. }
  5863. }
  5864. if (header_ctrl) {
  5865. header_kcontrol = snd_ctl_new1(header_ctrl,
  5866. tdm_dai_data);
  5867. rc = snd_ctl_add(dai->component->card->snd_card,
  5868. header_kcontrol);
  5869. if (rc < 0) {
  5870. if (header_type_kcontrol)
  5871. snd_ctl_remove(dai->component->card->snd_card,
  5872. header_type_kcontrol);
  5873. if (data_format_kcontrol)
  5874. snd_ctl_remove(dai->component->card->snd_card,
  5875. data_format_kcontrol);
  5876. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  5877. __func__, dai->name);
  5878. goto rtn;
  5879. }
  5880. }
  5881. rc = msm_dai_q6_dai_add_route(dai);
  5882. rtn:
  5883. return rc;
  5884. }
  5885. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  5886. {
  5887. int rc = 0;
  5888. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  5889. dev_get_drvdata(dai->dev);
  5890. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  5891. int group_idx = 0;
  5892. atomic_t *group_ref = NULL;
  5893. group_idx = msm_dai_q6_get_group_idx(dai->id);
  5894. if (group_idx < 0) {
  5895. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  5896. __func__, dai->id);
  5897. return -EINVAL;
  5898. }
  5899. group_ref = &tdm_group_ref[group_idx];
  5900. /* If AFE port is still up, close it */
  5901. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  5902. rc = afe_close(dai->id); /* can block */
  5903. if (rc < 0) {
  5904. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  5905. __func__, dai->id);
  5906. }
  5907. atomic_dec(group_ref);
  5908. clear_bit(STATUS_PORT_STARTED,
  5909. tdm_dai_data->status_mask);
  5910. if (atomic_read(group_ref) == 0) {
  5911. rc = afe_port_group_enable(group_id,
  5912. NULL, false);
  5913. if (rc < 0) {
  5914. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  5915. group_id);
  5916. }
  5917. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  5918. dai->id, false);
  5919. if (rc < 0) {
  5920. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  5921. __func__, dai->id);
  5922. }
  5923. }
  5924. }
  5925. return 0;
  5926. }
  5927. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  5928. unsigned int tx_mask,
  5929. unsigned int rx_mask,
  5930. int slots, int slot_width)
  5931. {
  5932. int rc = 0;
  5933. struct msm_dai_q6_tdm_dai_data *dai_data =
  5934. dev_get_drvdata(dai->dev);
  5935. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  5936. &dai_data->group_cfg.tdm_cfg;
  5937. unsigned int cap_mask;
  5938. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  5939. /* HW only supports 16 and 32 bit slot width configuration */
  5940. if ((slot_width != 16) && (slot_width != 32)) {
  5941. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  5942. __func__, slot_width);
  5943. return -EINVAL;
  5944. }
  5945. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  5946. switch (slots) {
  5947. case 2:
  5948. cap_mask = 0x03;
  5949. break;
  5950. case 4:
  5951. cap_mask = 0x0F;
  5952. break;
  5953. case 8:
  5954. cap_mask = 0xFF;
  5955. break;
  5956. case 16:
  5957. cap_mask = 0xFFFF;
  5958. break;
  5959. default:
  5960. dev_err(dai->dev, "%s: invalid slots %d\n",
  5961. __func__, slots);
  5962. return -EINVAL;
  5963. }
  5964. switch (dai->id) {
  5965. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5966. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  5967. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  5968. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  5969. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  5970. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  5971. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  5972. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  5973. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5974. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  5975. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  5976. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  5977. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  5978. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  5979. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  5980. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  5981. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5982. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  5983. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  5984. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  5985. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  5986. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  5987. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  5988. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  5989. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5990. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  5991. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  5992. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  5993. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  5994. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  5995. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  5996. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  5997. case AFE_PORT_ID_QUINARY_TDM_RX:
  5998. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  5999. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  6000. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  6001. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  6002. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  6003. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  6004. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  6005. tdm_group->nslots_per_frame = slots;
  6006. tdm_group->slot_width = slot_width;
  6007. tdm_group->slot_mask = rx_mask & cap_mask;
  6008. break;
  6009. case AFE_PORT_ID_PRIMARY_TDM_TX:
  6010. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6011. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6012. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6013. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6014. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6015. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6016. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6017. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6018. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6019. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6020. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6021. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6022. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6023. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6024. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6025. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6026. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6027. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6028. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6029. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6030. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6031. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6032. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6033. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6034. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6035. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6036. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6037. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6038. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6039. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6040. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6041. case AFE_PORT_ID_QUINARY_TDM_TX:
  6042. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6043. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6044. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6045. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6046. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6047. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6048. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6049. tdm_group->nslots_per_frame = slots;
  6050. tdm_group->slot_width = slot_width;
  6051. tdm_group->slot_mask = tx_mask & cap_mask;
  6052. break;
  6053. default:
  6054. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6055. __func__, dai->id);
  6056. return -EINVAL;
  6057. }
  6058. return rc;
  6059. }
  6060. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  6061. int clk_id, unsigned int freq, int dir)
  6062. {
  6063. struct msm_dai_q6_tdm_dai_data *dai_data =
  6064. dev_get_drvdata(dai->dev);
  6065. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  6066. (dai->id <= AFE_PORT_ID_QUINARY_TDM_TX_7)) {
  6067. dai_data->clk_set.clk_freq_in_hz = freq;
  6068. } else {
  6069. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6070. __func__, dai->id);
  6071. return -EINVAL;
  6072. }
  6073. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  6074. __func__, dai->id, freq);
  6075. return 0;
  6076. }
  6077. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  6078. unsigned int tx_num, unsigned int *tx_slot,
  6079. unsigned int rx_num, unsigned int *rx_slot)
  6080. {
  6081. int rc = 0;
  6082. struct msm_dai_q6_tdm_dai_data *dai_data =
  6083. dev_get_drvdata(dai->dev);
  6084. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6085. &dai_data->port_cfg.slot_mapping;
  6086. int i = 0;
  6087. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  6088. switch (dai->id) {
  6089. case AFE_PORT_ID_PRIMARY_TDM_RX:
  6090. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  6091. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  6092. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  6093. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  6094. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  6095. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  6096. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  6097. case AFE_PORT_ID_SECONDARY_TDM_RX:
  6098. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  6099. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  6100. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  6101. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  6102. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  6103. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  6104. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  6105. case AFE_PORT_ID_TERTIARY_TDM_RX:
  6106. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  6107. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  6108. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  6109. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  6110. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  6111. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  6112. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  6113. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  6114. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  6115. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  6116. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  6117. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  6118. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  6119. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  6120. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  6121. case AFE_PORT_ID_QUINARY_TDM_RX:
  6122. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  6123. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  6124. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  6125. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  6126. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  6127. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  6128. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  6129. if (!rx_slot) {
  6130. dev_err(dai->dev, "%s: rx slot not found\n", __func__);
  6131. return -EINVAL;
  6132. }
  6133. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6134. dev_err(dai->dev, "%s: invalid rx num %d\n", __func__,
  6135. rx_num);
  6136. return -EINVAL;
  6137. }
  6138. for (i = 0; i < rx_num; i++)
  6139. slot_mapping->offset[i] = rx_slot[i];
  6140. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6141. slot_mapping->offset[i] =
  6142. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6143. slot_mapping->num_channel = rx_num;
  6144. break;
  6145. case AFE_PORT_ID_PRIMARY_TDM_TX:
  6146. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6147. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6148. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6149. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6150. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6151. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6152. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6153. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6154. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6155. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6156. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6157. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6158. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6159. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6160. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6161. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6162. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6163. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6164. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6165. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6166. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6167. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6168. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6169. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6170. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6171. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6172. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6173. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6174. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6175. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6176. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6177. case AFE_PORT_ID_QUINARY_TDM_TX:
  6178. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6179. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6180. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6181. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6182. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6183. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6184. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6185. if (!tx_slot) {
  6186. dev_err(dai->dev, "%s: tx slot not found\n", __func__);
  6187. return -EINVAL;
  6188. }
  6189. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6190. dev_err(dai->dev, "%s: invalid tx num %d\n", __func__,
  6191. tx_num);
  6192. return -EINVAL;
  6193. }
  6194. for (i = 0; i < tx_num; i++)
  6195. slot_mapping->offset[i] = tx_slot[i];
  6196. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6197. slot_mapping->offset[i] =
  6198. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6199. slot_mapping->num_channel = tx_num;
  6200. break;
  6201. default:
  6202. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6203. __func__, dai->id);
  6204. return -EINVAL;
  6205. }
  6206. return rc;
  6207. }
  6208. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  6209. struct snd_pcm_hw_params *params,
  6210. struct snd_soc_dai *dai)
  6211. {
  6212. struct msm_dai_q6_tdm_dai_data *dai_data =
  6213. dev_get_drvdata(dai->dev);
  6214. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  6215. &dai_data->group_cfg.tdm_cfg;
  6216. struct afe_param_id_tdm_cfg *tdm =
  6217. &dai_data->port_cfg.tdm;
  6218. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6219. &dai_data->port_cfg.slot_mapping;
  6220. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  6221. &dai_data->port_cfg.custom_tdm_header;
  6222. pr_debug("%s: dev_name: %s\n",
  6223. __func__, dev_name(dai->dev));
  6224. if ((params_channels(params) == 0) ||
  6225. (params_channels(params) > 8)) {
  6226. dev_err(dai->dev, "%s: invalid param channels %d\n",
  6227. __func__, params_channels(params));
  6228. return -EINVAL;
  6229. }
  6230. switch (params_format(params)) {
  6231. case SNDRV_PCM_FORMAT_S16_LE:
  6232. dai_data->bitwidth = 16;
  6233. break;
  6234. case SNDRV_PCM_FORMAT_S24_LE:
  6235. case SNDRV_PCM_FORMAT_S24_3LE:
  6236. dai_data->bitwidth = 24;
  6237. break;
  6238. case SNDRV_PCM_FORMAT_S32_LE:
  6239. dai_data->bitwidth = 32;
  6240. break;
  6241. default:
  6242. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  6243. __func__, params_format(params));
  6244. return -EINVAL;
  6245. }
  6246. dai_data->channels = params_channels(params);
  6247. dai_data->rate = params_rate(params);
  6248. /*
  6249. * update tdm group config param
  6250. * NOTE: group config is set to the same as slot config.
  6251. */
  6252. tdm_group->bit_width = tdm_group->slot_width;
  6253. tdm_group->num_channels = tdm_group->nslots_per_frame;
  6254. tdm_group->sample_rate = dai_data->rate;
  6255. pr_debug("%s: TDM GROUP:\n"
  6256. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6257. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  6258. __func__,
  6259. tdm_group->num_channels,
  6260. tdm_group->sample_rate,
  6261. tdm_group->bit_width,
  6262. tdm_group->nslots_per_frame,
  6263. tdm_group->slot_width,
  6264. tdm_group->slot_mask);
  6265. pr_debug("%s: TDM GROUP:\n"
  6266. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  6267. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  6268. __func__,
  6269. tdm_group->port_id[0],
  6270. tdm_group->port_id[1],
  6271. tdm_group->port_id[2],
  6272. tdm_group->port_id[3],
  6273. tdm_group->port_id[4],
  6274. tdm_group->port_id[5],
  6275. tdm_group->port_id[6],
  6276. tdm_group->port_id[7]);
  6277. /*
  6278. * update tdm config param
  6279. * NOTE: channels/rate/bitwidth are per stream property
  6280. */
  6281. tdm->num_channels = dai_data->channels;
  6282. tdm->sample_rate = dai_data->rate;
  6283. tdm->bit_width = dai_data->bitwidth;
  6284. /*
  6285. * port slot config is the same as group slot config
  6286. * port slot mask should be set according to offset
  6287. */
  6288. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  6289. tdm->slot_width = tdm_group->slot_width;
  6290. tdm->slot_mask = tdm_group->slot_mask;
  6291. pr_debug("%s: TDM:\n"
  6292. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6293. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  6294. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  6295. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  6296. __func__,
  6297. tdm->num_channels,
  6298. tdm->sample_rate,
  6299. tdm->bit_width,
  6300. tdm->nslots_per_frame,
  6301. tdm->slot_width,
  6302. tdm->slot_mask,
  6303. tdm->data_format,
  6304. tdm->sync_mode,
  6305. tdm->sync_src,
  6306. tdm->ctrl_data_out_enable,
  6307. tdm->ctrl_invert_sync_pulse,
  6308. tdm->ctrl_sync_data_delay);
  6309. /*
  6310. * update slot mapping config param
  6311. * NOTE: channels/rate/bitwidth are per stream property
  6312. */
  6313. slot_mapping->bitwidth = dai_data->bitwidth;
  6314. pr_debug("%s: SLOT MAPPING:\n"
  6315. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  6316. __func__,
  6317. slot_mapping->num_channel,
  6318. slot_mapping->bitwidth,
  6319. slot_mapping->data_align_type);
  6320. pr_debug("%s: SLOT MAPPING:\n"
  6321. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  6322. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  6323. __func__,
  6324. slot_mapping->offset[0],
  6325. slot_mapping->offset[1],
  6326. slot_mapping->offset[2],
  6327. slot_mapping->offset[3],
  6328. slot_mapping->offset[4],
  6329. slot_mapping->offset[5],
  6330. slot_mapping->offset[6],
  6331. slot_mapping->offset[7]);
  6332. /*
  6333. * update custom header config param
  6334. * NOTE: channels/rate/bitwidth are per playback stream property.
  6335. * custom tdm header only applicable to playback stream.
  6336. */
  6337. if (custom_tdm_header->header_type !=
  6338. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  6339. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6340. "start_offset=0x%x header_width=%d\n"
  6341. "num_frame_repeat=%d header_type=0x%x\n",
  6342. __func__,
  6343. custom_tdm_header->start_offset,
  6344. custom_tdm_header->header_width,
  6345. custom_tdm_header->num_frame_repeat,
  6346. custom_tdm_header->header_type);
  6347. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6348. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  6349. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  6350. __func__,
  6351. custom_tdm_header->header[0],
  6352. custom_tdm_header->header[1],
  6353. custom_tdm_header->header[2],
  6354. custom_tdm_header->header[3],
  6355. custom_tdm_header->header[4],
  6356. custom_tdm_header->header[5],
  6357. custom_tdm_header->header[6],
  6358. custom_tdm_header->header[7]);
  6359. }
  6360. return 0;
  6361. }
  6362. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  6363. struct snd_soc_dai *dai)
  6364. {
  6365. int rc = 0;
  6366. struct msm_dai_q6_tdm_dai_data *dai_data =
  6367. dev_get_drvdata(dai->dev);
  6368. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  6369. int group_idx = 0;
  6370. atomic_t *group_ref = NULL;
  6371. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6372. if (group_idx < 0) {
  6373. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6374. __func__, dai->id);
  6375. return -EINVAL;
  6376. }
  6377. mutex_lock(&tdm_mutex);
  6378. group_ref = &tdm_group_ref[group_idx];
  6379. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6380. /* PORT START should be set if prepare called
  6381. * in active state.
  6382. */
  6383. if (atomic_read(group_ref) == 0) {
  6384. /* TX and RX share the same clk.
  6385. * AFE clk is enabled per group to simplify the logic.
  6386. * DSP will monitor the clk count.
  6387. */
  6388. rc = msm_dai_q6_tdm_set_clk(dai_data,
  6389. dai->id, true);
  6390. if (rc < 0) {
  6391. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  6392. __func__, dai->id);
  6393. goto rtn;
  6394. }
  6395. /*
  6396. * if only one port, don't do group enable as there
  6397. * is no group need for only one port
  6398. */
  6399. if (dai_data->num_group_ports > 1) {
  6400. rc = afe_port_group_enable(group_id,
  6401. &dai_data->group_cfg, true);
  6402. if (rc < 0) {
  6403. dev_err(dai->dev,
  6404. "%s: fail to enable AFE group 0x%x\n",
  6405. __func__, group_id);
  6406. goto rtn;
  6407. }
  6408. }
  6409. }
  6410. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  6411. dai_data->rate, dai_data->num_group_ports);
  6412. if (rc < 0) {
  6413. if (atomic_read(group_ref) == 0) {
  6414. afe_port_group_enable(group_id,
  6415. NULL, false);
  6416. msm_dai_q6_tdm_set_clk(dai_data,
  6417. dai->id, false);
  6418. }
  6419. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  6420. __func__, dai->id);
  6421. } else {
  6422. set_bit(STATUS_PORT_STARTED,
  6423. dai_data->status_mask);
  6424. atomic_inc(group_ref);
  6425. }
  6426. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  6427. /* NOTE: AFE should error out if HW resource contention */
  6428. }
  6429. rtn:
  6430. mutex_unlock(&tdm_mutex);
  6431. return rc;
  6432. }
  6433. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  6434. struct snd_soc_dai *dai)
  6435. {
  6436. int rc = 0;
  6437. struct msm_dai_q6_tdm_dai_data *dai_data =
  6438. dev_get_drvdata(dai->dev);
  6439. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  6440. int group_idx = 0;
  6441. atomic_t *group_ref = NULL;
  6442. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6443. if (group_idx < 0) {
  6444. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6445. __func__, dai->id);
  6446. return;
  6447. }
  6448. mutex_lock(&tdm_mutex);
  6449. group_ref = &tdm_group_ref[group_idx];
  6450. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6451. rc = afe_close(dai->id);
  6452. if (rc < 0) {
  6453. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  6454. __func__, dai->id);
  6455. }
  6456. atomic_dec(group_ref);
  6457. clear_bit(STATUS_PORT_STARTED,
  6458. dai_data->status_mask);
  6459. if (atomic_read(group_ref) == 0) {
  6460. rc = afe_port_group_enable(group_id,
  6461. NULL, false);
  6462. if (rc < 0) {
  6463. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  6464. __func__, group_id);
  6465. }
  6466. rc = msm_dai_q6_tdm_set_clk(dai_data,
  6467. dai->id, false);
  6468. if (rc < 0) {
  6469. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  6470. __func__, dai->id);
  6471. }
  6472. }
  6473. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  6474. /* NOTE: AFE should error out if HW resource contention */
  6475. }
  6476. mutex_unlock(&tdm_mutex);
  6477. }
  6478. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  6479. .prepare = msm_dai_q6_tdm_prepare,
  6480. .hw_params = msm_dai_q6_tdm_hw_params,
  6481. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  6482. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  6483. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  6484. .shutdown = msm_dai_q6_tdm_shutdown,
  6485. };
  6486. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  6487. {
  6488. .playback = {
  6489. .stream_name = "Primary TDM0 Playback",
  6490. .aif_name = "PRI_TDM_RX_0",
  6491. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6492. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6493. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6494. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6495. SNDRV_PCM_FMTBIT_S24_LE |
  6496. SNDRV_PCM_FMTBIT_S32_LE,
  6497. .channels_min = 1,
  6498. .channels_max = 8,
  6499. .rate_min = 8000,
  6500. .rate_max = 352800,
  6501. },
  6502. .ops = &msm_dai_q6_tdm_ops,
  6503. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  6504. .probe = msm_dai_q6_dai_tdm_probe,
  6505. .remove = msm_dai_q6_dai_tdm_remove,
  6506. },
  6507. {
  6508. .playback = {
  6509. .stream_name = "Primary TDM1 Playback",
  6510. .aif_name = "PRI_TDM_RX_1",
  6511. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6512. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6513. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6514. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6515. SNDRV_PCM_FMTBIT_S24_LE |
  6516. SNDRV_PCM_FMTBIT_S32_LE,
  6517. .channels_min = 1,
  6518. .channels_max = 8,
  6519. .rate_min = 8000,
  6520. .rate_max = 352800,
  6521. },
  6522. .ops = &msm_dai_q6_tdm_ops,
  6523. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  6524. .probe = msm_dai_q6_dai_tdm_probe,
  6525. .remove = msm_dai_q6_dai_tdm_remove,
  6526. },
  6527. {
  6528. .playback = {
  6529. .stream_name = "Primary TDM2 Playback",
  6530. .aif_name = "PRI_TDM_RX_2",
  6531. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6532. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6533. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6534. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6535. SNDRV_PCM_FMTBIT_S24_LE |
  6536. SNDRV_PCM_FMTBIT_S32_LE,
  6537. .channels_min = 1,
  6538. .channels_max = 8,
  6539. .rate_min = 8000,
  6540. .rate_max = 352800,
  6541. },
  6542. .ops = &msm_dai_q6_tdm_ops,
  6543. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  6544. .probe = msm_dai_q6_dai_tdm_probe,
  6545. .remove = msm_dai_q6_dai_tdm_remove,
  6546. },
  6547. {
  6548. .playback = {
  6549. .stream_name = "Primary TDM3 Playback",
  6550. .aif_name = "PRI_TDM_RX_3",
  6551. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6552. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6553. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6554. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6555. SNDRV_PCM_FMTBIT_S24_LE |
  6556. SNDRV_PCM_FMTBIT_S32_LE,
  6557. .channels_min = 1,
  6558. .channels_max = 8,
  6559. .rate_min = 8000,
  6560. .rate_max = 352800,
  6561. },
  6562. .ops = &msm_dai_q6_tdm_ops,
  6563. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  6564. .probe = msm_dai_q6_dai_tdm_probe,
  6565. .remove = msm_dai_q6_dai_tdm_remove,
  6566. },
  6567. {
  6568. .playback = {
  6569. .stream_name = "Primary TDM4 Playback",
  6570. .aif_name = "PRI_TDM_RX_4",
  6571. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6572. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6573. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6574. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6575. SNDRV_PCM_FMTBIT_S24_LE |
  6576. SNDRV_PCM_FMTBIT_S32_LE,
  6577. .channels_min = 1,
  6578. .channels_max = 8,
  6579. .rate_min = 8000,
  6580. .rate_max = 352800,
  6581. },
  6582. .ops = &msm_dai_q6_tdm_ops,
  6583. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  6584. .probe = msm_dai_q6_dai_tdm_probe,
  6585. .remove = msm_dai_q6_dai_tdm_remove,
  6586. },
  6587. {
  6588. .playback = {
  6589. .stream_name = "Primary TDM5 Playback",
  6590. .aif_name = "PRI_TDM_RX_5",
  6591. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6592. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6593. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6594. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6595. SNDRV_PCM_FMTBIT_S24_LE |
  6596. SNDRV_PCM_FMTBIT_S32_LE,
  6597. .channels_min = 1,
  6598. .channels_max = 8,
  6599. .rate_min = 8000,
  6600. .rate_max = 352800,
  6601. },
  6602. .ops = &msm_dai_q6_tdm_ops,
  6603. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  6604. .probe = msm_dai_q6_dai_tdm_probe,
  6605. .remove = msm_dai_q6_dai_tdm_remove,
  6606. },
  6607. {
  6608. .playback = {
  6609. .stream_name = "Primary TDM6 Playback",
  6610. .aif_name = "PRI_TDM_RX_6",
  6611. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6612. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6613. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6614. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6615. SNDRV_PCM_FMTBIT_S24_LE |
  6616. SNDRV_PCM_FMTBIT_S32_LE,
  6617. .channels_min = 1,
  6618. .channels_max = 8,
  6619. .rate_min = 8000,
  6620. .rate_max = 352800,
  6621. },
  6622. .ops = &msm_dai_q6_tdm_ops,
  6623. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  6624. .probe = msm_dai_q6_dai_tdm_probe,
  6625. .remove = msm_dai_q6_dai_tdm_remove,
  6626. },
  6627. {
  6628. .playback = {
  6629. .stream_name = "Primary TDM7 Playback",
  6630. .aif_name = "PRI_TDM_RX_7",
  6631. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6632. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6633. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6634. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6635. SNDRV_PCM_FMTBIT_S24_LE |
  6636. SNDRV_PCM_FMTBIT_S32_LE,
  6637. .channels_min = 1,
  6638. .channels_max = 8,
  6639. .rate_min = 8000,
  6640. .rate_max = 352800,
  6641. },
  6642. .ops = &msm_dai_q6_tdm_ops,
  6643. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  6644. .probe = msm_dai_q6_dai_tdm_probe,
  6645. .remove = msm_dai_q6_dai_tdm_remove,
  6646. },
  6647. {
  6648. .capture = {
  6649. .stream_name = "Primary TDM0 Capture",
  6650. .aif_name = "PRI_TDM_TX_0",
  6651. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6652. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6653. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6654. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6655. SNDRV_PCM_FMTBIT_S24_LE |
  6656. SNDRV_PCM_FMTBIT_S32_LE,
  6657. .channels_min = 1,
  6658. .channels_max = 8,
  6659. .rate_min = 8000,
  6660. .rate_max = 352800,
  6661. },
  6662. .ops = &msm_dai_q6_tdm_ops,
  6663. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  6664. .probe = msm_dai_q6_dai_tdm_probe,
  6665. .remove = msm_dai_q6_dai_tdm_remove,
  6666. },
  6667. {
  6668. .capture = {
  6669. .stream_name = "Primary TDM1 Capture",
  6670. .aif_name = "PRI_TDM_TX_1",
  6671. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6672. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6673. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6674. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6675. SNDRV_PCM_FMTBIT_S24_LE |
  6676. SNDRV_PCM_FMTBIT_S32_LE,
  6677. .channels_min = 1,
  6678. .channels_max = 8,
  6679. .rate_min = 8000,
  6680. .rate_max = 352800,
  6681. },
  6682. .ops = &msm_dai_q6_tdm_ops,
  6683. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  6684. .probe = msm_dai_q6_dai_tdm_probe,
  6685. .remove = msm_dai_q6_dai_tdm_remove,
  6686. },
  6687. {
  6688. .capture = {
  6689. .stream_name = "Primary TDM2 Capture",
  6690. .aif_name = "PRI_TDM_TX_2",
  6691. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6692. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6693. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6694. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6695. SNDRV_PCM_FMTBIT_S24_LE |
  6696. SNDRV_PCM_FMTBIT_S32_LE,
  6697. .channels_min = 1,
  6698. .channels_max = 8,
  6699. .rate_min = 8000,
  6700. .rate_max = 352800,
  6701. },
  6702. .ops = &msm_dai_q6_tdm_ops,
  6703. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  6704. .probe = msm_dai_q6_dai_tdm_probe,
  6705. .remove = msm_dai_q6_dai_tdm_remove,
  6706. },
  6707. {
  6708. .capture = {
  6709. .stream_name = "Primary TDM3 Capture",
  6710. .aif_name = "PRI_TDM_TX_3",
  6711. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6712. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6713. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6714. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6715. SNDRV_PCM_FMTBIT_S24_LE |
  6716. SNDRV_PCM_FMTBIT_S32_LE,
  6717. .channels_min = 1,
  6718. .channels_max = 8,
  6719. .rate_min = 8000,
  6720. .rate_max = 352800,
  6721. },
  6722. .ops = &msm_dai_q6_tdm_ops,
  6723. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  6724. .probe = msm_dai_q6_dai_tdm_probe,
  6725. .remove = msm_dai_q6_dai_tdm_remove,
  6726. },
  6727. {
  6728. .capture = {
  6729. .stream_name = "Primary TDM4 Capture",
  6730. .aif_name = "PRI_TDM_TX_4",
  6731. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6732. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6733. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6734. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6735. SNDRV_PCM_FMTBIT_S24_LE |
  6736. SNDRV_PCM_FMTBIT_S32_LE,
  6737. .channels_min = 1,
  6738. .channels_max = 8,
  6739. .rate_min = 8000,
  6740. .rate_max = 352800,
  6741. },
  6742. .ops = &msm_dai_q6_tdm_ops,
  6743. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  6744. .probe = msm_dai_q6_dai_tdm_probe,
  6745. .remove = msm_dai_q6_dai_tdm_remove,
  6746. },
  6747. {
  6748. .capture = {
  6749. .stream_name = "Primary TDM5 Capture",
  6750. .aif_name = "PRI_TDM_TX_5",
  6751. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6752. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6753. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6754. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6755. SNDRV_PCM_FMTBIT_S24_LE |
  6756. SNDRV_PCM_FMTBIT_S32_LE,
  6757. .channels_min = 1,
  6758. .channels_max = 8,
  6759. .rate_min = 8000,
  6760. .rate_max = 352800,
  6761. },
  6762. .ops = &msm_dai_q6_tdm_ops,
  6763. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  6764. .probe = msm_dai_q6_dai_tdm_probe,
  6765. .remove = msm_dai_q6_dai_tdm_remove,
  6766. },
  6767. {
  6768. .capture = {
  6769. .stream_name = "Primary TDM6 Capture",
  6770. .aif_name = "PRI_TDM_TX_6",
  6771. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6772. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6773. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6774. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6775. SNDRV_PCM_FMTBIT_S24_LE |
  6776. SNDRV_PCM_FMTBIT_S32_LE,
  6777. .channels_min = 1,
  6778. .channels_max = 8,
  6779. .rate_min = 8000,
  6780. .rate_max = 352800,
  6781. },
  6782. .ops = &msm_dai_q6_tdm_ops,
  6783. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  6784. .probe = msm_dai_q6_dai_tdm_probe,
  6785. .remove = msm_dai_q6_dai_tdm_remove,
  6786. },
  6787. {
  6788. .capture = {
  6789. .stream_name = "Primary TDM7 Capture",
  6790. .aif_name = "PRI_TDM_TX_7",
  6791. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6792. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6793. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6794. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6795. SNDRV_PCM_FMTBIT_S24_LE |
  6796. SNDRV_PCM_FMTBIT_S32_LE,
  6797. .channels_min = 1,
  6798. .channels_max = 8,
  6799. .rate_min = 8000,
  6800. .rate_max = 352800,
  6801. },
  6802. .ops = &msm_dai_q6_tdm_ops,
  6803. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  6804. .probe = msm_dai_q6_dai_tdm_probe,
  6805. .remove = msm_dai_q6_dai_tdm_remove,
  6806. },
  6807. {
  6808. .playback = {
  6809. .stream_name = "Secondary TDM0 Playback",
  6810. .aif_name = "SEC_TDM_RX_0",
  6811. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6812. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6813. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6814. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6815. SNDRV_PCM_FMTBIT_S24_LE |
  6816. SNDRV_PCM_FMTBIT_S32_LE,
  6817. .channels_min = 1,
  6818. .channels_max = 8,
  6819. .rate_min = 8000,
  6820. .rate_max = 352800,
  6821. },
  6822. .ops = &msm_dai_q6_tdm_ops,
  6823. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  6824. .probe = msm_dai_q6_dai_tdm_probe,
  6825. .remove = msm_dai_q6_dai_tdm_remove,
  6826. },
  6827. {
  6828. .playback = {
  6829. .stream_name = "Secondary TDM1 Playback",
  6830. .aif_name = "SEC_TDM_RX_1",
  6831. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6832. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6833. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6834. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6835. SNDRV_PCM_FMTBIT_S24_LE |
  6836. SNDRV_PCM_FMTBIT_S32_LE,
  6837. .channels_min = 1,
  6838. .channels_max = 8,
  6839. .rate_min = 8000,
  6840. .rate_max = 352800,
  6841. },
  6842. .ops = &msm_dai_q6_tdm_ops,
  6843. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  6844. .probe = msm_dai_q6_dai_tdm_probe,
  6845. .remove = msm_dai_q6_dai_tdm_remove,
  6846. },
  6847. {
  6848. .playback = {
  6849. .stream_name = "Secondary TDM2 Playback",
  6850. .aif_name = "SEC_TDM_RX_2",
  6851. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6852. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6853. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6854. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6855. SNDRV_PCM_FMTBIT_S24_LE |
  6856. SNDRV_PCM_FMTBIT_S32_LE,
  6857. .channels_min = 1,
  6858. .channels_max = 8,
  6859. .rate_min = 8000,
  6860. .rate_max = 352800,
  6861. },
  6862. .ops = &msm_dai_q6_tdm_ops,
  6863. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  6864. .probe = msm_dai_q6_dai_tdm_probe,
  6865. .remove = msm_dai_q6_dai_tdm_remove,
  6866. },
  6867. {
  6868. .playback = {
  6869. .stream_name = "Secondary TDM3 Playback",
  6870. .aif_name = "SEC_TDM_RX_3",
  6871. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6872. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6873. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6874. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6875. SNDRV_PCM_FMTBIT_S24_LE |
  6876. SNDRV_PCM_FMTBIT_S32_LE,
  6877. .channels_min = 1,
  6878. .channels_max = 8,
  6879. .rate_min = 8000,
  6880. .rate_max = 352800,
  6881. },
  6882. .ops = &msm_dai_q6_tdm_ops,
  6883. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  6884. .probe = msm_dai_q6_dai_tdm_probe,
  6885. .remove = msm_dai_q6_dai_tdm_remove,
  6886. },
  6887. {
  6888. .playback = {
  6889. .stream_name = "Secondary TDM4 Playback",
  6890. .aif_name = "SEC_TDM_RX_4",
  6891. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6892. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6893. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6894. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6895. SNDRV_PCM_FMTBIT_S24_LE |
  6896. SNDRV_PCM_FMTBIT_S32_LE,
  6897. .channels_min = 1,
  6898. .channels_max = 8,
  6899. .rate_min = 8000,
  6900. .rate_max = 352800,
  6901. },
  6902. .ops = &msm_dai_q6_tdm_ops,
  6903. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  6904. .probe = msm_dai_q6_dai_tdm_probe,
  6905. .remove = msm_dai_q6_dai_tdm_remove,
  6906. },
  6907. {
  6908. .playback = {
  6909. .stream_name = "Secondary TDM5 Playback",
  6910. .aif_name = "SEC_TDM_RX_5",
  6911. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6912. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6913. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6914. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6915. SNDRV_PCM_FMTBIT_S24_LE |
  6916. SNDRV_PCM_FMTBIT_S32_LE,
  6917. .channels_min = 1,
  6918. .channels_max = 8,
  6919. .rate_min = 8000,
  6920. .rate_max = 352800,
  6921. },
  6922. .ops = &msm_dai_q6_tdm_ops,
  6923. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  6924. .probe = msm_dai_q6_dai_tdm_probe,
  6925. .remove = msm_dai_q6_dai_tdm_remove,
  6926. },
  6927. {
  6928. .playback = {
  6929. .stream_name = "Secondary TDM6 Playback",
  6930. .aif_name = "SEC_TDM_RX_6",
  6931. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6932. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6933. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6934. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6935. SNDRV_PCM_FMTBIT_S24_LE |
  6936. SNDRV_PCM_FMTBIT_S32_LE,
  6937. .channels_min = 1,
  6938. .channels_max = 8,
  6939. .rate_min = 8000,
  6940. .rate_max = 352800,
  6941. },
  6942. .ops = &msm_dai_q6_tdm_ops,
  6943. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  6944. .probe = msm_dai_q6_dai_tdm_probe,
  6945. .remove = msm_dai_q6_dai_tdm_remove,
  6946. },
  6947. {
  6948. .playback = {
  6949. .stream_name = "Secondary TDM7 Playback",
  6950. .aif_name = "SEC_TDM_RX_7",
  6951. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6952. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6953. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6954. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6955. SNDRV_PCM_FMTBIT_S24_LE |
  6956. SNDRV_PCM_FMTBIT_S32_LE,
  6957. .channels_min = 1,
  6958. .channels_max = 8,
  6959. .rate_min = 8000,
  6960. .rate_max = 352800,
  6961. },
  6962. .ops = &msm_dai_q6_tdm_ops,
  6963. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  6964. .probe = msm_dai_q6_dai_tdm_probe,
  6965. .remove = msm_dai_q6_dai_tdm_remove,
  6966. },
  6967. {
  6968. .capture = {
  6969. .stream_name = "Secondary TDM0 Capture",
  6970. .aif_name = "SEC_TDM_TX_0",
  6971. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6972. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6973. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6974. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6975. SNDRV_PCM_FMTBIT_S24_LE |
  6976. SNDRV_PCM_FMTBIT_S32_LE,
  6977. .channels_min = 1,
  6978. .channels_max = 8,
  6979. .rate_min = 8000,
  6980. .rate_max = 352800,
  6981. },
  6982. .ops = &msm_dai_q6_tdm_ops,
  6983. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  6984. .probe = msm_dai_q6_dai_tdm_probe,
  6985. .remove = msm_dai_q6_dai_tdm_remove,
  6986. },
  6987. {
  6988. .capture = {
  6989. .stream_name = "Secondary TDM1 Capture",
  6990. .aif_name = "SEC_TDM_TX_1",
  6991. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6992. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6993. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6994. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6995. SNDRV_PCM_FMTBIT_S24_LE |
  6996. SNDRV_PCM_FMTBIT_S32_LE,
  6997. .channels_min = 1,
  6998. .channels_max = 8,
  6999. .rate_min = 8000,
  7000. .rate_max = 352800,
  7001. },
  7002. .ops = &msm_dai_q6_tdm_ops,
  7003. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  7004. .probe = msm_dai_q6_dai_tdm_probe,
  7005. .remove = msm_dai_q6_dai_tdm_remove,
  7006. },
  7007. {
  7008. .capture = {
  7009. .stream_name = "Secondary TDM2 Capture",
  7010. .aif_name = "SEC_TDM_TX_2",
  7011. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7012. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7013. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7014. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7015. SNDRV_PCM_FMTBIT_S24_LE |
  7016. SNDRV_PCM_FMTBIT_S32_LE,
  7017. .channels_min = 1,
  7018. .channels_max = 8,
  7019. .rate_min = 8000,
  7020. .rate_max = 352800,
  7021. },
  7022. .ops = &msm_dai_q6_tdm_ops,
  7023. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  7024. .probe = msm_dai_q6_dai_tdm_probe,
  7025. .remove = msm_dai_q6_dai_tdm_remove,
  7026. },
  7027. {
  7028. .capture = {
  7029. .stream_name = "Secondary TDM3 Capture",
  7030. .aif_name = "SEC_TDM_TX_3",
  7031. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7032. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7033. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7034. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7035. SNDRV_PCM_FMTBIT_S24_LE |
  7036. SNDRV_PCM_FMTBIT_S32_LE,
  7037. .channels_min = 1,
  7038. .channels_max = 8,
  7039. .rate_min = 8000,
  7040. .rate_max = 352800,
  7041. },
  7042. .ops = &msm_dai_q6_tdm_ops,
  7043. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  7044. .probe = msm_dai_q6_dai_tdm_probe,
  7045. .remove = msm_dai_q6_dai_tdm_remove,
  7046. },
  7047. {
  7048. .capture = {
  7049. .stream_name = "Secondary TDM4 Capture",
  7050. .aif_name = "SEC_TDM_TX_4",
  7051. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7052. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7053. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7054. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7055. SNDRV_PCM_FMTBIT_S24_LE |
  7056. SNDRV_PCM_FMTBIT_S32_LE,
  7057. .channels_min = 1,
  7058. .channels_max = 8,
  7059. .rate_min = 8000,
  7060. .rate_max = 352800,
  7061. },
  7062. .ops = &msm_dai_q6_tdm_ops,
  7063. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  7064. .probe = msm_dai_q6_dai_tdm_probe,
  7065. .remove = msm_dai_q6_dai_tdm_remove,
  7066. },
  7067. {
  7068. .capture = {
  7069. .stream_name = "Secondary TDM5 Capture",
  7070. .aif_name = "SEC_TDM_TX_5",
  7071. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7072. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7073. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7074. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7075. SNDRV_PCM_FMTBIT_S24_LE |
  7076. SNDRV_PCM_FMTBIT_S32_LE,
  7077. .channels_min = 1,
  7078. .channels_max = 8,
  7079. .rate_min = 8000,
  7080. .rate_max = 352800,
  7081. },
  7082. .ops = &msm_dai_q6_tdm_ops,
  7083. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  7084. .probe = msm_dai_q6_dai_tdm_probe,
  7085. .remove = msm_dai_q6_dai_tdm_remove,
  7086. },
  7087. {
  7088. .capture = {
  7089. .stream_name = "Secondary TDM6 Capture",
  7090. .aif_name = "SEC_TDM_TX_6",
  7091. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7092. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7093. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7094. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7095. SNDRV_PCM_FMTBIT_S24_LE |
  7096. SNDRV_PCM_FMTBIT_S32_LE,
  7097. .channels_min = 1,
  7098. .channels_max = 8,
  7099. .rate_min = 8000,
  7100. .rate_max = 352800,
  7101. },
  7102. .ops = &msm_dai_q6_tdm_ops,
  7103. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  7104. .probe = msm_dai_q6_dai_tdm_probe,
  7105. .remove = msm_dai_q6_dai_tdm_remove,
  7106. },
  7107. {
  7108. .capture = {
  7109. .stream_name = "Secondary TDM7 Capture",
  7110. .aif_name = "SEC_TDM_TX_7",
  7111. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7112. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7113. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7114. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7115. SNDRV_PCM_FMTBIT_S24_LE |
  7116. SNDRV_PCM_FMTBIT_S32_LE,
  7117. .channels_min = 1,
  7118. .channels_max = 8,
  7119. .rate_min = 8000,
  7120. .rate_max = 352800,
  7121. },
  7122. .ops = &msm_dai_q6_tdm_ops,
  7123. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  7124. .probe = msm_dai_q6_dai_tdm_probe,
  7125. .remove = msm_dai_q6_dai_tdm_remove,
  7126. },
  7127. {
  7128. .playback = {
  7129. .stream_name = "Tertiary TDM0 Playback",
  7130. .aif_name = "TERT_TDM_RX_0",
  7131. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7132. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7133. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7134. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7135. SNDRV_PCM_FMTBIT_S24_LE |
  7136. SNDRV_PCM_FMTBIT_S32_LE,
  7137. .channels_min = 1,
  7138. .channels_max = 8,
  7139. .rate_min = 8000,
  7140. .rate_max = 352800,
  7141. },
  7142. .ops = &msm_dai_q6_tdm_ops,
  7143. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  7144. .probe = msm_dai_q6_dai_tdm_probe,
  7145. .remove = msm_dai_q6_dai_tdm_remove,
  7146. },
  7147. {
  7148. .playback = {
  7149. .stream_name = "Tertiary TDM1 Playback",
  7150. .aif_name = "TERT_TDM_RX_1",
  7151. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7152. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7153. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7154. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7155. SNDRV_PCM_FMTBIT_S24_LE |
  7156. SNDRV_PCM_FMTBIT_S32_LE,
  7157. .channels_min = 1,
  7158. .channels_max = 8,
  7159. .rate_min = 8000,
  7160. .rate_max = 352800,
  7161. },
  7162. .ops = &msm_dai_q6_tdm_ops,
  7163. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  7164. .probe = msm_dai_q6_dai_tdm_probe,
  7165. .remove = msm_dai_q6_dai_tdm_remove,
  7166. },
  7167. {
  7168. .playback = {
  7169. .stream_name = "Tertiary TDM2 Playback",
  7170. .aif_name = "TERT_TDM_RX_2",
  7171. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7172. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7173. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7174. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7175. SNDRV_PCM_FMTBIT_S24_LE |
  7176. SNDRV_PCM_FMTBIT_S32_LE,
  7177. .channels_min = 1,
  7178. .channels_max = 8,
  7179. .rate_min = 8000,
  7180. .rate_max = 352800,
  7181. },
  7182. .ops = &msm_dai_q6_tdm_ops,
  7183. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  7184. .probe = msm_dai_q6_dai_tdm_probe,
  7185. .remove = msm_dai_q6_dai_tdm_remove,
  7186. },
  7187. {
  7188. .playback = {
  7189. .stream_name = "Tertiary TDM3 Playback",
  7190. .aif_name = "TERT_TDM_RX_3",
  7191. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7192. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7193. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7194. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7195. SNDRV_PCM_FMTBIT_S24_LE |
  7196. SNDRV_PCM_FMTBIT_S32_LE,
  7197. .channels_min = 1,
  7198. .channels_max = 8,
  7199. .rate_min = 8000,
  7200. .rate_max = 352800,
  7201. },
  7202. .ops = &msm_dai_q6_tdm_ops,
  7203. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  7204. .probe = msm_dai_q6_dai_tdm_probe,
  7205. .remove = msm_dai_q6_dai_tdm_remove,
  7206. },
  7207. {
  7208. .playback = {
  7209. .stream_name = "Tertiary TDM4 Playback",
  7210. .aif_name = "TERT_TDM_RX_4",
  7211. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7212. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7213. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7214. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7215. SNDRV_PCM_FMTBIT_S24_LE |
  7216. SNDRV_PCM_FMTBIT_S32_LE,
  7217. .channels_min = 1,
  7218. .channels_max = 8,
  7219. .rate_min = 8000,
  7220. .rate_max = 352800,
  7221. },
  7222. .ops = &msm_dai_q6_tdm_ops,
  7223. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  7224. .probe = msm_dai_q6_dai_tdm_probe,
  7225. .remove = msm_dai_q6_dai_tdm_remove,
  7226. },
  7227. {
  7228. .playback = {
  7229. .stream_name = "Tertiary TDM5 Playback",
  7230. .aif_name = "TERT_TDM_RX_5",
  7231. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7232. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7233. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7234. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7235. SNDRV_PCM_FMTBIT_S24_LE |
  7236. SNDRV_PCM_FMTBIT_S32_LE,
  7237. .channels_min = 1,
  7238. .channels_max = 8,
  7239. .rate_min = 8000,
  7240. .rate_max = 352800,
  7241. },
  7242. .ops = &msm_dai_q6_tdm_ops,
  7243. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  7244. .probe = msm_dai_q6_dai_tdm_probe,
  7245. .remove = msm_dai_q6_dai_tdm_remove,
  7246. },
  7247. {
  7248. .playback = {
  7249. .stream_name = "Tertiary TDM6 Playback",
  7250. .aif_name = "TERT_TDM_RX_6",
  7251. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7252. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7253. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7254. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7255. SNDRV_PCM_FMTBIT_S24_LE |
  7256. SNDRV_PCM_FMTBIT_S32_LE,
  7257. .channels_min = 1,
  7258. .channels_max = 8,
  7259. .rate_min = 8000,
  7260. .rate_max = 352800,
  7261. },
  7262. .ops = &msm_dai_q6_tdm_ops,
  7263. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  7264. .probe = msm_dai_q6_dai_tdm_probe,
  7265. .remove = msm_dai_q6_dai_tdm_remove,
  7266. },
  7267. {
  7268. .playback = {
  7269. .stream_name = "Tertiary TDM7 Playback",
  7270. .aif_name = "TERT_TDM_RX_7",
  7271. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7272. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7273. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7274. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7275. SNDRV_PCM_FMTBIT_S24_LE |
  7276. SNDRV_PCM_FMTBIT_S32_LE,
  7277. .channels_min = 1,
  7278. .channels_max = 8,
  7279. .rate_min = 8000,
  7280. .rate_max = 352800,
  7281. },
  7282. .ops = &msm_dai_q6_tdm_ops,
  7283. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  7284. .probe = msm_dai_q6_dai_tdm_probe,
  7285. .remove = msm_dai_q6_dai_tdm_remove,
  7286. },
  7287. {
  7288. .capture = {
  7289. .stream_name = "Tertiary TDM0 Capture",
  7290. .aif_name = "TERT_TDM_TX_0",
  7291. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7292. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7293. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7294. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7295. SNDRV_PCM_FMTBIT_S24_LE |
  7296. SNDRV_PCM_FMTBIT_S32_LE,
  7297. .channels_min = 1,
  7298. .channels_max = 8,
  7299. .rate_min = 8000,
  7300. .rate_max = 352800,
  7301. },
  7302. .ops = &msm_dai_q6_tdm_ops,
  7303. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  7304. .probe = msm_dai_q6_dai_tdm_probe,
  7305. .remove = msm_dai_q6_dai_tdm_remove,
  7306. },
  7307. {
  7308. .capture = {
  7309. .stream_name = "Tertiary TDM1 Capture",
  7310. .aif_name = "TERT_TDM_TX_1",
  7311. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7312. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7313. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7314. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7315. SNDRV_PCM_FMTBIT_S24_LE |
  7316. SNDRV_PCM_FMTBIT_S32_LE,
  7317. .channels_min = 1,
  7318. .channels_max = 8,
  7319. .rate_min = 8000,
  7320. .rate_max = 352800,
  7321. },
  7322. .ops = &msm_dai_q6_tdm_ops,
  7323. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  7324. .probe = msm_dai_q6_dai_tdm_probe,
  7325. .remove = msm_dai_q6_dai_tdm_remove,
  7326. },
  7327. {
  7328. .capture = {
  7329. .stream_name = "Tertiary TDM2 Capture",
  7330. .aif_name = "TERT_TDM_TX_2",
  7331. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7332. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7333. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7334. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7335. SNDRV_PCM_FMTBIT_S24_LE |
  7336. SNDRV_PCM_FMTBIT_S32_LE,
  7337. .channels_min = 1,
  7338. .channels_max = 8,
  7339. .rate_min = 8000,
  7340. .rate_max = 352800,
  7341. },
  7342. .ops = &msm_dai_q6_tdm_ops,
  7343. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  7344. .probe = msm_dai_q6_dai_tdm_probe,
  7345. .remove = msm_dai_q6_dai_tdm_remove,
  7346. },
  7347. {
  7348. .capture = {
  7349. .stream_name = "Tertiary TDM3 Capture",
  7350. .aif_name = "TERT_TDM_TX_3",
  7351. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7352. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7353. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7354. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7355. SNDRV_PCM_FMTBIT_S24_LE |
  7356. SNDRV_PCM_FMTBIT_S32_LE,
  7357. .channels_min = 1,
  7358. .channels_max = 8,
  7359. .rate_min = 8000,
  7360. .rate_max = 352800,
  7361. },
  7362. .ops = &msm_dai_q6_tdm_ops,
  7363. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  7364. .probe = msm_dai_q6_dai_tdm_probe,
  7365. .remove = msm_dai_q6_dai_tdm_remove,
  7366. },
  7367. {
  7368. .capture = {
  7369. .stream_name = "Tertiary TDM4 Capture",
  7370. .aif_name = "TERT_TDM_TX_4",
  7371. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7372. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7373. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7374. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7375. SNDRV_PCM_FMTBIT_S24_LE |
  7376. SNDRV_PCM_FMTBIT_S32_LE,
  7377. .channels_min = 1,
  7378. .channels_max = 8,
  7379. .rate_min = 8000,
  7380. .rate_max = 352800,
  7381. },
  7382. .ops = &msm_dai_q6_tdm_ops,
  7383. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  7384. .probe = msm_dai_q6_dai_tdm_probe,
  7385. .remove = msm_dai_q6_dai_tdm_remove,
  7386. },
  7387. {
  7388. .capture = {
  7389. .stream_name = "Tertiary TDM5 Capture",
  7390. .aif_name = "TERT_TDM_TX_5",
  7391. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7392. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7393. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7394. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7395. SNDRV_PCM_FMTBIT_S24_LE |
  7396. SNDRV_PCM_FMTBIT_S32_LE,
  7397. .channels_min = 1,
  7398. .channels_max = 8,
  7399. .rate_min = 8000,
  7400. .rate_max = 352800,
  7401. },
  7402. .ops = &msm_dai_q6_tdm_ops,
  7403. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  7404. .probe = msm_dai_q6_dai_tdm_probe,
  7405. .remove = msm_dai_q6_dai_tdm_remove,
  7406. },
  7407. {
  7408. .capture = {
  7409. .stream_name = "Tertiary TDM6 Capture",
  7410. .aif_name = "TERT_TDM_TX_6",
  7411. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7412. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7413. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7414. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7415. SNDRV_PCM_FMTBIT_S24_LE |
  7416. SNDRV_PCM_FMTBIT_S32_LE,
  7417. .channels_min = 1,
  7418. .channels_max = 8,
  7419. .rate_min = 8000,
  7420. .rate_max = 352800,
  7421. },
  7422. .ops = &msm_dai_q6_tdm_ops,
  7423. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  7424. .probe = msm_dai_q6_dai_tdm_probe,
  7425. .remove = msm_dai_q6_dai_tdm_remove,
  7426. },
  7427. {
  7428. .capture = {
  7429. .stream_name = "Tertiary TDM7 Capture",
  7430. .aif_name = "TERT_TDM_TX_7",
  7431. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7432. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7433. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7434. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7435. SNDRV_PCM_FMTBIT_S24_LE |
  7436. SNDRV_PCM_FMTBIT_S32_LE,
  7437. .channels_min = 1,
  7438. .channels_max = 8,
  7439. .rate_min = 8000,
  7440. .rate_max = 352800,
  7441. },
  7442. .ops = &msm_dai_q6_tdm_ops,
  7443. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  7444. .probe = msm_dai_q6_dai_tdm_probe,
  7445. .remove = msm_dai_q6_dai_tdm_remove,
  7446. },
  7447. {
  7448. .playback = {
  7449. .stream_name = "Quaternary TDM0 Playback",
  7450. .aif_name = "QUAT_TDM_RX_0",
  7451. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7452. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7453. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7454. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7455. SNDRV_PCM_FMTBIT_S24_LE |
  7456. SNDRV_PCM_FMTBIT_S32_LE,
  7457. .channels_min = 1,
  7458. .channels_max = 8,
  7459. .rate_min = 8000,
  7460. .rate_max = 352800,
  7461. },
  7462. .ops = &msm_dai_q6_tdm_ops,
  7463. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  7464. .probe = msm_dai_q6_dai_tdm_probe,
  7465. .remove = msm_dai_q6_dai_tdm_remove,
  7466. },
  7467. {
  7468. .playback = {
  7469. .stream_name = "Quaternary TDM1 Playback",
  7470. .aif_name = "QUAT_TDM_RX_1",
  7471. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7472. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7473. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7474. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7475. SNDRV_PCM_FMTBIT_S24_LE |
  7476. SNDRV_PCM_FMTBIT_S32_LE,
  7477. .channels_min = 1,
  7478. .channels_max = 8,
  7479. .rate_min = 8000,
  7480. .rate_max = 352800,
  7481. },
  7482. .ops = &msm_dai_q6_tdm_ops,
  7483. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  7484. .probe = msm_dai_q6_dai_tdm_probe,
  7485. .remove = msm_dai_q6_dai_tdm_remove,
  7486. },
  7487. {
  7488. .playback = {
  7489. .stream_name = "Quaternary TDM2 Playback",
  7490. .aif_name = "QUAT_TDM_RX_2",
  7491. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7492. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7493. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7494. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7495. SNDRV_PCM_FMTBIT_S24_LE |
  7496. SNDRV_PCM_FMTBIT_S32_LE,
  7497. .channels_min = 1,
  7498. .channels_max = 8,
  7499. .rate_min = 8000,
  7500. .rate_max = 352800,
  7501. },
  7502. .ops = &msm_dai_q6_tdm_ops,
  7503. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  7504. .probe = msm_dai_q6_dai_tdm_probe,
  7505. .remove = msm_dai_q6_dai_tdm_remove,
  7506. },
  7507. {
  7508. .playback = {
  7509. .stream_name = "Quaternary TDM3 Playback",
  7510. .aif_name = "QUAT_TDM_RX_3",
  7511. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7512. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7513. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7514. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7515. SNDRV_PCM_FMTBIT_S24_LE |
  7516. SNDRV_PCM_FMTBIT_S32_LE,
  7517. .channels_min = 1,
  7518. .channels_max = 8,
  7519. .rate_min = 8000,
  7520. .rate_max = 352800,
  7521. },
  7522. .ops = &msm_dai_q6_tdm_ops,
  7523. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  7524. .probe = msm_dai_q6_dai_tdm_probe,
  7525. .remove = msm_dai_q6_dai_tdm_remove,
  7526. },
  7527. {
  7528. .playback = {
  7529. .stream_name = "Quaternary TDM4 Playback",
  7530. .aif_name = "QUAT_TDM_RX_4",
  7531. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7532. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7533. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7534. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7535. SNDRV_PCM_FMTBIT_S24_LE |
  7536. SNDRV_PCM_FMTBIT_S32_LE,
  7537. .channels_min = 1,
  7538. .channels_max = 8,
  7539. .rate_min = 8000,
  7540. .rate_max = 352800,
  7541. },
  7542. .ops = &msm_dai_q6_tdm_ops,
  7543. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  7544. .probe = msm_dai_q6_dai_tdm_probe,
  7545. .remove = msm_dai_q6_dai_tdm_remove,
  7546. },
  7547. {
  7548. .playback = {
  7549. .stream_name = "Quaternary TDM5 Playback",
  7550. .aif_name = "QUAT_TDM_RX_5",
  7551. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7552. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7553. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7554. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7555. SNDRV_PCM_FMTBIT_S24_LE |
  7556. SNDRV_PCM_FMTBIT_S32_LE,
  7557. .channels_min = 1,
  7558. .channels_max = 8,
  7559. .rate_min = 8000,
  7560. .rate_max = 352800,
  7561. },
  7562. .ops = &msm_dai_q6_tdm_ops,
  7563. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  7564. .probe = msm_dai_q6_dai_tdm_probe,
  7565. .remove = msm_dai_q6_dai_tdm_remove,
  7566. },
  7567. {
  7568. .playback = {
  7569. .stream_name = "Quaternary TDM6 Playback",
  7570. .aif_name = "QUAT_TDM_RX_6",
  7571. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7572. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7573. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7574. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7575. SNDRV_PCM_FMTBIT_S24_LE |
  7576. SNDRV_PCM_FMTBIT_S32_LE,
  7577. .channels_min = 1,
  7578. .channels_max = 8,
  7579. .rate_min = 8000,
  7580. .rate_max = 352800,
  7581. },
  7582. .ops = &msm_dai_q6_tdm_ops,
  7583. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  7584. .probe = msm_dai_q6_dai_tdm_probe,
  7585. .remove = msm_dai_q6_dai_tdm_remove,
  7586. },
  7587. {
  7588. .playback = {
  7589. .stream_name = "Quaternary TDM7 Playback",
  7590. .aif_name = "QUAT_TDM_RX_7",
  7591. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7592. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7593. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7594. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7595. SNDRV_PCM_FMTBIT_S24_LE |
  7596. SNDRV_PCM_FMTBIT_S32_LE,
  7597. .channels_min = 1,
  7598. .channels_max = 8,
  7599. .rate_min = 8000,
  7600. .rate_max = 352800,
  7601. },
  7602. .ops = &msm_dai_q6_tdm_ops,
  7603. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  7604. .probe = msm_dai_q6_dai_tdm_probe,
  7605. .remove = msm_dai_q6_dai_tdm_remove,
  7606. },
  7607. {
  7608. .capture = {
  7609. .stream_name = "Quaternary TDM0 Capture",
  7610. .aif_name = "QUAT_TDM_TX_0",
  7611. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7612. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7613. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7614. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7615. SNDRV_PCM_FMTBIT_S24_LE |
  7616. SNDRV_PCM_FMTBIT_S32_LE,
  7617. .channels_min = 1,
  7618. .channels_max = 8,
  7619. .rate_min = 8000,
  7620. .rate_max = 352800,
  7621. },
  7622. .ops = &msm_dai_q6_tdm_ops,
  7623. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  7624. .probe = msm_dai_q6_dai_tdm_probe,
  7625. .remove = msm_dai_q6_dai_tdm_remove,
  7626. },
  7627. {
  7628. .capture = {
  7629. .stream_name = "Quaternary TDM1 Capture",
  7630. .aif_name = "QUAT_TDM_TX_1",
  7631. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7632. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7633. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7634. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7635. SNDRV_PCM_FMTBIT_S24_LE |
  7636. SNDRV_PCM_FMTBIT_S32_LE,
  7637. .channels_min = 1,
  7638. .channels_max = 8,
  7639. .rate_min = 8000,
  7640. .rate_max = 352800,
  7641. },
  7642. .ops = &msm_dai_q6_tdm_ops,
  7643. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  7644. .probe = msm_dai_q6_dai_tdm_probe,
  7645. .remove = msm_dai_q6_dai_tdm_remove,
  7646. },
  7647. {
  7648. .capture = {
  7649. .stream_name = "Quaternary TDM2 Capture",
  7650. .aif_name = "QUAT_TDM_TX_2",
  7651. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7652. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7653. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7654. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7655. SNDRV_PCM_FMTBIT_S24_LE |
  7656. SNDRV_PCM_FMTBIT_S32_LE,
  7657. .channels_min = 1,
  7658. .channels_max = 8,
  7659. .rate_min = 8000,
  7660. .rate_max = 352800,
  7661. },
  7662. .ops = &msm_dai_q6_tdm_ops,
  7663. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  7664. .probe = msm_dai_q6_dai_tdm_probe,
  7665. .remove = msm_dai_q6_dai_tdm_remove,
  7666. },
  7667. {
  7668. .capture = {
  7669. .stream_name = "Quaternary TDM3 Capture",
  7670. .aif_name = "QUAT_TDM_TX_3",
  7671. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7672. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7673. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7674. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7675. SNDRV_PCM_FMTBIT_S24_LE |
  7676. SNDRV_PCM_FMTBIT_S32_LE,
  7677. .channels_min = 1,
  7678. .channels_max = 8,
  7679. .rate_min = 8000,
  7680. .rate_max = 352800,
  7681. },
  7682. .ops = &msm_dai_q6_tdm_ops,
  7683. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  7684. .probe = msm_dai_q6_dai_tdm_probe,
  7685. .remove = msm_dai_q6_dai_tdm_remove,
  7686. },
  7687. {
  7688. .capture = {
  7689. .stream_name = "Quaternary TDM4 Capture",
  7690. .aif_name = "QUAT_TDM_TX_4",
  7691. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7692. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7693. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7694. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7695. SNDRV_PCM_FMTBIT_S24_LE |
  7696. SNDRV_PCM_FMTBIT_S32_LE,
  7697. .channels_min = 1,
  7698. .channels_max = 8,
  7699. .rate_min = 8000,
  7700. .rate_max = 352800,
  7701. },
  7702. .ops = &msm_dai_q6_tdm_ops,
  7703. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  7704. .probe = msm_dai_q6_dai_tdm_probe,
  7705. .remove = msm_dai_q6_dai_tdm_remove,
  7706. },
  7707. {
  7708. .capture = {
  7709. .stream_name = "Quaternary TDM5 Capture",
  7710. .aif_name = "QUAT_TDM_TX_5",
  7711. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7712. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7713. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7714. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7715. SNDRV_PCM_FMTBIT_S24_LE |
  7716. SNDRV_PCM_FMTBIT_S32_LE,
  7717. .channels_min = 1,
  7718. .channels_max = 8,
  7719. .rate_min = 8000,
  7720. .rate_max = 352800,
  7721. },
  7722. .ops = &msm_dai_q6_tdm_ops,
  7723. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  7724. .probe = msm_dai_q6_dai_tdm_probe,
  7725. .remove = msm_dai_q6_dai_tdm_remove,
  7726. },
  7727. {
  7728. .capture = {
  7729. .stream_name = "Quaternary TDM6 Capture",
  7730. .aif_name = "QUAT_TDM_TX_6",
  7731. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7732. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7733. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7734. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7735. SNDRV_PCM_FMTBIT_S24_LE |
  7736. SNDRV_PCM_FMTBIT_S32_LE,
  7737. .channels_min = 1,
  7738. .channels_max = 8,
  7739. .rate_min = 8000,
  7740. .rate_max = 352800,
  7741. },
  7742. .ops = &msm_dai_q6_tdm_ops,
  7743. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  7744. .probe = msm_dai_q6_dai_tdm_probe,
  7745. .remove = msm_dai_q6_dai_tdm_remove,
  7746. },
  7747. {
  7748. .capture = {
  7749. .stream_name = "Quaternary TDM7 Capture",
  7750. .aif_name = "QUAT_TDM_TX_7",
  7751. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7752. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7753. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7754. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7755. SNDRV_PCM_FMTBIT_S24_LE |
  7756. SNDRV_PCM_FMTBIT_S32_LE,
  7757. .channels_min = 1,
  7758. .channels_max = 8,
  7759. .rate_min = 8000,
  7760. .rate_max = 352800,
  7761. },
  7762. .ops = &msm_dai_q6_tdm_ops,
  7763. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  7764. .probe = msm_dai_q6_dai_tdm_probe,
  7765. .remove = msm_dai_q6_dai_tdm_remove,
  7766. },
  7767. {
  7768. .playback = {
  7769. .stream_name = "Quinary TDM0 Playback",
  7770. .aif_name = "QUIN_TDM_RX_0",
  7771. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7772. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7773. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7774. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7775. SNDRV_PCM_FMTBIT_S24_LE |
  7776. SNDRV_PCM_FMTBIT_S32_LE,
  7777. .channels_min = 1,
  7778. .channels_max = 8,
  7779. .rate_min = 8000,
  7780. .rate_max = 352800,
  7781. },
  7782. .ops = &msm_dai_q6_tdm_ops,
  7783. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  7784. .probe = msm_dai_q6_dai_tdm_probe,
  7785. .remove = msm_dai_q6_dai_tdm_remove,
  7786. },
  7787. {
  7788. .playback = {
  7789. .stream_name = "Quinary TDM1 Playback",
  7790. .aif_name = "QUIN_TDM_RX_1",
  7791. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7792. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7793. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7794. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7795. SNDRV_PCM_FMTBIT_S24_LE |
  7796. SNDRV_PCM_FMTBIT_S32_LE,
  7797. .channels_min = 1,
  7798. .channels_max = 8,
  7799. .rate_min = 8000,
  7800. .rate_max = 352800,
  7801. },
  7802. .ops = &msm_dai_q6_tdm_ops,
  7803. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  7804. .probe = msm_dai_q6_dai_tdm_probe,
  7805. .remove = msm_dai_q6_dai_tdm_remove,
  7806. },
  7807. {
  7808. .playback = {
  7809. .stream_name = "Quinary TDM2 Playback",
  7810. .aif_name = "QUIN_TDM_RX_2",
  7811. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7812. SNDRV_PCM_RATE_16000 | 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. .ops = &msm_dai_q6_tdm_ops,
  7823. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  7824. .probe = msm_dai_q6_dai_tdm_probe,
  7825. .remove = msm_dai_q6_dai_tdm_remove,
  7826. },
  7827. {
  7828. .playback = {
  7829. .stream_name = "Quinary TDM3 Playback",
  7830. .aif_name = "QUIN_TDM_RX_3",
  7831. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7832. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7833. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7834. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7835. SNDRV_PCM_FMTBIT_S24_LE |
  7836. SNDRV_PCM_FMTBIT_S32_LE,
  7837. .channels_min = 1,
  7838. .channels_max = 8,
  7839. .rate_min = 8000,
  7840. .rate_max = 352800,
  7841. },
  7842. .ops = &msm_dai_q6_tdm_ops,
  7843. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  7844. .probe = msm_dai_q6_dai_tdm_probe,
  7845. .remove = msm_dai_q6_dai_tdm_remove,
  7846. },
  7847. {
  7848. .playback = {
  7849. .stream_name = "Quinary TDM4 Playback",
  7850. .aif_name = "QUIN_TDM_RX_4",
  7851. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7852. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7853. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7854. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7855. SNDRV_PCM_FMTBIT_S24_LE |
  7856. SNDRV_PCM_FMTBIT_S32_LE,
  7857. .channels_min = 1,
  7858. .channels_max = 8,
  7859. .rate_min = 8000,
  7860. .rate_max = 352800,
  7861. },
  7862. .ops = &msm_dai_q6_tdm_ops,
  7863. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  7864. .probe = msm_dai_q6_dai_tdm_probe,
  7865. .remove = msm_dai_q6_dai_tdm_remove,
  7866. },
  7867. {
  7868. .playback = {
  7869. .stream_name = "Quinary TDM5 Playback",
  7870. .aif_name = "QUIN_TDM_RX_5",
  7871. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7872. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7873. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7874. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7875. SNDRV_PCM_FMTBIT_S24_LE |
  7876. SNDRV_PCM_FMTBIT_S32_LE,
  7877. .channels_min = 1,
  7878. .channels_max = 8,
  7879. .rate_min = 8000,
  7880. .rate_max = 352800,
  7881. },
  7882. .ops = &msm_dai_q6_tdm_ops,
  7883. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  7884. .probe = msm_dai_q6_dai_tdm_probe,
  7885. .remove = msm_dai_q6_dai_tdm_remove,
  7886. },
  7887. {
  7888. .playback = {
  7889. .stream_name = "Quinary TDM6 Playback",
  7890. .aif_name = "QUIN_TDM_RX_6",
  7891. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7892. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7893. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7894. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7895. SNDRV_PCM_FMTBIT_S24_LE |
  7896. SNDRV_PCM_FMTBIT_S32_LE,
  7897. .channels_min = 1,
  7898. .channels_max = 8,
  7899. .rate_min = 8000,
  7900. .rate_max = 352800,
  7901. },
  7902. .ops = &msm_dai_q6_tdm_ops,
  7903. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  7904. .probe = msm_dai_q6_dai_tdm_probe,
  7905. .remove = msm_dai_q6_dai_tdm_remove,
  7906. },
  7907. {
  7908. .playback = {
  7909. .stream_name = "Quinary TDM7 Playback",
  7910. .aif_name = "QUIN_TDM_RX_7",
  7911. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7912. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7913. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7914. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7915. SNDRV_PCM_FMTBIT_S24_LE |
  7916. SNDRV_PCM_FMTBIT_S32_LE,
  7917. .channels_min = 1,
  7918. .channels_max = 8,
  7919. .rate_min = 8000,
  7920. .rate_max = 352800,
  7921. },
  7922. .ops = &msm_dai_q6_tdm_ops,
  7923. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  7924. .probe = msm_dai_q6_dai_tdm_probe,
  7925. .remove = msm_dai_q6_dai_tdm_remove,
  7926. },
  7927. {
  7928. .capture = {
  7929. .stream_name = "Quinary TDM0 Capture",
  7930. .aif_name = "QUIN_TDM_TX_0",
  7931. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7932. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7933. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7934. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7935. SNDRV_PCM_FMTBIT_S24_LE |
  7936. SNDRV_PCM_FMTBIT_S32_LE,
  7937. .channels_min = 1,
  7938. .channels_max = 8,
  7939. .rate_min = 8000,
  7940. .rate_max = 352800,
  7941. },
  7942. .ops = &msm_dai_q6_tdm_ops,
  7943. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  7944. .probe = msm_dai_q6_dai_tdm_probe,
  7945. .remove = msm_dai_q6_dai_tdm_remove,
  7946. },
  7947. {
  7948. .capture = {
  7949. .stream_name = "Quinary TDM1 Capture",
  7950. .aif_name = "QUIN_TDM_TX_1",
  7951. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7952. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7953. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7954. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7955. SNDRV_PCM_FMTBIT_S24_LE |
  7956. SNDRV_PCM_FMTBIT_S32_LE,
  7957. .channels_min = 1,
  7958. .channels_max = 8,
  7959. .rate_min = 8000,
  7960. .rate_max = 352800,
  7961. },
  7962. .ops = &msm_dai_q6_tdm_ops,
  7963. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  7964. .probe = msm_dai_q6_dai_tdm_probe,
  7965. .remove = msm_dai_q6_dai_tdm_remove,
  7966. },
  7967. {
  7968. .capture = {
  7969. .stream_name = "Quinary TDM2 Capture",
  7970. .aif_name = "QUIN_TDM_TX_2",
  7971. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7972. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7973. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7974. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7975. SNDRV_PCM_FMTBIT_S24_LE |
  7976. SNDRV_PCM_FMTBIT_S32_LE,
  7977. .channels_min = 1,
  7978. .channels_max = 8,
  7979. .rate_min = 8000,
  7980. .rate_max = 352800,
  7981. },
  7982. .ops = &msm_dai_q6_tdm_ops,
  7983. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  7984. .probe = msm_dai_q6_dai_tdm_probe,
  7985. .remove = msm_dai_q6_dai_tdm_remove,
  7986. },
  7987. {
  7988. .capture = {
  7989. .stream_name = "Quinary TDM3 Capture",
  7990. .aif_name = "QUIN_TDM_TX_3",
  7991. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7992. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7993. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7994. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7995. SNDRV_PCM_FMTBIT_S24_LE |
  7996. SNDRV_PCM_FMTBIT_S32_LE,
  7997. .channels_min = 1,
  7998. .channels_max = 8,
  7999. .rate_min = 8000,
  8000. .rate_max = 352800,
  8001. },
  8002. .ops = &msm_dai_q6_tdm_ops,
  8003. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  8004. .probe = msm_dai_q6_dai_tdm_probe,
  8005. .remove = msm_dai_q6_dai_tdm_remove,
  8006. },
  8007. {
  8008. .capture = {
  8009. .stream_name = "Quinary TDM4 Capture",
  8010. .aif_name = "QUIN_TDM_TX_4",
  8011. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8012. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8013. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8014. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8015. SNDRV_PCM_FMTBIT_S24_LE |
  8016. SNDRV_PCM_FMTBIT_S32_LE,
  8017. .channels_min = 1,
  8018. .channels_max = 8,
  8019. .rate_min = 8000,
  8020. .rate_max = 352800,
  8021. },
  8022. .ops = &msm_dai_q6_tdm_ops,
  8023. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  8024. .probe = msm_dai_q6_dai_tdm_probe,
  8025. .remove = msm_dai_q6_dai_tdm_remove,
  8026. },
  8027. {
  8028. .capture = {
  8029. .stream_name = "Quinary TDM5 Capture",
  8030. .aif_name = "QUIN_TDM_TX_5",
  8031. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8032. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8033. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8034. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8035. SNDRV_PCM_FMTBIT_S24_LE |
  8036. SNDRV_PCM_FMTBIT_S32_LE,
  8037. .channels_min = 1,
  8038. .channels_max = 8,
  8039. .rate_min = 8000,
  8040. .rate_max = 352800,
  8041. },
  8042. .ops = &msm_dai_q6_tdm_ops,
  8043. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  8044. .probe = msm_dai_q6_dai_tdm_probe,
  8045. .remove = msm_dai_q6_dai_tdm_remove,
  8046. },
  8047. {
  8048. .capture = {
  8049. .stream_name = "Quinary TDM6 Capture",
  8050. .aif_name = "QUIN_TDM_TX_6",
  8051. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8052. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8053. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8054. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8055. SNDRV_PCM_FMTBIT_S24_LE |
  8056. SNDRV_PCM_FMTBIT_S32_LE,
  8057. .channels_min = 1,
  8058. .channels_max = 8,
  8059. .rate_min = 8000,
  8060. .rate_max = 352800,
  8061. },
  8062. .ops = &msm_dai_q6_tdm_ops,
  8063. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  8064. .probe = msm_dai_q6_dai_tdm_probe,
  8065. .remove = msm_dai_q6_dai_tdm_remove,
  8066. },
  8067. {
  8068. .capture = {
  8069. .stream_name = "Quinary TDM7 Capture",
  8070. .aif_name = "QUIN_TDM_TX_7",
  8071. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8072. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8073. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8074. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8075. SNDRV_PCM_FMTBIT_S24_LE |
  8076. SNDRV_PCM_FMTBIT_S32_LE,
  8077. .channels_min = 1,
  8078. .channels_max = 8,
  8079. .rate_min = 8000,
  8080. .rate_max = 352800,
  8081. },
  8082. .ops = &msm_dai_q6_tdm_ops,
  8083. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  8084. .probe = msm_dai_q6_dai_tdm_probe,
  8085. .remove = msm_dai_q6_dai_tdm_remove,
  8086. },
  8087. };
  8088. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  8089. .name = "msm-dai-q6-tdm",
  8090. };
  8091. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  8092. {
  8093. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  8094. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  8095. int rc = 0;
  8096. u32 tdm_dev_id = 0;
  8097. int port_idx = 0;
  8098. struct device_node *tdm_parent_node = NULL;
  8099. /* retrieve device/afe id */
  8100. rc = of_property_read_u32(pdev->dev.of_node,
  8101. "qcom,msm-cpudai-tdm-dev-id",
  8102. &tdm_dev_id);
  8103. if (rc) {
  8104. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  8105. __func__);
  8106. goto rtn;
  8107. }
  8108. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  8109. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  8110. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  8111. __func__, tdm_dev_id);
  8112. rc = -ENXIO;
  8113. goto rtn;
  8114. }
  8115. pdev->id = tdm_dev_id;
  8116. dev_info(&pdev->dev, "%s: dev_name: %s dev_id: 0x%x\n",
  8117. __func__, dev_name(&pdev->dev), tdm_dev_id);
  8118. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  8119. GFP_KERNEL);
  8120. if (!dai_data) {
  8121. rc = -ENOMEM;
  8122. dev_err(&pdev->dev,
  8123. "%s Failed to allocate memory for tdm dai_data\n",
  8124. __func__);
  8125. goto rtn;
  8126. }
  8127. memset(dai_data, 0, sizeof(*dai_data));
  8128. /* TDM CFG */
  8129. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  8130. rc = of_property_read_u32(tdm_parent_node,
  8131. "qcom,msm-cpudai-tdm-sync-mode",
  8132. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  8133. if (rc) {
  8134. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  8135. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  8136. goto free_dai_data;
  8137. }
  8138. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  8139. __func__, dai_data->port_cfg.tdm.sync_mode);
  8140. rc = of_property_read_u32(tdm_parent_node,
  8141. "qcom,msm-cpudai-tdm-sync-src",
  8142. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  8143. if (rc) {
  8144. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  8145. __func__, "qcom,msm-cpudai-tdm-sync-src");
  8146. goto free_dai_data;
  8147. }
  8148. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  8149. __func__, dai_data->port_cfg.tdm.sync_src);
  8150. rc = of_property_read_u32(tdm_parent_node,
  8151. "qcom,msm-cpudai-tdm-data-out",
  8152. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8153. if (rc) {
  8154. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  8155. __func__, "qcom,msm-cpudai-tdm-data-out");
  8156. goto free_dai_data;
  8157. }
  8158. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  8159. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8160. rc = of_property_read_u32(tdm_parent_node,
  8161. "qcom,msm-cpudai-tdm-invert-sync",
  8162. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8163. if (rc) {
  8164. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  8165. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  8166. goto free_dai_data;
  8167. }
  8168. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  8169. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8170. rc = of_property_read_u32(tdm_parent_node,
  8171. "qcom,msm-cpudai-tdm-data-delay",
  8172. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8173. if (rc) {
  8174. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  8175. __func__, "qcom,msm-cpudai-tdm-data-delay");
  8176. goto free_dai_data;
  8177. }
  8178. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  8179. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8180. /* TDM CFG -- set default */
  8181. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  8182. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  8183. AFE_API_VERSION_TDM_CONFIG;
  8184. /* TDM SLOT MAPPING CFG */
  8185. rc = of_property_read_u32(pdev->dev.of_node,
  8186. "qcom,msm-cpudai-tdm-data-align",
  8187. &dai_data->port_cfg.slot_mapping.data_align_type);
  8188. if (rc) {
  8189. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  8190. __func__,
  8191. "qcom,msm-cpudai-tdm-data-align");
  8192. goto free_dai_data;
  8193. }
  8194. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  8195. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  8196. /* TDM SLOT MAPPING CFG -- set default */
  8197. dai_data->port_cfg.slot_mapping.minor_version =
  8198. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  8199. /* CUSTOM TDM HEADER CFG */
  8200. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  8201. if (of_find_property(pdev->dev.of_node,
  8202. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  8203. of_find_property(pdev->dev.of_node,
  8204. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  8205. of_find_property(pdev->dev.of_node,
  8206. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  8207. /* if the property exist */
  8208. rc = of_property_read_u32(pdev->dev.of_node,
  8209. "qcom,msm-cpudai-tdm-header-start-offset",
  8210. (u32 *)&custom_tdm_header->start_offset);
  8211. if (rc) {
  8212. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  8213. __func__,
  8214. "qcom,msm-cpudai-tdm-header-start-offset");
  8215. goto free_dai_data;
  8216. }
  8217. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  8218. __func__, custom_tdm_header->start_offset);
  8219. rc = of_property_read_u32(pdev->dev.of_node,
  8220. "qcom,msm-cpudai-tdm-header-width",
  8221. (u32 *)&custom_tdm_header->header_width);
  8222. if (rc) {
  8223. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  8224. __func__, "qcom,msm-cpudai-tdm-header-width");
  8225. goto free_dai_data;
  8226. }
  8227. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  8228. __func__, custom_tdm_header->header_width);
  8229. rc = of_property_read_u32(pdev->dev.of_node,
  8230. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  8231. (u32 *)&custom_tdm_header->num_frame_repeat);
  8232. if (rc) {
  8233. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  8234. __func__,
  8235. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  8236. goto free_dai_data;
  8237. }
  8238. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  8239. __func__, custom_tdm_header->num_frame_repeat);
  8240. /* CUSTOM TDM HEADER CFG -- set default */
  8241. custom_tdm_header->minor_version =
  8242. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  8243. custom_tdm_header->header_type =
  8244. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8245. } else {
  8246. dev_info(&pdev->dev,
  8247. "%s: Custom tdm header not supported\n", __func__);
  8248. /* CUSTOM TDM HEADER CFG -- set default */
  8249. custom_tdm_header->header_type =
  8250. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8251. /* proceed with probe */
  8252. }
  8253. /* copy static clk per parent node */
  8254. dai_data->clk_set = tdm_clk_set;
  8255. /* copy static group cfg per parent node */
  8256. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  8257. /* copy static num group ports per parent node */
  8258. dai_data->num_group_ports = num_tdm_group_ports;
  8259. dev_set_drvdata(&pdev->dev, dai_data);
  8260. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  8261. if (port_idx < 0) {
  8262. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  8263. __func__, tdm_dev_id);
  8264. rc = -EINVAL;
  8265. goto free_dai_data;
  8266. }
  8267. rc = snd_soc_register_component(&pdev->dev,
  8268. &msm_q6_tdm_dai_component,
  8269. &msm_dai_q6_tdm_dai[port_idx], 1);
  8270. if (rc) {
  8271. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  8272. __func__, tdm_dev_id, rc);
  8273. goto err_register;
  8274. }
  8275. return 0;
  8276. err_register:
  8277. free_dai_data:
  8278. kfree(dai_data);
  8279. rtn:
  8280. return rc;
  8281. }
  8282. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  8283. {
  8284. struct msm_dai_q6_tdm_dai_data *dai_data =
  8285. dev_get_drvdata(&pdev->dev);
  8286. snd_soc_unregister_component(&pdev->dev);
  8287. kfree(dai_data);
  8288. return 0;
  8289. }
  8290. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  8291. { .compatible = "qcom,msm-dai-q6-tdm", },
  8292. {}
  8293. };
  8294. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  8295. static struct platform_driver msm_dai_q6_tdm_driver = {
  8296. .probe = msm_dai_q6_tdm_dev_probe,
  8297. .remove = msm_dai_q6_tdm_dev_remove,
  8298. .driver = {
  8299. .name = "msm-dai-q6-tdm",
  8300. .owner = THIS_MODULE,
  8301. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  8302. },
  8303. };
  8304. int __init msm_dai_q6_init(void)
  8305. {
  8306. int rc;
  8307. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  8308. if (rc) {
  8309. pr_err("%s: fail to register auxpcm dev driver", __func__);
  8310. goto fail;
  8311. }
  8312. rc = platform_driver_register(&msm_dai_q6);
  8313. if (rc) {
  8314. pr_err("%s: fail to register dai q6 driver", __func__);
  8315. goto dai_q6_fail;
  8316. }
  8317. rc = platform_driver_register(&msm_dai_q6_dev);
  8318. if (rc) {
  8319. pr_err("%s: fail to register dai q6 dev driver", __func__);
  8320. goto dai_q6_dev_fail;
  8321. }
  8322. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  8323. if (rc) {
  8324. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  8325. goto dai_q6_mi2s_drv_fail;
  8326. }
  8327. rc = platform_driver_register(&msm_dai_mi2s_q6);
  8328. if (rc) {
  8329. pr_err("%s: fail to register dai MI2S\n", __func__);
  8330. goto dai_mi2s_q6_fail;
  8331. }
  8332. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  8333. if (rc) {
  8334. pr_err("%s: fail to register dai SPDIF\n", __func__);
  8335. goto dai_spdif_q6_fail;
  8336. }
  8337. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  8338. if (rc) {
  8339. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  8340. goto dai_q6_tdm_drv_fail;
  8341. }
  8342. rc = platform_driver_register(&msm_dai_tdm_q6);
  8343. if (rc) {
  8344. pr_err("%s: fail to register dai TDM\n", __func__);
  8345. goto dai_tdm_q6_fail;
  8346. }
  8347. return rc;
  8348. dai_tdm_q6_fail:
  8349. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  8350. dai_q6_tdm_drv_fail:
  8351. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  8352. dai_spdif_q6_fail:
  8353. platform_driver_unregister(&msm_dai_mi2s_q6);
  8354. dai_mi2s_q6_fail:
  8355. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  8356. dai_q6_mi2s_drv_fail:
  8357. platform_driver_unregister(&msm_dai_q6_dev);
  8358. dai_q6_dev_fail:
  8359. platform_driver_unregister(&msm_dai_q6);
  8360. dai_q6_fail:
  8361. platform_driver_unregister(&msm_auxpcm_dev_driver);
  8362. fail:
  8363. return rc;
  8364. }
  8365. void __exit msm_dai_q6_exit(void)
  8366. {
  8367. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  8368. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  8369. platform_driver_unregister(&msm_dai_mi2s_q6);
  8370. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  8371. platform_driver_unregister(&msm_dai_q6_dev);
  8372. platform_driver_unregister(&msm_dai_q6);
  8373. platform_driver_unregister(&msm_auxpcm_dev_driver);
  8374. }
  8375. /* Module information */
  8376. MODULE_DESCRIPTION("MSM DSP DAI driver");
  8377. MODULE_LICENSE("GPL v2");