msm-dai-q6-v2.c 317 KB

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