msm-dai-q6-v2.c 324 KB

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