msm-dai-q6-v2.c 263 KB

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