msm-dai-q6-v2.c 390 KB

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