msm-dai-q6-v2.c 317 KB

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