msm-dai-q6-v2.c 239 KB

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