msm-dai-q6-v2.c 380 KB

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