msm-dai-q6-v2.c 381 KB

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