msm-dai-q6-v2.c 298 KB

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