msm-dai-q6-v2.c 386 KB

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