msm-dai-q6-v2.c 380 KB

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