msm-dai-q6-v2.c 351 KB

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