msm-dai-q6-v2.c 323 KB

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