msm-dai-q6-v2.c 322 KB

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