msm-dai-q6-v2.c 382 KB

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