msm-dai-q6-v2.c 352 KB

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