msm-dai-q6-v2.c 352 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064
  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. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  2466. .prepare = msm_dai_q6_prepare,
  2467. .hw_params = msm_dai_q6_hw_params,
  2468. .shutdown = msm_dai_q6_shutdown,
  2469. .set_fmt = msm_dai_q6_set_fmt,
  2470. .set_channel_map = msm_dai_q6_set_channel_map,
  2471. };
  2472. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  2473. struct snd_ctl_elem_value *ucontrol)
  2474. {
  2475. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2476. u16 port_id = ((struct soc_enum *)
  2477. kcontrol->private_value)->reg;
  2478. dai_data->cal_mode = ucontrol->value.integer.value[0];
  2479. pr_debug("%s: setting cal_mode to %d\n",
  2480. __func__, dai_data->cal_mode);
  2481. afe_set_cal_mode(port_id, dai_data->cal_mode);
  2482. return 0;
  2483. }
  2484. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  2485. struct snd_ctl_elem_value *ucontrol)
  2486. {
  2487. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2488. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  2489. return 0;
  2490. }
  2491. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  2492. struct snd_ctl_elem_value *ucontrol)
  2493. {
  2494. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2495. int value = ucontrol->value.integer.value[0];
  2496. if (dai_data) {
  2497. dai_data->port_config.slim_sch.data_format = value;
  2498. pr_debug("%s: format = %d\n", __func__, value);
  2499. }
  2500. return 0;
  2501. }
  2502. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  2503. struct snd_ctl_elem_value *ucontrol)
  2504. {
  2505. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2506. if (dai_data)
  2507. ucontrol->value.integer.value[0] =
  2508. dai_data->port_config.slim_sch.data_format;
  2509. return 0;
  2510. }
  2511. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  2512. struct snd_ctl_elem_value *ucontrol)
  2513. {
  2514. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2515. u32 val = ucontrol->value.integer.value[0];
  2516. if (dai_data) {
  2517. dai_data->port_config.usb_audio.dev_token = val;
  2518. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2519. dai_data->port_config.usb_audio.dev_token);
  2520. } else {
  2521. pr_err("%s: dai_data is NULL\n", __func__);
  2522. }
  2523. return 0;
  2524. }
  2525. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  2526. struct snd_ctl_elem_value *ucontrol)
  2527. {
  2528. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2529. if (dai_data) {
  2530. ucontrol->value.integer.value[0] =
  2531. dai_data->port_config.usb_audio.dev_token;
  2532. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2533. dai_data->port_config.usb_audio.dev_token);
  2534. } else {
  2535. pr_err("%s: dai_data is NULL\n", __func__);
  2536. }
  2537. return 0;
  2538. }
  2539. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  2540. struct snd_ctl_elem_value *ucontrol)
  2541. {
  2542. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2543. u32 val = ucontrol->value.integer.value[0];
  2544. if (dai_data) {
  2545. dai_data->port_config.usb_audio.endian = val;
  2546. pr_debug("%s: endian = 0x%x\n", __func__,
  2547. dai_data->port_config.usb_audio.endian);
  2548. } else {
  2549. pr_err("%s: dai_data is NULL\n", __func__);
  2550. return -EINVAL;
  2551. }
  2552. return 0;
  2553. }
  2554. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  2555. struct snd_ctl_elem_value *ucontrol)
  2556. {
  2557. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2558. if (dai_data) {
  2559. ucontrol->value.integer.value[0] =
  2560. dai_data->port_config.usb_audio.endian;
  2561. pr_debug("%s: endian = 0x%x\n", __func__,
  2562. dai_data->port_config.usb_audio.endian);
  2563. } else {
  2564. pr_err("%s: dai_data is NULL\n", __func__);
  2565. return -EINVAL;
  2566. }
  2567. return 0;
  2568. }
  2569. static int msm_dai_q6_usb_audio_svc_interval_put(struct snd_kcontrol *kcontrol,
  2570. struct snd_ctl_elem_value *ucontrol)
  2571. {
  2572. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2573. u32 val = ucontrol->value.integer.value[0];
  2574. if (!dai_data) {
  2575. pr_err("%s: dai_data is NULL\n", __func__);
  2576. return -EINVAL;
  2577. }
  2578. dai_data->port_config.usb_audio.service_interval = val;
  2579. pr_debug("%s: new service interval = %u\n", __func__,
  2580. dai_data->port_config.usb_audio.service_interval);
  2581. return 0;
  2582. }
  2583. static int msm_dai_q6_usb_audio_svc_interval_get(struct snd_kcontrol *kcontrol,
  2584. struct snd_ctl_elem_value *ucontrol)
  2585. {
  2586. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2587. if (!dai_data) {
  2588. pr_err("%s: dai_data is NULL\n", __func__);
  2589. return -EINVAL;
  2590. }
  2591. ucontrol->value.integer.value[0] =
  2592. dai_data->port_config.usb_audio.service_interval;
  2593. pr_debug("%s: service interval = %d\n", __func__,
  2594. dai_data->port_config.usb_audio.service_interval);
  2595. return 0;
  2596. }
  2597. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2598. struct snd_ctl_elem_info *uinfo)
  2599. {
  2600. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2601. uinfo->count = sizeof(struct afe_enc_config);
  2602. return 0;
  2603. }
  2604. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2605. struct snd_ctl_elem_value *ucontrol)
  2606. {
  2607. int ret = 0;
  2608. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2609. if (dai_data) {
  2610. int format_size = sizeof(dai_data->enc_config.format);
  2611. pr_debug("%s: encoder config for %d format\n",
  2612. __func__, dai_data->enc_config.format);
  2613. memcpy(ucontrol->value.bytes.data,
  2614. &dai_data->enc_config.format,
  2615. format_size);
  2616. switch (dai_data->enc_config.format) {
  2617. case ENC_FMT_SBC:
  2618. memcpy(ucontrol->value.bytes.data + format_size,
  2619. &dai_data->enc_config.data,
  2620. sizeof(struct asm_sbc_enc_cfg_t));
  2621. break;
  2622. case ENC_FMT_AAC_V2:
  2623. memcpy(ucontrol->value.bytes.data + format_size,
  2624. &dai_data->enc_config.data,
  2625. sizeof(struct asm_aac_enc_cfg_t));
  2626. break;
  2627. case ENC_FMT_APTX:
  2628. memcpy(ucontrol->value.bytes.data + format_size,
  2629. &dai_data->enc_config.data,
  2630. sizeof(struct asm_aptx_enc_cfg_t));
  2631. break;
  2632. case ENC_FMT_APTX_HD:
  2633. memcpy(ucontrol->value.bytes.data + format_size,
  2634. &dai_data->enc_config.data,
  2635. sizeof(struct asm_custom_enc_cfg_t));
  2636. break;
  2637. case ENC_FMT_CELT:
  2638. memcpy(ucontrol->value.bytes.data + format_size,
  2639. &dai_data->enc_config.data,
  2640. sizeof(struct asm_celt_enc_cfg_t));
  2641. break;
  2642. case ENC_FMT_LDAC:
  2643. memcpy(ucontrol->value.bytes.data + format_size,
  2644. &dai_data->enc_config.data,
  2645. sizeof(struct asm_ldac_enc_cfg_t));
  2646. break;
  2647. case ENC_FMT_APTX_ADAPTIVE:
  2648. memcpy(ucontrol->value.bytes.data + format_size,
  2649. &dai_data->enc_config.data,
  2650. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2651. break;
  2652. case ENC_FMT_APTX_AD_SPEECH:
  2653. memcpy(ucontrol->value.bytes.data + format_size,
  2654. &dai_data->enc_config.data,
  2655. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2656. break;
  2657. default:
  2658. pr_debug("%s: unknown format = %d\n",
  2659. __func__, dai_data->enc_config.format);
  2660. ret = -EINVAL;
  2661. break;
  2662. }
  2663. }
  2664. return ret;
  2665. }
  2666. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2667. struct snd_ctl_elem_value *ucontrol)
  2668. {
  2669. int ret = 0;
  2670. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2671. if (dai_data) {
  2672. int format_size = sizeof(dai_data->enc_config.format);
  2673. memset(&dai_data->enc_config, 0x0,
  2674. sizeof(struct afe_enc_config));
  2675. memcpy(&dai_data->enc_config.format,
  2676. ucontrol->value.bytes.data,
  2677. format_size);
  2678. pr_debug("%s: Received encoder config for %d format\n",
  2679. __func__, dai_data->enc_config.format);
  2680. switch (dai_data->enc_config.format) {
  2681. case ENC_FMT_SBC:
  2682. memcpy(&dai_data->enc_config.data,
  2683. ucontrol->value.bytes.data + format_size,
  2684. sizeof(struct asm_sbc_enc_cfg_t));
  2685. break;
  2686. case ENC_FMT_AAC_V2:
  2687. memcpy(&dai_data->enc_config.data,
  2688. ucontrol->value.bytes.data + format_size,
  2689. sizeof(struct asm_aac_enc_cfg_t));
  2690. break;
  2691. case ENC_FMT_APTX:
  2692. memcpy(&dai_data->enc_config.data,
  2693. ucontrol->value.bytes.data + format_size,
  2694. sizeof(struct asm_aptx_enc_cfg_t));
  2695. break;
  2696. case ENC_FMT_APTX_HD:
  2697. memcpy(&dai_data->enc_config.data,
  2698. ucontrol->value.bytes.data + format_size,
  2699. sizeof(struct asm_custom_enc_cfg_t));
  2700. break;
  2701. case ENC_FMT_CELT:
  2702. memcpy(&dai_data->enc_config.data,
  2703. ucontrol->value.bytes.data + format_size,
  2704. sizeof(struct asm_celt_enc_cfg_t));
  2705. break;
  2706. case ENC_FMT_LDAC:
  2707. memcpy(&dai_data->enc_config.data,
  2708. ucontrol->value.bytes.data + format_size,
  2709. sizeof(struct asm_ldac_enc_cfg_t));
  2710. break;
  2711. case ENC_FMT_APTX_ADAPTIVE:
  2712. memcpy(&dai_data->enc_config.data,
  2713. ucontrol->value.bytes.data + format_size,
  2714. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2715. break;
  2716. case ENC_FMT_APTX_AD_SPEECH:
  2717. memcpy(&dai_data->enc_config.data,
  2718. ucontrol->value.bytes.data + format_size,
  2719. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2720. break;
  2721. default:
  2722. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2723. __func__, dai_data->enc_config.format);
  2724. ret = -EINVAL;
  2725. break;
  2726. }
  2727. } else
  2728. ret = -EINVAL;
  2729. return ret;
  2730. }
  2731. static const char *const afe_chs_text[] = {"Zero", "One", "Two"};
  2732. static const struct soc_enum afe_chs_enum[] = {
  2733. SOC_ENUM_SINGLE_EXT(3, afe_chs_text),
  2734. };
  2735. static const char *const afe_bit_format_text[] = {"S16_LE", "S24_LE",
  2736. "S32_LE"};
  2737. static const struct soc_enum afe_bit_format_enum[] = {
  2738. SOC_ENUM_SINGLE_EXT(3, afe_bit_format_text),
  2739. };
  2740. static const char *const tws_chs_mode_text[] = {"Zero", "One", "Two"};
  2741. static const struct soc_enum tws_chs_mode_enum[] = {
  2742. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tws_chs_mode_text), tws_chs_mode_text),
  2743. };
  2744. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2745. struct snd_ctl_elem_value *ucontrol)
  2746. {
  2747. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2748. if (dai_data) {
  2749. ucontrol->value.integer.value[0] = dai_data->afe_rx_in_channels;
  2750. pr_debug("%s:afe input channel = %d\n",
  2751. __func__, dai_data->afe_rx_in_channels);
  2752. }
  2753. return 0;
  2754. }
  2755. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2756. struct snd_ctl_elem_value *ucontrol)
  2757. {
  2758. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2759. if (dai_data) {
  2760. dai_data->afe_rx_in_channels = ucontrol->value.integer.value[0];
  2761. pr_debug("%s: updating afe input channel : %d\n",
  2762. __func__, dai_data->afe_rx_in_channels);
  2763. }
  2764. return 0;
  2765. }
  2766. static int msm_dai_q6_tws_channel_mode_get(struct snd_kcontrol *kcontrol,
  2767. struct snd_ctl_elem_value *ucontrol)
  2768. {
  2769. struct snd_soc_dai *dai = kcontrol->private_data;
  2770. struct msm_dai_q6_dai_data *dai_data = NULL;
  2771. if (dai)
  2772. dai_data = dev_get_drvdata(dai->dev);
  2773. if (dai_data) {
  2774. ucontrol->value.integer.value[0] =
  2775. dai_data->enc_config.mono_mode;
  2776. pr_debug("%s:tws channel mode = %d\n",
  2777. __func__, dai_data->enc_config.mono_mode);
  2778. }
  2779. return 0;
  2780. }
  2781. static int msm_dai_q6_tws_channel_mode_put(struct snd_kcontrol *kcontrol,
  2782. struct snd_ctl_elem_value *ucontrol)
  2783. {
  2784. struct snd_soc_dai *dai = kcontrol->private_data;
  2785. struct msm_dai_q6_dai_data *dai_data = NULL;
  2786. int ret = 0;
  2787. if (dai)
  2788. dai_data = dev_get_drvdata(dai->dev);
  2789. if (dai_data && (dai_data->enc_config.format == ENC_FMT_APTX)) {
  2790. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2791. ret = afe_set_tws_channel_mode(dai->id,
  2792. ucontrol->value.integer.value[0]);
  2793. if (ret < 0) {
  2794. pr_err("%s: channel mode setting failed for TWS\n",
  2795. __func__);
  2796. goto exit;
  2797. } else {
  2798. pr_debug("%s: updating tws channel mode : %d\n",
  2799. __func__, dai_data->enc_config.mono_mode);
  2800. }
  2801. }
  2802. if (ucontrol->value.integer.value[0] ==
  2803. MSM_DAI_TWS_CHANNEL_MODE_ONE ||
  2804. ucontrol->value.integer.value[0] ==
  2805. MSM_DAI_TWS_CHANNEL_MODE_TWO)
  2806. dai_data->enc_config.mono_mode =
  2807. ucontrol->value.integer.value[0];
  2808. else
  2809. return -EINVAL;
  2810. }
  2811. exit:
  2812. return ret;
  2813. }
  2814. static int msm_dai_q6_afe_input_bit_format_get(
  2815. struct snd_kcontrol *kcontrol,
  2816. struct snd_ctl_elem_value *ucontrol)
  2817. {
  2818. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2819. if (!dai_data) {
  2820. pr_err("%s: Invalid dai data\n", __func__);
  2821. return -EINVAL;
  2822. }
  2823. switch (dai_data->afe_rx_in_bitformat) {
  2824. case SNDRV_PCM_FORMAT_S32_LE:
  2825. ucontrol->value.integer.value[0] = 2;
  2826. break;
  2827. case SNDRV_PCM_FORMAT_S24_LE:
  2828. ucontrol->value.integer.value[0] = 1;
  2829. break;
  2830. case SNDRV_PCM_FORMAT_S16_LE:
  2831. default:
  2832. ucontrol->value.integer.value[0] = 0;
  2833. break;
  2834. }
  2835. pr_debug("%s: afe input bit format : %ld\n",
  2836. __func__, ucontrol->value.integer.value[0]);
  2837. return 0;
  2838. }
  2839. static int msm_dai_q6_afe_input_bit_format_put(
  2840. struct snd_kcontrol *kcontrol,
  2841. struct snd_ctl_elem_value *ucontrol)
  2842. {
  2843. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2844. if (!dai_data) {
  2845. pr_err("%s: Invalid dai data\n", __func__);
  2846. return -EINVAL;
  2847. }
  2848. switch (ucontrol->value.integer.value[0]) {
  2849. case 2:
  2850. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  2851. break;
  2852. case 1:
  2853. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2854. break;
  2855. case 0:
  2856. default:
  2857. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2858. break;
  2859. }
  2860. pr_debug("%s: updating afe input bit format : %d\n",
  2861. __func__, dai_data->afe_rx_in_bitformat);
  2862. return 0;
  2863. }
  2864. static int msm_dai_q6_afe_output_bit_format_get(
  2865. struct snd_kcontrol *kcontrol,
  2866. struct snd_ctl_elem_value *ucontrol)
  2867. {
  2868. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2869. if (!dai_data) {
  2870. pr_err("%s: Invalid dai data\n", __func__);
  2871. return -EINVAL;
  2872. }
  2873. switch (dai_data->afe_tx_out_bitformat) {
  2874. case SNDRV_PCM_FORMAT_S32_LE:
  2875. ucontrol->value.integer.value[0] = 2;
  2876. break;
  2877. case SNDRV_PCM_FORMAT_S24_LE:
  2878. ucontrol->value.integer.value[0] = 1;
  2879. break;
  2880. case SNDRV_PCM_FORMAT_S16_LE:
  2881. default:
  2882. ucontrol->value.integer.value[0] = 0;
  2883. break;
  2884. }
  2885. pr_debug("%s: afe output bit format : %ld\n",
  2886. __func__, ucontrol->value.integer.value[0]);
  2887. return 0;
  2888. }
  2889. static int msm_dai_q6_afe_output_bit_format_put(
  2890. struct snd_kcontrol *kcontrol,
  2891. struct snd_ctl_elem_value *ucontrol)
  2892. {
  2893. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2894. if (!dai_data) {
  2895. pr_err("%s: Invalid dai data\n", __func__);
  2896. return -EINVAL;
  2897. }
  2898. switch (ucontrol->value.integer.value[0]) {
  2899. case 2:
  2900. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  2901. break;
  2902. case 1:
  2903. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2904. break;
  2905. case 0:
  2906. default:
  2907. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2908. break;
  2909. }
  2910. pr_debug("%s: updating afe output bit format : %d\n",
  2911. __func__, dai_data->afe_tx_out_bitformat);
  2912. return 0;
  2913. }
  2914. static int msm_dai_q6_afe_output_channel_get(struct snd_kcontrol *kcontrol,
  2915. struct snd_ctl_elem_value *ucontrol)
  2916. {
  2917. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2918. if (dai_data) {
  2919. ucontrol->value.integer.value[0] =
  2920. dai_data->afe_tx_out_channels;
  2921. pr_debug("%s:afe output channel = %d\n",
  2922. __func__, dai_data->afe_tx_out_channels);
  2923. }
  2924. return 0;
  2925. }
  2926. static int msm_dai_q6_afe_output_channel_put(struct snd_kcontrol *kcontrol,
  2927. struct snd_ctl_elem_value *ucontrol)
  2928. {
  2929. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2930. if (dai_data) {
  2931. dai_data->afe_tx_out_channels =
  2932. ucontrol->value.integer.value[0];
  2933. pr_debug("%s: updating afe output channel : %d\n",
  2934. __func__, dai_data->afe_tx_out_channels);
  2935. }
  2936. return 0;
  2937. }
  2938. static int msm_dai_q6_afe_scrambler_mode_get(
  2939. struct snd_kcontrol *kcontrol,
  2940. struct snd_ctl_elem_value *ucontrol)
  2941. {
  2942. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2943. if (!dai_data) {
  2944. pr_err("%s: Invalid dai data\n", __func__);
  2945. return -EINVAL;
  2946. }
  2947. ucontrol->value.integer.value[0] = dai_data->enc_config.scrambler_mode;
  2948. return 0;
  2949. }
  2950. static int msm_dai_q6_afe_scrambler_mode_put(
  2951. struct snd_kcontrol *kcontrol,
  2952. struct snd_ctl_elem_value *ucontrol)
  2953. {
  2954. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2955. if (!dai_data) {
  2956. pr_err("%s: Invalid dai data\n", __func__);
  2957. return -EINVAL;
  2958. }
  2959. dai_data->enc_config.scrambler_mode = ucontrol->value.integer.value[0];
  2960. pr_debug("%s: afe scrambler mode : %d\n",
  2961. __func__, dai_data->enc_config.scrambler_mode);
  2962. return 0;
  2963. }
  2964. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  2965. {
  2966. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2967. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2968. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2969. .name = "SLIM_7_RX Encoder Config",
  2970. .info = msm_dai_q6_afe_enc_cfg_info,
  2971. .get = msm_dai_q6_afe_enc_cfg_get,
  2972. .put = msm_dai_q6_afe_enc_cfg_put,
  2973. },
  2974. {
  2975. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2976. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2977. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2978. .name = "SLIM_7_RX APTX_AD Enc Cfg",
  2979. .info = msm_dai_q6_afe_enc_cfg_info,
  2980. .get = msm_dai_q6_afe_enc_cfg_get,
  2981. .put = msm_dai_q6_afe_enc_cfg_put,
  2982. },
  2983. SOC_ENUM_EXT("AFE Input Channels", afe_chs_enum[0],
  2984. msm_dai_q6_afe_input_channel_get,
  2985. msm_dai_q6_afe_input_channel_put),
  2986. SOC_ENUM_EXT("AFE Input Bit Format", afe_bit_format_enum[0],
  2987. msm_dai_q6_afe_input_bit_format_get,
  2988. msm_dai_q6_afe_input_bit_format_put),
  2989. SOC_SINGLE_EXT("AFE Scrambler Mode",
  2990. 0, 0, 1, 0,
  2991. msm_dai_q6_afe_scrambler_mode_get,
  2992. msm_dai_q6_afe_scrambler_mode_put),
  2993. SOC_ENUM_EXT("TWS Channel Mode", tws_chs_mode_enum[0],
  2994. msm_dai_q6_tws_channel_mode_get,
  2995. msm_dai_q6_tws_channel_mode_put)
  2996. };
  2997. static int msm_dai_q6_afe_dec_cfg_info(struct snd_kcontrol *kcontrol,
  2998. struct snd_ctl_elem_info *uinfo)
  2999. {
  3000. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3001. uinfo->count = sizeof(struct afe_dec_config);
  3002. return 0;
  3003. }
  3004. static int msm_dai_q6_afe_feedback_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3005. struct snd_ctl_elem_value *ucontrol)
  3006. {
  3007. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3008. u32 format_size = 0;
  3009. u32 abr_size = 0;
  3010. if (!dai_data) {
  3011. pr_err("%s: Invalid dai data\n", __func__);
  3012. return -EINVAL;
  3013. }
  3014. format_size = sizeof(dai_data->dec_config.format);
  3015. memcpy(ucontrol->value.bytes.data,
  3016. &dai_data->dec_config.format,
  3017. format_size);
  3018. pr_debug("%s: abr_dec_cfg for %d format\n",
  3019. __func__, dai_data->dec_config.format);
  3020. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3021. memcpy(ucontrol->value.bytes.data + format_size,
  3022. &dai_data->dec_config.abr_dec_cfg,
  3023. sizeof(struct afe_imc_dec_enc_info));
  3024. switch (dai_data->dec_config.format) {
  3025. case DEC_FMT_APTX_AD_SPEECH:
  3026. pr_debug("%s: afe_dec_cfg for %d format\n",
  3027. __func__, dai_data->dec_config.format);
  3028. memcpy(ucontrol->value.bytes.data + format_size + abr_size,
  3029. &dai_data->dec_config.data,
  3030. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3031. break;
  3032. default:
  3033. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3034. __func__, dai_data->dec_config.format);
  3035. break;
  3036. }
  3037. return 0;
  3038. }
  3039. static int msm_dai_q6_afe_feedback_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3040. struct snd_ctl_elem_value *ucontrol)
  3041. {
  3042. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3043. u32 format_size = 0;
  3044. u32 abr_size = 0;
  3045. if (!dai_data) {
  3046. pr_err("%s: Invalid dai data\n", __func__);
  3047. return -EINVAL;
  3048. }
  3049. memset(&dai_data->dec_config, 0x0,
  3050. sizeof(struct afe_dec_config));
  3051. format_size = sizeof(dai_data->dec_config.format);
  3052. memcpy(&dai_data->dec_config.format,
  3053. ucontrol->value.bytes.data,
  3054. format_size);
  3055. pr_debug("%s: abr_dec_cfg for %d format\n",
  3056. __func__, dai_data->dec_config.format);
  3057. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3058. memcpy(&dai_data->dec_config.abr_dec_cfg,
  3059. ucontrol->value.bytes.data + format_size,
  3060. sizeof(struct afe_imc_dec_enc_info));
  3061. dai_data->dec_config.abr_dec_cfg.is_abr_enabled = true;
  3062. switch (dai_data->dec_config.format) {
  3063. case DEC_FMT_APTX_AD_SPEECH:
  3064. pr_debug("%s: afe_dec_cfg for %d format\n",
  3065. __func__, dai_data->dec_config.format);
  3066. memcpy(&dai_data->dec_config.data,
  3067. ucontrol->value.bytes.data + format_size + abr_size,
  3068. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3069. break;
  3070. default:
  3071. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3072. __func__, dai_data->dec_config.format);
  3073. break;
  3074. }
  3075. return 0;
  3076. }
  3077. static int msm_dai_q6_afe_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3078. struct snd_ctl_elem_value *ucontrol)
  3079. {
  3080. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3081. u32 format_size = 0;
  3082. int ret = 0;
  3083. if (!dai_data) {
  3084. pr_err("%s: Invalid dai data\n", __func__);
  3085. return -EINVAL;
  3086. }
  3087. format_size = sizeof(dai_data->dec_config.format);
  3088. memcpy(ucontrol->value.bytes.data,
  3089. &dai_data->dec_config.format,
  3090. format_size);
  3091. switch (dai_data->dec_config.format) {
  3092. case DEC_FMT_AAC_V2:
  3093. memcpy(ucontrol->value.bytes.data + format_size,
  3094. &dai_data->dec_config.data,
  3095. sizeof(struct asm_aac_dec_cfg_v2_t));
  3096. break;
  3097. case DEC_FMT_APTX_ADAPTIVE:
  3098. memcpy(ucontrol->value.bytes.data + format_size,
  3099. &dai_data->dec_config.data,
  3100. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3101. break;
  3102. case DEC_FMT_SBC:
  3103. case DEC_FMT_MP3:
  3104. /* No decoder specific data available */
  3105. break;
  3106. default:
  3107. pr_err("%s: Invalid format %d\n",
  3108. __func__, dai_data->dec_config.format);
  3109. ret = -EINVAL;
  3110. break;
  3111. }
  3112. return ret;
  3113. }
  3114. static int msm_dai_q6_afe_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3115. struct snd_ctl_elem_value *ucontrol)
  3116. {
  3117. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3118. u32 format_size = 0;
  3119. int ret = 0;
  3120. if (!dai_data) {
  3121. pr_err("%s: Invalid dai data\n", __func__);
  3122. return -EINVAL;
  3123. }
  3124. memset(&dai_data->dec_config, 0x0,
  3125. sizeof(struct afe_dec_config));
  3126. format_size = sizeof(dai_data->dec_config.format);
  3127. memcpy(&dai_data->dec_config.format,
  3128. ucontrol->value.bytes.data,
  3129. format_size);
  3130. pr_debug("%s: Received decoder config for %d format\n",
  3131. __func__, dai_data->dec_config.format);
  3132. switch (dai_data->dec_config.format) {
  3133. case DEC_FMT_AAC_V2:
  3134. memcpy(&dai_data->dec_config.data,
  3135. ucontrol->value.bytes.data + format_size,
  3136. sizeof(struct asm_aac_dec_cfg_v2_t));
  3137. break;
  3138. case DEC_FMT_SBC:
  3139. memcpy(&dai_data->dec_config.data,
  3140. ucontrol->value.bytes.data + format_size,
  3141. sizeof(struct asm_sbc_dec_cfg_t));
  3142. break;
  3143. case DEC_FMT_APTX_ADAPTIVE:
  3144. memcpy(&dai_data->dec_config.data,
  3145. ucontrol->value.bytes.data + format_size,
  3146. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3147. break;
  3148. default:
  3149. pr_err("%s: Invalid format %d\n",
  3150. __func__, dai_data->dec_config.format);
  3151. ret = -EINVAL;
  3152. break;
  3153. }
  3154. return ret;
  3155. }
  3156. static const struct snd_kcontrol_new afe_dec_config_controls[] = {
  3157. {
  3158. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3159. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3160. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3161. .name = "SLIM_7_TX Decoder Config",
  3162. .info = msm_dai_q6_afe_dec_cfg_info,
  3163. .get = msm_dai_q6_afe_feedback_dec_cfg_get,
  3164. .put = msm_dai_q6_afe_feedback_dec_cfg_put,
  3165. },
  3166. {
  3167. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3168. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3169. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3170. .name = "SLIM_9_TX Decoder Config",
  3171. .info = msm_dai_q6_afe_dec_cfg_info,
  3172. .get = msm_dai_q6_afe_dec_cfg_get,
  3173. .put = msm_dai_q6_afe_dec_cfg_put,
  3174. },
  3175. SOC_ENUM_EXT("AFE Output Channels", afe_chs_enum[0],
  3176. msm_dai_q6_afe_output_channel_get,
  3177. msm_dai_q6_afe_output_channel_put),
  3178. SOC_ENUM_EXT("AFE Output Bit Format", afe_bit_format_enum[0],
  3179. msm_dai_q6_afe_output_bit_format_get,
  3180. msm_dai_q6_afe_output_bit_format_put),
  3181. };
  3182. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  3183. struct snd_ctl_elem_info *uinfo)
  3184. {
  3185. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3186. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  3187. return 0;
  3188. }
  3189. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  3190. struct snd_ctl_elem_value *ucontrol)
  3191. {
  3192. int ret = -EINVAL;
  3193. struct afe_param_id_dev_timing_stats timing_stats;
  3194. struct snd_soc_dai *dai = kcontrol->private_data;
  3195. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3196. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3197. pr_debug("%s: afe port not started. dai_data->status_mask = %ld\n",
  3198. __func__, *dai_data->status_mask);
  3199. goto done;
  3200. }
  3201. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  3202. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  3203. if (ret) {
  3204. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  3205. __func__, dai->id, ret);
  3206. goto done;
  3207. }
  3208. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  3209. sizeof(struct afe_param_id_dev_timing_stats));
  3210. done:
  3211. return ret;
  3212. }
  3213. static const char * const afe_cal_mode_text[] = {
  3214. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  3215. };
  3216. static const struct soc_enum slim_2_rx_enum =
  3217. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3218. afe_cal_mode_text);
  3219. static const struct soc_enum rt_proxy_1_rx_enum =
  3220. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3221. afe_cal_mode_text);
  3222. static const struct soc_enum rt_proxy_1_tx_enum =
  3223. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3224. afe_cal_mode_text);
  3225. static const struct snd_kcontrol_new sb_config_controls[] = {
  3226. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  3227. msm_dai_q6_sb_format_get,
  3228. msm_dai_q6_sb_format_put),
  3229. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  3230. msm_dai_q6_cal_info_get,
  3231. msm_dai_q6_cal_info_put),
  3232. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  3233. msm_dai_q6_sb_format_get,
  3234. msm_dai_q6_sb_format_put)
  3235. };
  3236. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  3237. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  3238. msm_dai_q6_cal_info_get,
  3239. msm_dai_q6_cal_info_put),
  3240. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  3241. msm_dai_q6_cal_info_get,
  3242. msm_dai_q6_cal_info_put),
  3243. };
  3244. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  3245. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  3246. msm_dai_q6_usb_audio_cfg_get,
  3247. msm_dai_q6_usb_audio_cfg_put),
  3248. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  3249. msm_dai_q6_usb_audio_endian_cfg_get,
  3250. msm_dai_q6_usb_audio_endian_cfg_put),
  3251. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  3252. msm_dai_q6_usb_audio_cfg_get,
  3253. msm_dai_q6_usb_audio_cfg_put),
  3254. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  3255. msm_dai_q6_usb_audio_endian_cfg_get,
  3256. msm_dai_q6_usb_audio_endian_cfg_put),
  3257. SOC_SINGLE_EXT("USB_AUDIO_RX service_interval", SND_SOC_NOPM, 0,
  3258. UINT_MAX, 0,
  3259. msm_dai_q6_usb_audio_svc_interval_get,
  3260. msm_dai_q6_usb_audio_svc_interval_put),
  3261. };
  3262. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  3263. {
  3264. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3265. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3266. .name = "SLIMBUS_0_RX DRIFT",
  3267. .info = msm_dai_q6_slim_rx_drift_info,
  3268. .get = msm_dai_q6_slim_rx_drift_get,
  3269. },
  3270. {
  3271. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3272. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3273. .name = "SLIMBUS_6_RX DRIFT",
  3274. .info = msm_dai_q6_slim_rx_drift_info,
  3275. .get = msm_dai_q6_slim_rx_drift_get,
  3276. },
  3277. {
  3278. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3279. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3280. .name = "SLIMBUS_7_RX DRIFT",
  3281. .info = msm_dai_q6_slim_rx_drift_info,
  3282. .get = msm_dai_q6_slim_rx_drift_get,
  3283. },
  3284. };
  3285. static inline void msm_dai_q6_set_slim_dev_id(struct snd_soc_dai *dai)
  3286. {
  3287. int rc = 0;
  3288. int slim_dev_id = 0;
  3289. const char *q6_slim_dev_id = "qcom,msm-dai-q6-slim-dev-id";
  3290. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3291. dai_data->port_config.slim_sch.slimbus_dev_id = AFE_SLIMBUS_DEVICE_1;
  3292. rc = of_property_read_u32(dai->dev->of_node, q6_slim_dev_id,
  3293. &slim_dev_id);
  3294. if (rc) {
  3295. dev_dbg(dai->dev,
  3296. "%s: missing %s in dt node\n", __func__, q6_slim_dev_id);
  3297. return;
  3298. }
  3299. dev_dbg(dai->dev, "%s: slim_dev_id = %d\n", __func__, slim_dev_id);
  3300. if (slim_dev_id >= AFE_SLIMBUS_DEVICE_1 &&
  3301. slim_dev_id <= AFE_SLIMBUS_DEVICE_2)
  3302. dai_data->port_config.slim_sch.slimbus_dev_id = slim_dev_id;
  3303. }
  3304. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  3305. {
  3306. struct msm_dai_q6_dai_data *dai_data;
  3307. int rc = 0;
  3308. if (!dai) {
  3309. pr_err("%s: Invalid params dai\n", __func__);
  3310. return -EINVAL;
  3311. }
  3312. if (!dai->dev) {
  3313. pr_err("%s: Invalid params dai dev\n", __func__);
  3314. return -EINVAL;
  3315. }
  3316. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  3317. if (!dai_data)
  3318. return -ENOMEM;
  3319. else
  3320. dev_set_drvdata(dai->dev, dai_data);
  3321. msm_dai_q6_set_dai_id(dai);
  3322. if ((dai->id >= SLIMBUS_0_RX) && (dai->id <= SLIMBUS_9_TX))
  3323. msm_dai_q6_set_slim_dev_id(dai);
  3324. switch (dai->id) {
  3325. case SLIMBUS_4_TX:
  3326. rc = snd_ctl_add(dai->component->card->snd_card,
  3327. snd_ctl_new1(&sb_config_controls[0],
  3328. dai_data));
  3329. break;
  3330. case SLIMBUS_2_RX:
  3331. rc = snd_ctl_add(dai->component->card->snd_card,
  3332. snd_ctl_new1(&sb_config_controls[1],
  3333. dai_data));
  3334. rc = snd_ctl_add(dai->component->card->snd_card,
  3335. snd_ctl_new1(&sb_config_controls[2],
  3336. dai_data));
  3337. break;
  3338. case SLIMBUS_7_RX:
  3339. rc = snd_ctl_add(dai->component->card->snd_card,
  3340. snd_ctl_new1(&afe_enc_config_controls[0],
  3341. dai_data));
  3342. rc = snd_ctl_add(dai->component->card->snd_card,
  3343. snd_ctl_new1(&afe_enc_config_controls[1],
  3344. dai_data));
  3345. rc = snd_ctl_add(dai->component->card->snd_card,
  3346. snd_ctl_new1(&afe_enc_config_controls[2],
  3347. dai_data));
  3348. rc = snd_ctl_add(dai->component->card->snd_card,
  3349. snd_ctl_new1(&afe_enc_config_controls[3],
  3350. dai_data));
  3351. rc = snd_ctl_add(dai->component->card->snd_card,
  3352. snd_ctl_new1(&afe_enc_config_controls[4],
  3353. dai));
  3354. rc = snd_ctl_add(dai->component->card->snd_card,
  3355. snd_ctl_new1(&avd_drift_config_controls[2],
  3356. dai));
  3357. break;
  3358. case SLIMBUS_7_TX:
  3359. rc = snd_ctl_add(dai->component->card->snd_card,
  3360. snd_ctl_new1(&afe_dec_config_controls[0],
  3361. dai_data));
  3362. break;
  3363. case SLIMBUS_9_TX:
  3364. rc = snd_ctl_add(dai->component->card->snd_card,
  3365. snd_ctl_new1(&afe_dec_config_controls[1],
  3366. dai_data));
  3367. rc = snd_ctl_add(dai->component->card->snd_card,
  3368. snd_ctl_new1(&afe_dec_config_controls[2],
  3369. dai_data));
  3370. rc = snd_ctl_add(dai->component->card->snd_card,
  3371. snd_ctl_new1(&afe_dec_config_controls[3],
  3372. dai_data));
  3373. break;
  3374. case RT_PROXY_DAI_001_RX:
  3375. rc = snd_ctl_add(dai->component->card->snd_card,
  3376. snd_ctl_new1(&rt_proxy_config_controls[0],
  3377. dai_data));
  3378. break;
  3379. case RT_PROXY_DAI_001_TX:
  3380. rc = snd_ctl_add(dai->component->card->snd_card,
  3381. snd_ctl_new1(&rt_proxy_config_controls[1],
  3382. dai_data));
  3383. break;
  3384. case AFE_PORT_ID_USB_RX:
  3385. rc = snd_ctl_add(dai->component->card->snd_card,
  3386. snd_ctl_new1(&usb_audio_cfg_controls[0],
  3387. dai_data));
  3388. rc = snd_ctl_add(dai->component->card->snd_card,
  3389. snd_ctl_new1(&usb_audio_cfg_controls[1],
  3390. dai_data));
  3391. rc = snd_ctl_add(dai->component->card->snd_card,
  3392. snd_ctl_new1(&usb_audio_cfg_controls[4],
  3393. dai_data));
  3394. break;
  3395. case AFE_PORT_ID_USB_TX:
  3396. rc = snd_ctl_add(dai->component->card->snd_card,
  3397. snd_ctl_new1(&usb_audio_cfg_controls[2],
  3398. dai_data));
  3399. rc = snd_ctl_add(dai->component->card->snd_card,
  3400. snd_ctl_new1(&usb_audio_cfg_controls[3],
  3401. dai_data));
  3402. break;
  3403. case SLIMBUS_0_RX:
  3404. rc = snd_ctl_add(dai->component->card->snd_card,
  3405. snd_ctl_new1(&avd_drift_config_controls[0],
  3406. dai));
  3407. break;
  3408. case SLIMBUS_6_RX:
  3409. rc = snd_ctl_add(dai->component->card->snd_card,
  3410. snd_ctl_new1(&avd_drift_config_controls[1],
  3411. dai));
  3412. break;
  3413. }
  3414. if (rc < 0)
  3415. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  3416. __func__, dai->name);
  3417. rc = msm_dai_q6_dai_add_route(dai);
  3418. return rc;
  3419. }
  3420. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  3421. {
  3422. struct msm_dai_q6_dai_data *dai_data;
  3423. int rc;
  3424. dai_data = dev_get_drvdata(dai->dev);
  3425. /* If AFE port is still up, close it */
  3426. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3427. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  3428. rc = afe_close(dai->id); /* can block */
  3429. if (rc < 0)
  3430. dev_err(dai->dev, "fail to close AFE port\n");
  3431. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  3432. }
  3433. kfree(dai_data);
  3434. return 0;
  3435. }
  3436. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  3437. {
  3438. .playback = {
  3439. .stream_name = "AFE Playback",
  3440. .aif_name = "PCM_RX",
  3441. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3442. SNDRV_PCM_RATE_16000,
  3443. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3444. SNDRV_PCM_FMTBIT_S24_LE,
  3445. .channels_min = 1,
  3446. .channels_max = 2,
  3447. .rate_min = 8000,
  3448. .rate_max = 48000,
  3449. },
  3450. .ops = &msm_dai_q6_ops,
  3451. .id = RT_PROXY_DAI_001_RX,
  3452. .probe = msm_dai_q6_dai_probe,
  3453. .remove = msm_dai_q6_dai_remove,
  3454. },
  3455. {
  3456. .playback = {
  3457. .stream_name = "AFE-PROXY RX",
  3458. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3459. SNDRV_PCM_RATE_16000,
  3460. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3461. SNDRV_PCM_FMTBIT_S24_LE,
  3462. .channels_min = 1,
  3463. .channels_max = 2,
  3464. .rate_min = 8000,
  3465. .rate_max = 48000,
  3466. },
  3467. .ops = &msm_dai_q6_ops,
  3468. .id = RT_PROXY_DAI_002_RX,
  3469. .probe = msm_dai_q6_dai_probe,
  3470. .remove = msm_dai_q6_dai_remove,
  3471. },
  3472. };
  3473. static struct snd_soc_dai_driver msm_dai_q6_afe_lb_tx_dai[] = {
  3474. {
  3475. .capture = {
  3476. .stream_name = "AFE Loopback Capture",
  3477. .aif_name = "AFE_LOOPBACK_TX",
  3478. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3479. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3480. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3481. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3482. SNDRV_PCM_RATE_192000,
  3483. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  3484. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_3LE |
  3485. SNDRV_PCM_FMTBIT_S32_LE ),
  3486. .channels_min = 1,
  3487. .channels_max = 8,
  3488. .rate_min = 8000,
  3489. .rate_max = 192000,
  3490. },
  3491. .id = AFE_LOOPBACK_TX,
  3492. .probe = msm_dai_q6_dai_probe,
  3493. .remove = msm_dai_q6_dai_remove,
  3494. },
  3495. };
  3496. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  3497. {
  3498. .capture = {
  3499. .stream_name = "AFE Capture",
  3500. .aif_name = "PCM_TX",
  3501. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3502. SNDRV_PCM_RATE_16000,
  3503. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3504. .channels_min = 1,
  3505. .channels_max = 8,
  3506. .rate_min = 8000,
  3507. .rate_max = 48000,
  3508. },
  3509. .ops = &msm_dai_q6_ops,
  3510. .id = RT_PROXY_DAI_002_TX,
  3511. .probe = msm_dai_q6_dai_probe,
  3512. .remove = msm_dai_q6_dai_remove,
  3513. },
  3514. {
  3515. .capture = {
  3516. .stream_name = "AFE-PROXY TX",
  3517. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3518. SNDRV_PCM_RATE_16000,
  3519. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3520. .channels_min = 1,
  3521. .channels_max = 8,
  3522. .rate_min = 8000,
  3523. .rate_max = 48000,
  3524. },
  3525. .ops = &msm_dai_q6_ops,
  3526. .id = RT_PROXY_DAI_001_TX,
  3527. .probe = msm_dai_q6_dai_probe,
  3528. .remove = msm_dai_q6_dai_remove,
  3529. },
  3530. };
  3531. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  3532. .playback = {
  3533. .stream_name = "Internal BT-SCO Playback",
  3534. .aif_name = "INT_BT_SCO_RX",
  3535. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3536. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3537. .channels_min = 1,
  3538. .channels_max = 1,
  3539. .rate_max = 16000,
  3540. .rate_min = 8000,
  3541. },
  3542. .ops = &msm_dai_q6_ops,
  3543. .id = INT_BT_SCO_RX,
  3544. .probe = msm_dai_q6_dai_probe,
  3545. .remove = msm_dai_q6_dai_remove,
  3546. };
  3547. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  3548. .playback = {
  3549. .stream_name = "Internal BT-A2DP Playback",
  3550. .aif_name = "INT_BT_A2DP_RX",
  3551. .rates = SNDRV_PCM_RATE_48000,
  3552. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3553. .channels_min = 1,
  3554. .channels_max = 2,
  3555. .rate_max = 48000,
  3556. .rate_min = 48000,
  3557. },
  3558. .ops = &msm_dai_q6_ops,
  3559. .id = INT_BT_A2DP_RX,
  3560. .probe = msm_dai_q6_dai_probe,
  3561. .remove = msm_dai_q6_dai_remove,
  3562. };
  3563. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  3564. .capture = {
  3565. .stream_name = "Internal BT-SCO Capture",
  3566. .aif_name = "INT_BT_SCO_TX",
  3567. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3568. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3569. .channels_min = 1,
  3570. .channels_max = 1,
  3571. .rate_max = 16000,
  3572. .rate_min = 8000,
  3573. },
  3574. .ops = &msm_dai_q6_ops,
  3575. .id = INT_BT_SCO_TX,
  3576. .probe = msm_dai_q6_dai_probe,
  3577. .remove = msm_dai_q6_dai_remove,
  3578. };
  3579. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  3580. .playback = {
  3581. .stream_name = "Internal FM Playback",
  3582. .aif_name = "INT_FM_RX",
  3583. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3584. SNDRV_PCM_RATE_16000,
  3585. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3586. .channels_min = 2,
  3587. .channels_max = 2,
  3588. .rate_max = 48000,
  3589. .rate_min = 8000,
  3590. },
  3591. .ops = &msm_dai_q6_ops,
  3592. .id = INT_FM_RX,
  3593. .probe = msm_dai_q6_dai_probe,
  3594. .remove = msm_dai_q6_dai_remove,
  3595. };
  3596. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  3597. .capture = {
  3598. .stream_name = "Internal FM Capture",
  3599. .aif_name = "INT_FM_TX",
  3600. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3601. SNDRV_PCM_RATE_16000,
  3602. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3603. .channels_min = 2,
  3604. .channels_max = 2,
  3605. .rate_max = 48000,
  3606. .rate_min = 8000,
  3607. },
  3608. .ops = &msm_dai_q6_ops,
  3609. .id = INT_FM_TX,
  3610. .probe = msm_dai_q6_dai_probe,
  3611. .remove = msm_dai_q6_dai_remove,
  3612. };
  3613. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  3614. {
  3615. .playback = {
  3616. .stream_name = "Voice Farend Playback",
  3617. .aif_name = "VOICE_PLAYBACK_TX",
  3618. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3619. SNDRV_PCM_RATE_16000,
  3620. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3621. .channels_min = 1,
  3622. .channels_max = 2,
  3623. .rate_min = 8000,
  3624. .rate_max = 48000,
  3625. },
  3626. .ops = &msm_dai_q6_ops,
  3627. .id = VOICE_PLAYBACK_TX,
  3628. .probe = msm_dai_q6_dai_probe,
  3629. .remove = msm_dai_q6_dai_remove,
  3630. },
  3631. {
  3632. .playback = {
  3633. .stream_name = "Voice2 Farend Playback",
  3634. .aif_name = "VOICE2_PLAYBACK_TX",
  3635. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3636. SNDRV_PCM_RATE_16000,
  3637. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3638. .channels_min = 1,
  3639. .channels_max = 2,
  3640. .rate_min = 8000,
  3641. .rate_max = 48000,
  3642. },
  3643. .ops = &msm_dai_q6_ops,
  3644. .id = VOICE2_PLAYBACK_TX,
  3645. .probe = msm_dai_q6_dai_probe,
  3646. .remove = msm_dai_q6_dai_remove,
  3647. },
  3648. };
  3649. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  3650. {
  3651. .capture = {
  3652. .stream_name = "Voice Uplink Capture",
  3653. .aif_name = "INCALL_RECORD_TX",
  3654. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3655. SNDRV_PCM_RATE_16000,
  3656. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3657. .channels_min = 1,
  3658. .channels_max = 2,
  3659. .rate_min = 8000,
  3660. .rate_max = 48000,
  3661. },
  3662. .ops = &msm_dai_q6_ops,
  3663. .id = VOICE_RECORD_TX,
  3664. .probe = msm_dai_q6_dai_probe,
  3665. .remove = msm_dai_q6_dai_remove,
  3666. },
  3667. {
  3668. .capture = {
  3669. .stream_name = "Voice Downlink Capture",
  3670. .aif_name = "INCALL_RECORD_RX",
  3671. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3672. SNDRV_PCM_RATE_16000,
  3673. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3674. .channels_min = 1,
  3675. .channels_max = 2,
  3676. .rate_min = 8000,
  3677. .rate_max = 48000,
  3678. },
  3679. .ops = &msm_dai_q6_ops,
  3680. .id = VOICE_RECORD_RX,
  3681. .probe = msm_dai_q6_dai_probe,
  3682. .remove = msm_dai_q6_dai_remove,
  3683. },
  3684. };
  3685. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  3686. .playback = {
  3687. .stream_name = "USB Audio Playback",
  3688. .aif_name = "USB_AUDIO_RX",
  3689. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3690. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3691. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3692. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3693. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3694. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3695. SNDRV_PCM_RATE_384000,
  3696. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3697. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3698. .channels_min = 1,
  3699. .channels_max = 8,
  3700. .rate_max = 384000,
  3701. .rate_min = 8000,
  3702. },
  3703. .ops = &msm_dai_q6_ops,
  3704. .id = AFE_PORT_ID_USB_RX,
  3705. .probe = msm_dai_q6_dai_probe,
  3706. .remove = msm_dai_q6_dai_remove,
  3707. };
  3708. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  3709. .capture = {
  3710. .stream_name = "USB Audio Capture",
  3711. .aif_name = "USB_AUDIO_TX",
  3712. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3713. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3714. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3715. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3716. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3717. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3718. SNDRV_PCM_RATE_384000,
  3719. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3720. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3721. .channels_min = 1,
  3722. .channels_max = 8,
  3723. .rate_max = 384000,
  3724. .rate_min = 8000,
  3725. },
  3726. .ops = &msm_dai_q6_ops,
  3727. .id = AFE_PORT_ID_USB_TX,
  3728. .probe = msm_dai_q6_dai_probe,
  3729. .remove = msm_dai_q6_dai_remove,
  3730. };
  3731. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  3732. {
  3733. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3734. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  3735. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  3736. uint32_t val = 0;
  3737. const char *intf_name;
  3738. int rc = 0, i = 0, len = 0;
  3739. const uint32_t *slot_mapping_array = NULL;
  3740. u32 array_length = 0;
  3741. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  3742. GFP_KERNEL);
  3743. if (!dai_data)
  3744. return -ENOMEM;
  3745. rc = of_property_read_u32(pdev->dev.of_node,
  3746. "qcom,msm-dai-is-island-supported",
  3747. &dai_data->is_island_dai);
  3748. if (rc)
  3749. dev_dbg(&pdev->dev, "island supported entry not found\n");
  3750. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  3751. GFP_KERNEL);
  3752. if (!auxpcm_pdata) {
  3753. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  3754. goto fail_pdata_nomem;
  3755. }
  3756. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  3757. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  3758. rc = of_property_read_u32_array(pdev->dev.of_node,
  3759. "qcom,msm-cpudai-auxpcm-mode",
  3760. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3761. if (rc) {
  3762. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  3763. __func__);
  3764. goto fail_invalid_dt;
  3765. }
  3766. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  3767. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  3768. rc = of_property_read_u32_array(pdev->dev.of_node,
  3769. "qcom,msm-cpudai-auxpcm-sync",
  3770. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3771. if (rc) {
  3772. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  3773. __func__);
  3774. goto fail_invalid_dt;
  3775. }
  3776. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  3777. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  3778. rc = of_property_read_u32_array(pdev->dev.of_node,
  3779. "qcom,msm-cpudai-auxpcm-frame",
  3780. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3781. if (rc) {
  3782. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  3783. __func__);
  3784. goto fail_invalid_dt;
  3785. }
  3786. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  3787. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  3788. rc = of_property_read_u32_array(pdev->dev.of_node,
  3789. "qcom,msm-cpudai-auxpcm-quant",
  3790. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3791. if (rc) {
  3792. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  3793. __func__);
  3794. goto fail_invalid_dt;
  3795. }
  3796. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  3797. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  3798. rc = of_property_read_u32_array(pdev->dev.of_node,
  3799. "qcom,msm-cpudai-auxpcm-num-slots",
  3800. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3801. if (rc) {
  3802. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  3803. __func__);
  3804. goto fail_invalid_dt;
  3805. }
  3806. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  3807. if (auxpcm_pdata->mode_8k.num_slots >
  3808. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  3809. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3810. __func__,
  3811. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  3812. auxpcm_pdata->mode_8k.num_slots);
  3813. rc = -EINVAL;
  3814. goto fail_invalid_dt;
  3815. }
  3816. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  3817. if (auxpcm_pdata->mode_16k.num_slots >
  3818. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  3819. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3820. __func__,
  3821. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  3822. auxpcm_pdata->mode_16k.num_slots);
  3823. rc = -EINVAL;
  3824. goto fail_invalid_dt;
  3825. }
  3826. slot_mapping_array = of_get_property(pdev->dev.of_node,
  3827. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  3828. if (slot_mapping_array == NULL) {
  3829. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  3830. __func__);
  3831. rc = -EINVAL;
  3832. goto fail_invalid_dt;
  3833. }
  3834. array_length = auxpcm_pdata->mode_8k.num_slots +
  3835. auxpcm_pdata->mode_16k.num_slots;
  3836. if (len != sizeof(uint32_t) * array_length) {
  3837. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  3838. __func__, len, sizeof(uint32_t) * array_length);
  3839. rc = -EINVAL;
  3840. goto fail_invalid_dt;
  3841. }
  3842. auxpcm_pdata->mode_8k.slot_mapping =
  3843. kzalloc(sizeof(uint16_t) *
  3844. auxpcm_pdata->mode_8k.num_slots,
  3845. GFP_KERNEL);
  3846. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  3847. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  3848. __func__);
  3849. rc = -ENOMEM;
  3850. goto fail_invalid_dt;
  3851. }
  3852. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  3853. auxpcm_pdata->mode_8k.slot_mapping[i] =
  3854. (u16)be32_to_cpu(slot_mapping_array[i]);
  3855. auxpcm_pdata->mode_16k.slot_mapping =
  3856. kzalloc(sizeof(uint16_t) *
  3857. auxpcm_pdata->mode_16k.num_slots,
  3858. GFP_KERNEL);
  3859. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  3860. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  3861. __func__);
  3862. rc = -ENOMEM;
  3863. goto fail_invalid_16k_slot_mapping;
  3864. }
  3865. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  3866. auxpcm_pdata->mode_16k.slot_mapping[i] =
  3867. (u16)be32_to_cpu(slot_mapping_array[i +
  3868. auxpcm_pdata->mode_8k.num_slots]);
  3869. rc = of_property_read_u32_array(pdev->dev.of_node,
  3870. "qcom,msm-cpudai-auxpcm-data",
  3871. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3872. if (rc) {
  3873. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  3874. __func__);
  3875. goto fail_invalid_dt1;
  3876. }
  3877. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  3878. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  3879. rc = of_property_read_u32_array(pdev->dev.of_node,
  3880. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  3881. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3882. if (rc) {
  3883. dev_err(&pdev->dev,
  3884. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  3885. __func__);
  3886. goto fail_invalid_dt1;
  3887. }
  3888. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  3889. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  3890. rc = of_property_read_string(pdev->dev.of_node,
  3891. "qcom,msm-auxpcm-interface", &intf_name);
  3892. if (rc) {
  3893. dev_err(&pdev->dev,
  3894. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  3895. __func__);
  3896. goto fail_nodev_intf;
  3897. }
  3898. if (!strcmp(intf_name, "primary")) {
  3899. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  3900. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  3901. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  3902. i = 0;
  3903. } else if (!strcmp(intf_name, "secondary")) {
  3904. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  3905. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  3906. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  3907. i = 1;
  3908. } else if (!strcmp(intf_name, "tertiary")) {
  3909. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  3910. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  3911. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  3912. i = 2;
  3913. } else if (!strcmp(intf_name, "quaternary")) {
  3914. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  3915. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  3916. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  3917. i = 3;
  3918. } else if (!strcmp(intf_name, "quinary")) {
  3919. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  3920. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  3921. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  3922. i = 4;
  3923. } else if (!strcmp(intf_name, "senary")) {
  3924. dai_data->rx_pid = AFE_PORT_ID_SENARY_PCM_RX;
  3925. dai_data->tx_pid = AFE_PORT_ID_SENARY_PCM_TX;
  3926. pdev->id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID;
  3927. i = 5;
  3928. } else {
  3929. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  3930. __func__, intf_name);
  3931. goto fail_invalid_intf;
  3932. }
  3933. rc = of_property_read_u32(pdev->dev.of_node,
  3934. "qcom,msm-cpudai-afe-clk-ver", &val);
  3935. if (rc)
  3936. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  3937. else
  3938. dai_data->afe_clk_ver = val;
  3939. mutex_init(&dai_data->rlock);
  3940. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  3941. dev_set_drvdata(&pdev->dev, dai_data);
  3942. pdev->dev.platform_data = (void *) auxpcm_pdata;
  3943. rc = snd_soc_register_component(&pdev->dev,
  3944. &msm_dai_q6_aux_pcm_dai_component,
  3945. &msm_dai_q6_aux_pcm_dai[i], 1);
  3946. if (rc) {
  3947. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  3948. __func__, rc);
  3949. goto fail_reg_dai;
  3950. }
  3951. return rc;
  3952. fail_reg_dai:
  3953. fail_invalid_intf:
  3954. fail_nodev_intf:
  3955. fail_invalid_dt1:
  3956. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  3957. fail_invalid_16k_slot_mapping:
  3958. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  3959. fail_invalid_dt:
  3960. kfree(auxpcm_pdata);
  3961. fail_pdata_nomem:
  3962. kfree(dai_data);
  3963. return rc;
  3964. }
  3965. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  3966. {
  3967. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3968. dai_data = dev_get_drvdata(&pdev->dev);
  3969. snd_soc_unregister_component(&pdev->dev);
  3970. mutex_destroy(&dai_data->rlock);
  3971. kfree(dai_data);
  3972. kfree(pdev->dev.platform_data);
  3973. return 0;
  3974. }
  3975. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  3976. { .compatible = "qcom,msm-auxpcm-dev", },
  3977. {}
  3978. };
  3979. static struct platform_driver msm_auxpcm_dev_driver = {
  3980. .probe = msm_auxpcm_dev_probe,
  3981. .remove = msm_auxpcm_dev_remove,
  3982. .driver = {
  3983. .name = "msm-auxpcm-dev",
  3984. .owner = THIS_MODULE,
  3985. .of_match_table = msm_auxpcm_dev_dt_match,
  3986. .suppress_bind_attrs = true,
  3987. },
  3988. };
  3989. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  3990. {
  3991. .playback = {
  3992. .stream_name = "Slimbus Playback",
  3993. .aif_name = "SLIMBUS_0_RX",
  3994. .rates = SNDRV_PCM_RATE_8000_384000,
  3995. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3996. .channels_min = 1,
  3997. .channels_max = 8,
  3998. .rate_min = 8000,
  3999. .rate_max = 384000,
  4000. },
  4001. .ops = &msm_dai_q6_ops,
  4002. .id = SLIMBUS_0_RX,
  4003. .probe = msm_dai_q6_dai_probe,
  4004. .remove = msm_dai_q6_dai_remove,
  4005. },
  4006. {
  4007. .playback = {
  4008. .stream_name = "Slimbus1 Playback",
  4009. .aif_name = "SLIMBUS_1_RX",
  4010. .rates = SNDRV_PCM_RATE_8000_384000,
  4011. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4012. .channels_min = 1,
  4013. .channels_max = 2,
  4014. .rate_min = 8000,
  4015. .rate_max = 384000,
  4016. },
  4017. .ops = &msm_dai_q6_ops,
  4018. .id = SLIMBUS_1_RX,
  4019. .probe = msm_dai_q6_dai_probe,
  4020. .remove = msm_dai_q6_dai_remove,
  4021. },
  4022. {
  4023. .playback = {
  4024. .stream_name = "Slimbus2 Playback",
  4025. .aif_name = "SLIMBUS_2_RX",
  4026. .rates = SNDRV_PCM_RATE_8000_384000,
  4027. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4028. .channels_min = 1,
  4029. .channels_max = 8,
  4030. .rate_min = 8000,
  4031. .rate_max = 384000,
  4032. },
  4033. .ops = &msm_dai_q6_ops,
  4034. .id = SLIMBUS_2_RX,
  4035. .probe = msm_dai_q6_dai_probe,
  4036. .remove = msm_dai_q6_dai_remove,
  4037. },
  4038. {
  4039. .playback = {
  4040. .stream_name = "Slimbus3 Playback",
  4041. .aif_name = "SLIMBUS_3_RX",
  4042. .rates = SNDRV_PCM_RATE_8000_384000,
  4043. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4044. .channels_min = 1,
  4045. .channels_max = 2,
  4046. .rate_min = 8000,
  4047. .rate_max = 384000,
  4048. },
  4049. .ops = &msm_dai_q6_ops,
  4050. .id = SLIMBUS_3_RX,
  4051. .probe = msm_dai_q6_dai_probe,
  4052. .remove = msm_dai_q6_dai_remove,
  4053. },
  4054. {
  4055. .playback = {
  4056. .stream_name = "Slimbus4 Playback",
  4057. .aif_name = "SLIMBUS_4_RX",
  4058. .rates = SNDRV_PCM_RATE_8000_384000,
  4059. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4060. .channels_min = 1,
  4061. .channels_max = 2,
  4062. .rate_min = 8000,
  4063. .rate_max = 384000,
  4064. },
  4065. .ops = &msm_dai_q6_ops,
  4066. .id = SLIMBUS_4_RX,
  4067. .probe = msm_dai_q6_dai_probe,
  4068. .remove = msm_dai_q6_dai_remove,
  4069. },
  4070. {
  4071. .playback = {
  4072. .stream_name = "Slimbus6 Playback",
  4073. .aif_name = "SLIMBUS_6_RX",
  4074. .rates = SNDRV_PCM_RATE_8000_384000,
  4075. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4076. .channels_min = 1,
  4077. .channels_max = 2,
  4078. .rate_min = 8000,
  4079. .rate_max = 384000,
  4080. },
  4081. .ops = &msm_dai_q6_ops,
  4082. .id = SLIMBUS_6_RX,
  4083. .probe = msm_dai_q6_dai_probe,
  4084. .remove = msm_dai_q6_dai_remove,
  4085. },
  4086. {
  4087. .playback = {
  4088. .stream_name = "Slimbus5 Playback",
  4089. .aif_name = "SLIMBUS_5_RX",
  4090. .rates = SNDRV_PCM_RATE_8000_384000,
  4091. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4092. .channels_min = 1,
  4093. .channels_max = 2,
  4094. .rate_min = 8000,
  4095. .rate_max = 384000,
  4096. },
  4097. .ops = &msm_dai_q6_ops,
  4098. .id = SLIMBUS_5_RX,
  4099. .probe = msm_dai_q6_dai_probe,
  4100. .remove = msm_dai_q6_dai_remove,
  4101. },
  4102. {
  4103. .playback = {
  4104. .stream_name = "Slimbus7 Playback",
  4105. .aif_name = "SLIMBUS_7_RX",
  4106. .rates = SNDRV_PCM_RATE_8000_384000,
  4107. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4108. .channels_min = 1,
  4109. .channels_max = 8,
  4110. .rate_min = 8000,
  4111. .rate_max = 384000,
  4112. },
  4113. .ops = &msm_dai_q6_ops,
  4114. .id = SLIMBUS_7_RX,
  4115. .probe = msm_dai_q6_dai_probe,
  4116. .remove = msm_dai_q6_dai_remove,
  4117. },
  4118. {
  4119. .playback = {
  4120. .stream_name = "Slimbus8 Playback",
  4121. .aif_name = "SLIMBUS_8_RX",
  4122. .rates = SNDRV_PCM_RATE_8000_384000,
  4123. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4124. .channels_min = 1,
  4125. .channels_max = 8,
  4126. .rate_min = 8000,
  4127. .rate_max = 384000,
  4128. },
  4129. .ops = &msm_dai_q6_ops,
  4130. .id = SLIMBUS_8_RX,
  4131. .probe = msm_dai_q6_dai_probe,
  4132. .remove = msm_dai_q6_dai_remove,
  4133. },
  4134. {
  4135. .playback = {
  4136. .stream_name = "Slimbus9 Playback",
  4137. .aif_name = "SLIMBUS_9_RX",
  4138. .rates = SNDRV_PCM_RATE_8000_384000,
  4139. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4140. .channels_min = 1,
  4141. .channels_max = 8,
  4142. .rate_min = 8000,
  4143. .rate_max = 384000,
  4144. },
  4145. .ops = &msm_dai_q6_ops,
  4146. .id = SLIMBUS_9_RX,
  4147. .probe = msm_dai_q6_dai_probe,
  4148. .remove = msm_dai_q6_dai_remove,
  4149. },
  4150. };
  4151. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  4152. {
  4153. .capture = {
  4154. .stream_name = "Slimbus Capture",
  4155. .aif_name = "SLIMBUS_0_TX",
  4156. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4157. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4158. SNDRV_PCM_RATE_192000,
  4159. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4160. SNDRV_PCM_FMTBIT_S24_LE |
  4161. SNDRV_PCM_FMTBIT_S24_3LE,
  4162. .channels_min = 1,
  4163. .channels_max = 8,
  4164. .rate_min = 8000,
  4165. .rate_max = 192000,
  4166. },
  4167. .ops = &msm_dai_q6_ops,
  4168. .id = SLIMBUS_0_TX,
  4169. .probe = msm_dai_q6_dai_probe,
  4170. .remove = msm_dai_q6_dai_remove,
  4171. },
  4172. {
  4173. .capture = {
  4174. .stream_name = "Slimbus1 Capture",
  4175. .aif_name = "SLIMBUS_1_TX",
  4176. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4177. SNDRV_PCM_RATE_48000 | 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 = 2,
  4184. .rate_min = 8000,
  4185. .rate_max = 192000,
  4186. },
  4187. .ops = &msm_dai_q6_ops,
  4188. .id = SLIMBUS_1_TX,
  4189. .probe = msm_dai_q6_dai_probe,
  4190. .remove = msm_dai_q6_dai_remove,
  4191. },
  4192. {
  4193. .capture = {
  4194. .stream_name = "Slimbus2 Capture",
  4195. .aif_name = "SLIMBUS_2_TX",
  4196. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4197. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4198. SNDRV_PCM_RATE_192000,
  4199. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4200. SNDRV_PCM_FMTBIT_S24_LE,
  4201. .channels_min = 1,
  4202. .channels_max = 8,
  4203. .rate_min = 8000,
  4204. .rate_max = 192000,
  4205. },
  4206. .ops = &msm_dai_q6_ops,
  4207. .id = SLIMBUS_2_TX,
  4208. .probe = msm_dai_q6_dai_probe,
  4209. .remove = msm_dai_q6_dai_remove,
  4210. },
  4211. {
  4212. .capture = {
  4213. .stream_name = "Slimbus3 Capture",
  4214. .aif_name = "SLIMBUS_3_TX",
  4215. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4216. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4217. SNDRV_PCM_RATE_192000,
  4218. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4219. SNDRV_PCM_FMTBIT_S24_LE,
  4220. .channels_min = 2,
  4221. .channels_max = 4,
  4222. .rate_min = 8000,
  4223. .rate_max = 192000,
  4224. },
  4225. .ops = &msm_dai_q6_ops,
  4226. .id = SLIMBUS_3_TX,
  4227. .probe = msm_dai_q6_dai_probe,
  4228. .remove = msm_dai_q6_dai_remove,
  4229. },
  4230. {
  4231. .capture = {
  4232. .stream_name = "Slimbus4 Capture",
  4233. .aif_name = "SLIMBUS_4_TX",
  4234. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4235. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4236. SNDRV_PCM_RATE_192000,
  4237. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4238. SNDRV_PCM_FMTBIT_S24_LE |
  4239. SNDRV_PCM_FMTBIT_S32_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_4_TX,
  4247. .probe = msm_dai_q6_dai_probe,
  4248. .remove = msm_dai_q6_dai_remove,
  4249. },
  4250. {
  4251. .capture = {
  4252. .stream_name = "Slimbus5 Capture",
  4253. .aif_name = "SLIMBUS_5_TX",
  4254. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4255. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4256. SNDRV_PCM_RATE_192000,
  4257. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4258. SNDRV_PCM_FMTBIT_S24_LE,
  4259. .channels_min = 1,
  4260. .channels_max = 8,
  4261. .rate_min = 8000,
  4262. .rate_max = 192000,
  4263. },
  4264. .ops = &msm_dai_q6_ops,
  4265. .id = SLIMBUS_5_TX,
  4266. .probe = msm_dai_q6_dai_probe,
  4267. .remove = msm_dai_q6_dai_remove,
  4268. },
  4269. {
  4270. .capture = {
  4271. .stream_name = "Slimbus6 Capture",
  4272. .aif_name = "SLIMBUS_6_TX",
  4273. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4274. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4275. SNDRV_PCM_RATE_192000,
  4276. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4277. SNDRV_PCM_FMTBIT_S24_LE,
  4278. .channels_min = 1,
  4279. .channels_max = 2,
  4280. .rate_min = 8000,
  4281. .rate_max = 192000,
  4282. },
  4283. .ops = &msm_dai_q6_ops,
  4284. .id = SLIMBUS_6_TX,
  4285. .probe = msm_dai_q6_dai_probe,
  4286. .remove = msm_dai_q6_dai_remove,
  4287. },
  4288. {
  4289. .capture = {
  4290. .stream_name = "Slimbus7 Capture",
  4291. .aif_name = "SLIMBUS_7_TX",
  4292. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4293. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4294. SNDRV_PCM_RATE_192000,
  4295. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4296. SNDRV_PCM_FMTBIT_S24_LE |
  4297. SNDRV_PCM_FMTBIT_S32_LE,
  4298. .channels_min = 1,
  4299. .channels_max = 8,
  4300. .rate_min = 8000,
  4301. .rate_max = 192000,
  4302. },
  4303. .ops = &msm_dai_q6_ops,
  4304. .id = SLIMBUS_7_TX,
  4305. .probe = msm_dai_q6_dai_probe,
  4306. .remove = msm_dai_q6_dai_remove,
  4307. },
  4308. {
  4309. .capture = {
  4310. .stream_name = "Slimbus8 Capture",
  4311. .aif_name = "SLIMBUS_8_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_8_TX,
  4325. .probe = msm_dai_q6_dai_probe,
  4326. .remove = msm_dai_q6_dai_remove,
  4327. },
  4328. {
  4329. .capture = {
  4330. .stream_name = "Slimbus9 Capture",
  4331. .aif_name = "SLIMBUS_9_TX",
  4332. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4333. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  4334. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  4335. SNDRV_PCM_RATE_192000,
  4336. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4337. SNDRV_PCM_FMTBIT_S24_LE |
  4338. SNDRV_PCM_FMTBIT_S32_LE,
  4339. .channels_min = 1,
  4340. .channels_max = 8,
  4341. .rate_min = 8000,
  4342. .rate_max = 192000,
  4343. },
  4344. .ops = &msm_dai_q6_ops,
  4345. .id = SLIMBUS_9_TX,
  4346. .probe = msm_dai_q6_dai_probe,
  4347. .remove = msm_dai_q6_dai_remove,
  4348. },
  4349. };
  4350. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  4351. struct snd_ctl_elem_value *ucontrol)
  4352. {
  4353. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4354. int value = ucontrol->value.integer.value[0];
  4355. dai_data->port_config.i2s.data_format = value;
  4356. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  4357. __func__, value, dai_data->port_config.i2s.mono_stereo,
  4358. dai_data->port_config.i2s.channel_mode);
  4359. return 0;
  4360. }
  4361. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  4362. struct snd_ctl_elem_value *ucontrol)
  4363. {
  4364. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4365. ucontrol->value.integer.value[0] =
  4366. dai_data->port_config.i2s.data_format;
  4367. return 0;
  4368. }
  4369. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  4370. struct snd_ctl_elem_value *ucontrol)
  4371. {
  4372. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4373. int value = ucontrol->value.integer.value[0];
  4374. dai_data->vi_feed_mono = value;
  4375. pr_debug("%s: value = %d\n", __func__, value);
  4376. return 0;
  4377. }
  4378. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  4379. struct snd_ctl_elem_value *ucontrol)
  4380. {
  4381. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4382. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  4383. return 0;
  4384. }
  4385. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  4386. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  4387. msm_dai_q6_mi2s_format_get,
  4388. msm_dai_q6_mi2s_format_put),
  4389. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  4390. msm_dai_q6_mi2s_format_get,
  4391. msm_dai_q6_mi2s_format_put),
  4392. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  4393. msm_dai_q6_mi2s_format_get,
  4394. msm_dai_q6_mi2s_format_put),
  4395. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  4396. msm_dai_q6_mi2s_format_get,
  4397. msm_dai_q6_mi2s_format_put),
  4398. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  4399. msm_dai_q6_mi2s_format_get,
  4400. msm_dai_q6_mi2s_format_put),
  4401. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  4402. msm_dai_q6_mi2s_format_get,
  4403. msm_dai_q6_mi2s_format_put),
  4404. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  4405. msm_dai_q6_mi2s_format_get,
  4406. msm_dai_q6_mi2s_format_put),
  4407. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  4408. msm_dai_q6_mi2s_format_get,
  4409. msm_dai_q6_mi2s_format_put),
  4410. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  4411. msm_dai_q6_mi2s_format_get,
  4412. msm_dai_q6_mi2s_format_put),
  4413. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  4414. msm_dai_q6_mi2s_format_get,
  4415. msm_dai_q6_mi2s_format_put),
  4416. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  4417. msm_dai_q6_mi2s_format_get,
  4418. msm_dai_q6_mi2s_format_put),
  4419. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  4420. msm_dai_q6_mi2s_format_get,
  4421. msm_dai_q6_mi2s_format_put),
  4422. };
  4423. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  4424. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  4425. msm_dai_q6_mi2s_vi_feed_mono_get,
  4426. msm_dai_q6_mi2s_vi_feed_mono_put),
  4427. };
  4428. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  4429. {
  4430. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4431. dev_get_drvdata(dai->dev);
  4432. struct msm_mi2s_pdata *mi2s_pdata =
  4433. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  4434. struct snd_kcontrol *kcontrol = NULL;
  4435. int rc = 0;
  4436. const struct snd_kcontrol_new *ctrl = NULL;
  4437. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  4438. u16 dai_id = 0;
  4439. dai->id = mi2s_pdata->intf_id;
  4440. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4441. if (dai->id == MSM_PRIM_MI2S)
  4442. ctrl = &mi2s_config_controls[0];
  4443. if (dai->id == MSM_SEC_MI2S)
  4444. ctrl = &mi2s_config_controls[1];
  4445. if (dai->id == MSM_TERT_MI2S)
  4446. ctrl = &mi2s_config_controls[2];
  4447. if (dai->id == MSM_QUAT_MI2S)
  4448. ctrl = &mi2s_config_controls[3];
  4449. if (dai->id == MSM_QUIN_MI2S)
  4450. ctrl = &mi2s_config_controls[4];
  4451. }
  4452. if (ctrl) {
  4453. kcontrol = snd_ctl_new1(ctrl,
  4454. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  4455. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  4456. if (rc < 0) {
  4457. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  4458. __func__, dai->name);
  4459. goto rtn;
  4460. }
  4461. }
  4462. ctrl = NULL;
  4463. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4464. if (dai->id == MSM_PRIM_MI2S)
  4465. ctrl = &mi2s_config_controls[5];
  4466. if (dai->id == MSM_SEC_MI2S)
  4467. ctrl = &mi2s_config_controls[6];
  4468. if (dai->id == MSM_TERT_MI2S)
  4469. ctrl = &mi2s_config_controls[7];
  4470. if (dai->id == MSM_QUAT_MI2S)
  4471. ctrl = &mi2s_config_controls[8];
  4472. if (dai->id == MSM_QUIN_MI2S)
  4473. ctrl = &mi2s_config_controls[9];
  4474. if (dai->id == MSM_SENARY_MI2S)
  4475. ctrl = &mi2s_config_controls[10];
  4476. if (dai->id == MSM_INT5_MI2S)
  4477. ctrl = &mi2s_config_controls[11];
  4478. }
  4479. if (ctrl) {
  4480. rc = snd_ctl_add(dai->component->card->snd_card,
  4481. snd_ctl_new1(ctrl,
  4482. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4483. if (rc < 0) {
  4484. if (kcontrol)
  4485. snd_ctl_remove(dai->component->card->snd_card,
  4486. kcontrol);
  4487. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  4488. __func__, dai->name);
  4489. }
  4490. }
  4491. if (dai->id == MSM_INT5_MI2S)
  4492. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  4493. if (vi_feed_ctrl) {
  4494. rc = snd_ctl_add(dai->component->card->snd_card,
  4495. snd_ctl_new1(vi_feed_ctrl,
  4496. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4497. if (rc < 0) {
  4498. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  4499. __func__, dai->name);
  4500. }
  4501. }
  4502. if (mi2s_dai_data->is_island_dai) {
  4503. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  4504. &dai_id);
  4505. rc = msm_dai_q6_add_island_mx_ctls(
  4506. dai->component->card->snd_card,
  4507. dai->name, dai_id,
  4508. (void *)mi2s_dai_data);
  4509. }
  4510. rc = msm_dai_q6_dai_add_route(dai);
  4511. rtn:
  4512. return rc;
  4513. }
  4514. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  4515. {
  4516. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4517. dev_get_drvdata(dai->dev);
  4518. int rc;
  4519. /* If AFE port is still up, close it */
  4520. if (test_bit(STATUS_PORT_STARTED,
  4521. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  4522. rc = afe_close(MI2S_RX); /* can block */
  4523. if (rc < 0)
  4524. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  4525. clear_bit(STATUS_PORT_STARTED,
  4526. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  4527. }
  4528. if (test_bit(STATUS_PORT_STARTED,
  4529. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4530. rc = afe_close(MI2S_TX); /* can block */
  4531. if (rc < 0)
  4532. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  4533. clear_bit(STATUS_PORT_STARTED,
  4534. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  4535. }
  4536. return 0;
  4537. }
  4538. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  4539. struct snd_soc_dai *dai)
  4540. {
  4541. return 0;
  4542. }
  4543. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  4544. {
  4545. int ret = 0;
  4546. switch (stream) {
  4547. case SNDRV_PCM_STREAM_PLAYBACK:
  4548. switch (mi2s_id) {
  4549. case MSM_PRIM_MI2S:
  4550. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  4551. break;
  4552. case MSM_SEC_MI2S:
  4553. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  4554. break;
  4555. case MSM_TERT_MI2S:
  4556. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  4557. break;
  4558. case MSM_QUAT_MI2S:
  4559. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  4560. break;
  4561. case MSM_SEC_MI2S_SD1:
  4562. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  4563. break;
  4564. case MSM_QUIN_MI2S:
  4565. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  4566. break;
  4567. case MSM_SENARY_MI2S:
  4568. *port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  4569. break;
  4570. case MSM_INT0_MI2S:
  4571. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  4572. break;
  4573. case MSM_INT1_MI2S:
  4574. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  4575. break;
  4576. case MSM_INT2_MI2S:
  4577. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  4578. break;
  4579. case MSM_INT3_MI2S:
  4580. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  4581. break;
  4582. case MSM_INT4_MI2S:
  4583. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  4584. break;
  4585. case MSM_INT5_MI2S:
  4586. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  4587. break;
  4588. case MSM_INT6_MI2S:
  4589. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  4590. break;
  4591. default:
  4592. pr_err("%s: playback err id 0x%x\n",
  4593. __func__, mi2s_id);
  4594. ret = -1;
  4595. break;
  4596. }
  4597. break;
  4598. case SNDRV_PCM_STREAM_CAPTURE:
  4599. switch (mi2s_id) {
  4600. case MSM_PRIM_MI2S:
  4601. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  4602. break;
  4603. case MSM_SEC_MI2S:
  4604. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  4605. break;
  4606. case MSM_TERT_MI2S:
  4607. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  4608. break;
  4609. case MSM_QUAT_MI2S:
  4610. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  4611. break;
  4612. case MSM_QUIN_MI2S:
  4613. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  4614. break;
  4615. case MSM_SENARY_MI2S:
  4616. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  4617. break;
  4618. case MSM_INT0_MI2S:
  4619. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  4620. break;
  4621. case MSM_INT1_MI2S:
  4622. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  4623. break;
  4624. case MSM_INT2_MI2S:
  4625. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  4626. break;
  4627. case MSM_INT3_MI2S:
  4628. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  4629. break;
  4630. case MSM_INT4_MI2S:
  4631. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  4632. break;
  4633. case MSM_INT5_MI2S:
  4634. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  4635. break;
  4636. case MSM_INT6_MI2S:
  4637. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  4638. break;
  4639. default:
  4640. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  4641. ret = -1;
  4642. break;
  4643. }
  4644. break;
  4645. default:
  4646. pr_err("%s: default err %d\n", __func__, stream);
  4647. ret = -1;
  4648. break;
  4649. }
  4650. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  4651. return ret;
  4652. }
  4653. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  4654. struct snd_soc_dai *dai)
  4655. {
  4656. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4657. dev_get_drvdata(dai->dev);
  4658. struct msm_dai_q6_dai_data *dai_data =
  4659. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4660. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4661. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4662. u16 port_id = 0;
  4663. int rc = 0;
  4664. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4665. &port_id) != 0) {
  4666. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4667. __func__, port_id);
  4668. return -EINVAL;
  4669. }
  4670. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  4671. "dai_data->channels = %u sample_rate = %u\n", __func__,
  4672. dai->id, port_id, dai_data->channels, dai_data->rate);
  4673. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4674. /* PORT START should be set if prepare called
  4675. * in active state.
  4676. */
  4677. rc = afe_port_start(port_id, &dai_data->port_config,
  4678. dai_data->rate);
  4679. if (rc < 0)
  4680. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  4681. dai->id);
  4682. else
  4683. set_bit(STATUS_PORT_STARTED,
  4684. dai_data->status_mask);
  4685. }
  4686. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4687. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4688. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  4689. __func__);
  4690. }
  4691. return rc;
  4692. }
  4693. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  4694. struct snd_pcm_hw_params *params,
  4695. struct snd_soc_dai *dai)
  4696. {
  4697. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4698. dev_get_drvdata(dai->dev);
  4699. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  4700. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4701. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  4702. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  4703. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  4704. dai_data->channels = params_channels(params);
  4705. switch (dai_data->channels) {
  4706. case 15:
  4707. case 16:
  4708. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4709. case AFE_PORT_I2S_16CHS:
  4710. dai_data->port_config.i2s.channel_mode
  4711. = AFE_PORT_I2S_16CHS;
  4712. break;
  4713. default:
  4714. goto error_invalid_data;
  4715. };
  4716. break;
  4717. case 13:
  4718. case 14:
  4719. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4720. case AFE_PORT_I2S_14CHS:
  4721. case AFE_PORT_I2S_16CHS:
  4722. dai_data->port_config.i2s.channel_mode
  4723. = AFE_PORT_I2S_14CHS;
  4724. break;
  4725. default:
  4726. goto error_invalid_data;
  4727. };
  4728. break;
  4729. case 11:
  4730. case 12:
  4731. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4732. case AFE_PORT_I2S_12CHS:
  4733. case AFE_PORT_I2S_14CHS:
  4734. case AFE_PORT_I2S_16CHS:
  4735. dai_data->port_config.i2s.channel_mode
  4736. = AFE_PORT_I2S_12CHS;
  4737. break;
  4738. default:
  4739. goto error_invalid_data;
  4740. };
  4741. break;
  4742. case 9:
  4743. case 10:
  4744. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4745. case AFE_PORT_I2S_10CHS:
  4746. case AFE_PORT_I2S_12CHS:
  4747. case AFE_PORT_I2S_14CHS:
  4748. case AFE_PORT_I2S_16CHS:
  4749. dai_data->port_config.i2s.channel_mode
  4750. = AFE_PORT_I2S_10CHS;
  4751. break;
  4752. default:
  4753. goto error_invalid_data;
  4754. };
  4755. break;
  4756. case 8:
  4757. case 7:
  4758. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  4759. goto error_invalid_data;
  4760. else
  4761. if (mi2s_dai_config->pdata_mi2s_lines
  4762. == AFE_PORT_I2S_8CHS_2)
  4763. dai_data->port_config.i2s.channel_mode =
  4764. AFE_PORT_I2S_8CHS_2;
  4765. else
  4766. dai_data->port_config.i2s.channel_mode =
  4767. AFE_PORT_I2S_8CHS;
  4768. break;
  4769. case 6:
  4770. case 5:
  4771. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  4772. goto error_invalid_data;
  4773. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  4774. break;
  4775. case 4:
  4776. case 3:
  4777. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4778. case AFE_PORT_I2S_SD0:
  4779. case AFE_PORT_I2S_SD1:
  4780. case AFE_PORT_I2S_SD2:
  4781. case AFE_PORT_I2S_SD3:
  4782. case AFE_PORT_I2S_SD4:
  4783. case AFE_PORT_I2S_SD5:
  4784. case AFE_PORT_I2S_SD6:
  4785. case AFE_PORT_I2S_SD7:
  4786. goto error_invalid_data;
  4787. break;
  4788. case AFE_PORT_I2S_QUAD01:
  4789. case AFE_PORT_I2S_QUAD23:
  4790. case AFE_PORT_I2S_QUAD45:
  4791. case AFE_PORT_I2S_QUAD67:
  4792. dai_data->port_config.i2s.channel_mode =
  4793. mi2s_dai_config->pdata_mi2s_lines;
  4794. break;
  4795. case AFE_PORT_I2S_8CHS_2:
  4796. dai_data->port_config.i2s.channel_mode =
  4797. AFE_PORT_I2S_QUAD45;
  4798. break;
  4799. default:
  4800. dai_data->port_config.i2s.channel_mode =
  4801. AFE_PORT_I2S_QUAD01;
  4802. break;
  4803. };
  4804. break;
  4805. case 2:
  4806. case 1:
  4807. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  4808. goto error_invalid_data;
  4809. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4810. case AFE_PORT_I2S_SD0:
  4811. case AFE_PORT_I2S_SD1:
  4812. case AFE_PORT_I2S_SD2:
  4813. case AFE_PORT_I2S_SD3:
  4814. case AFE_PORT_I2S_SD4:
  4815. case AFE_PORT_I2S_SD5:
  4816. case AFE_PORT_I2S_SD6:
  4817. case AFE_PORT_I2S_SD7:
  4818. dai_data->port_config.i2s.channel_mode =
  4819. mi2s_dai_config->pdata_mi2s_lines;
  4820. break;
  4821. case AFE_PORT_I2S_QUAD01:
  4822. case AFE_PORT_I2S_6CHS:
  4823. case AFE_PORT_I2S_8CHS:
  4824. case AFE_PORT_I2S_10CHS:
  4825. case AFE_PORT_I2S_12CHS:
  4826. case AFE_PORT_I2S_14CHS:
  4827. case AFE_PORT_I2S_16CHS:
  4828. if (dai_data->vi_feed_mono == SPKR_1)
  4829. dai_data->port_config.i2s.channel_mode =
  4830. AFE_PORT_I2S_SD0;
  4831. else
  4832. dai_data->port_config.i2s.channel_mode =
  4833. AFE_PORT_I2S_SD1;
  4834. break;
  4835. case AFE_PORT_I2S_QUAD23:
  4836. dai_data->port_config.i2s.channel_mode =
  4837. AFE_PORT_I2S_SD2;
  4838. break;
  4839. case AFE_PORT_I2S_QUAD45:
  4840. dai_data->port_config.i2s.channel_mode =
  4841. AFE_PORT_I2S_SD4;
  4842. break;
  4843. case AFE_PORT_I2S_QUAD67:
  4844. dai_data->port_config.i2s.channel_mode =
  4845. AFE_PORT_I2S_SD6;
  4846. break;
  4847. }
  4848. if (dai_data->channels == 2)
  4849. dai_data->port_config.i2s.mono_stereo =
  4850. MSM_AFE_CH_STEREO;
  4851. else
  4852. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  4853. break;
  4854. default:
  4855. pr_err("%s: default err channels %d\n",
  4856. __func__, dai_data->channels);
  4857. goto error_invalid_data;
  4858. }
  4859. dai_data->rate = params_rate(params);
  4860. switch (params_format(params)) {
  4861. case SNDRV_PCM_FORMAT_S16_LE:
  4862. case SNDRV_PCM_FORMAT_SPECIAL:
  4863. dai_data->port_config.i2s.bit_width = 16;
  4864. dai_data->bitwidth = 16;
  4865. break;
  4866. case SNDRV_PCM_FORMAT_S24_LE:
  4867. case SNDRV_PCM_FORMAT_S24_3LE:
  4868. dai_data->port_config.i2s.bit_width = 24;
  4869. dai_data->bitwidth = 24;
  4870. break;
  4871. default:
  4872. pr_err("%s: format %d\n",
  4873. __func__, params_format(params));
  4874. return -EINVAL;
  4875. }
  4876. dai_data->port_config.i2s.i2s_cfg_minor_version =
  4877. AFE_API_VERSION_I2S_CONFIG;
  4878. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  4879. if ((test_bit(STATUS_PORT_STARTED,
  4880. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  4881. test_bit(STATUS_PORT_STARTED,
  4882. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  4883. (test_bit(STATUS_PORT_STARTED,
  4884. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  4885. test_bit(STATUS_PORT_STARTED,
  4886. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  4887. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  4888. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  4889. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  4890. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  4891. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  4892. "Tx sample_rate = %u bit_width = %hu\n"
  4893. "Rx sample_rate = %u bit_width = %hu\n"
  4894. , __func__,
  4895. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  4896. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  4897. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  4898. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  4899. return -EINVAL;
  4900. }
  4901. }
  4902. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  4903. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  4904. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  4905. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  4906. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  4907. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  4908. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  4909. i2s->sample_rate, i2s->data_format, i2s->reserved);
  4910. return 0;
  4911. error_invalid_data:
  4912. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  4913. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  4914. return -EINVAL;
  4915. }
  4916. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  4917. {
  4918. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4919. dev_get_drvdata(dai->dev);
  4920. if (test_bit(STATUS_PORT_STARTED,
  4921. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  4922. test_bit(STATUS_PORT_STARTED,
  4923. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4924. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  4925. __func__);
  4926. return -EPERM;
  4927. }
  4928. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  4929. case SND_SOC_DAIFMT_CBS_CFS:
  4930. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4931. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4932. break;
  4933. case SND_SOC_DAIFMT_CBM_CFM:
  4934. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4935. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4936. break;
  4937. default:
  4938. pr_err("%s: fmt %d\n",
  4939. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  4940. return -EINVAL;
  4941. }
  4942. return 0;
  4943. }
  4944. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  4945. struct snd_soc_dai *dai)
  4946. {
  4947. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4948. dev_get_drvdata(dai->dev);
  4949. struct msm_dai_q6_dai_data *dai_data =
  4950. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4951. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4952. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4953. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4954. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4955. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  4956. }
  4957. return 0;
  4958. }
  4959. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  4960. struct snd_soc_dai *dai)
  4961. {
  4962. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4963. dev_get_drvdata(dai->dev);
  4964. struct msm_dai_q6_dai_data *dai_data =
  4965. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4966. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4967. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4968. u16 port_id = 0;
  4969. int rc = 0;
  4970. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4971. &port_id) != 0) {
  4972. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4973. __func__, port_id);
  4974. }
  4975. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  4976. __func__, port_id);
  4977. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4978. rc = afe_close(port_id);
  4979. if (rc < 0)
  4980. dev_err(dai->dev, "fail to close AFE port\n");
  4981. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  4982. }
  4983. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  4984. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4985. }
  4986. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  4987. .startup = msm_dai_q6_mi2s_startup,
  4988. .prepare = msm_dai_q6_mi2s_prepare,
  4989. .hw_params = msm_dai_q6_mi2s_hw_params,
  4990. .hw_free = msm_dai_q6_mi2s_hw_free,
  4991. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  4992. .shutdown = msm_dai_q6_mi2s_shutdown,
  4993. };
  4994. /* Channel min and max are initialized base on platform data */
  4995. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  4996. {
  4997. .playback = {
  4998. .stream_name = "Primary MI2S Playback",
  4999. .aif_name = "PRI_MI2S_RX",
  5000. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5001. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5002. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5003. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5004. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5005. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5006. SNDRV_PCM_RATE_384000,
  5007. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5008. SNDRV_PCM_FMTBIT_S24_LE |
  5009. SNDRV_PCM_FMTBIT_S24_3LE,
  5010. .rate_min = 8000,
  5011. .rate_max = 384000,
  5012. },
  5013. .capture = {
  5014. .stream_name = "Primary MI2S Capture",
  5015. .aif_name = "PRI_MI2S_TX",
  5016. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5017. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5018. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5019. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5020. SNDRV_PCM_RATE_192000,
  5021. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5022. .rate_min = 8000,
  5023. .rate_max = 192000,
  5024. },
  5025. .ops = &msm_dai_q6_mi2s_ops,
  5026. .name = "Primary MI2S",
  5027. .id = MSM_PRIM_MI2S,
  5028. .probe = msm_dai_q6_dai_mi2s_probe,
  5029. .remove = msm_dai_q6_dai_mi2s_remove,
  5030. },
  5031. {
  5032. .playback = {
  5033. .stream_name = "Secondary MI2S Playback",
  5034. .aif_name = "SEC_MI2S_RX",
  5035. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5036. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5037. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5038. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5039. SNDRV_PCM_RATE_192000,
  5040. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5041. .rate_min = 8000,
  5042. .rate_max = 192000,
  5043. },
  5044. .capture = {
  5045. .stream_name = "Secondary MI2S Capture",
  5046. .aif_name = "SEC_MI2S_TX",
  5047. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5048. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5049. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5050. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5051. SNDRV_PCM_RATE_192000,
  5052. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5053. .rate_min = 8000,
  5054. .rate_max = 192000,
  5055. },
  5056. .ops = &msm_dai_q6_mi2s_ops,
  5057. .name = "Secondary MI2S",
  5058. .id = MSM_SEC_MI2S,
  5059. .probe = msm_dai_q6_dai_mi2s_probe,
  5060. .remove = msm_dai_q6_dai_mi2s_remove,
  5061. },
  5062. {
  5063. .playback = {
  5064. .stream_name = "Tertiary MI2S Playback",
  5065. .aif_name = "TERT_MI2S_RX",
  5066. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5067. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5068. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5069. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5070. SNDRV_PCM_RATE_192000,
  5071. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5072. .rate_min = 8000,
  5073. .rate_max = 192000,
  5074. },
  5075. .capture = {
  5076. .stream_name = "Tertiary MI2S Capture",
  5077. .aif_name = "TERT_MI2S_TX",
  5078. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5079. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5080. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5081. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5082. SNDRV_PCM_RATE_192000,
  5083. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5084. .rate_min = 8000,
  5085. .rate_max = 192000,
  5086. },
  5087. .ops = &msm_dai_q6_mi2s_ops,
  5088. .name = "Tertiary MI2S",
  5089. .id = MSM_TERT_MI2S,
  5090. .probe = msm_dai_q6_dai_mi2s_probe,
  5091. .remove = msm_dai_q6_dai_mi2s_remove,
  5092. },
  5093. {
  5094. .playback = {
  5095. .stream_name = "Quaternary MI2S Playback",
  5096. .aif_name = "QUAT_MI2S_RX",
  5097. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5098. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5099. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5100. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5101. SNDRV_PCM_RATE_192000,
  5102. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5103. .rate_min = 8000,
  5104. .rate_max = 192000,
  5105. },
  5106. .capture = {
  5107. .stream_name = "Quaternary MI2S Capture",
  5108. .aif_name = "QUAT_MI2S_TX",
  5109. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5110. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5111. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5112. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5113. SNDRV_PCM_RATE_192000,
  5114. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5115. .rate_min = 8000,
  5116. .rate_max = 192000,
  5117. },
  5118. .ops = &msm_dai_q6_mi2s_ops,
  5119. .name = "Quaternary MI2S",
  5120. .id = MSM_QUAT_MI2S,
  5121. .probe = msm_dai_q6_dai_mi2s_probe,
  5122. .remove = msm_dai_q6_dai_mi2s_remove,
  5123. },
  5124. {
  5125. .playback = {
  5126. .stream_name = "Quinary MI2S Playback",
  5127. .aif_name = "QUIN_MI2S_RX",
  5128. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5129. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5130. SNDRV_PCM_RATE_192000,
  5131. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5132. .rate_min = 8000,
  5133. .rate_max = 192000,
  5134. },
  5135. .capture = {
  5136. .stream_name = "Quinary MI2S Capture",
  5137. .aif_name = "QUIN_MI2S_TX",
  5138. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5139. SNDRV_PCM_RATE_16000,
  5140. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5141. .rate_min = 8000,
  5142. .rate_max = 48000,
  5143. },
  5144. .ops = &msm_dai_q6_mi2s_ops,
  5145. .name = "Quinary MI2S",
  5146. .id = MSM_QUIN_MI2S,
  5147. .probe = msm_dai_q6_dai_mi2s_probe,
  5148. .remove = msm_dai_q6_dai_mi2s_remove,
  5149. },
  5150. {
  5151. .playback = {
  5152. .stream_name = "Senary MI2S Playback",
  5153. .aif_name = "SEN_MI2S_RX",
  5154. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5155. SNDRV_PCM_RATE_16000,
  5156. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5157. .rate_min = 8000,
  5158. .rate_max = 48000,
  5159. },
  5160. .capture = {
  5161. .stream_name = "Senary MI2S Capture",
  5162. .aif_name = "SENARY_MI2S_TX",
  5163. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5164. SNDRV_PCM_RATE_16000,
  5165. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5166. .rate_min = 8000,
  5167. .rate_max = 48000,
  5168. },
  5169. .ops = &msm_dai_q6_mi2s_ops,
  5170. .name = "Senary MI2S",
  5171. .id = MSM_SENARY_MI2S,
  5172. .probe = msm_dai_q6_dai_mi2s_probe,
  5173. .remove = msm_dai_q6_dai_mi2s_remove,
  5174. },
  5175. {
  5176. .playback = {
  5177. .stream_name = "Secondary MI2S Playback SD1",
  5178. .aif_name = "SEC_MI2S_RX_SD1",
  5179. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5180. SNDRV_PCM_RATE_16000,
  5181. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5182. .rate_min = 8000,
  5183. .rate_max = 48000,
  5184. },
  5185. .id = MSM_SEC_MI2S_SD1,
  5186. },
  5187. {
  5188. .playback = {
  5189. .stream_name = "INT0 MI2S Playback",
  5190. .aif_name = "INT0_MI2S_RX",
  5191. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5192. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  5193. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  5194. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5195. SNDRV_PCM_FMTBIT_S24_LE |
  5196. SNDRV_PCM_FMTBIT_S24_3LE,
  5197. .rate_min = 8000,
  5198. .rate_max = 192000,
  5199. },
  5200. .capture = {
  5201. .stream_name = "INT0 MI2S Capture",
  5202. .aif_name = "INT0_MI2S_TX",
  5203. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5204. SNDRV_PCM_RATE_16000,
  5205. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5206. .rate_min = 8000,
  5207. .rate_max = 48000,
  5208. },
  5209. .ops = &msm_dai_q6_mi2s_ops,
  5210. .name = "INT0 MI2S",
  5211. .id = MSM_INT0_MI2S,
  5212. .probe = msm_dai_q6_dai_mi2s_probe,
  5213. .remove = msm_dai_q6_dai_mi2s_remove,
  5214. },
  5215. {
  5216. .playback = {
  5217. .stream_name = "INT1 MI2S Playback",
  5218. .aif_name = "INT1_MI2S_RX",
  5219. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5220. SNDRV_PCM_RATE_16000,
  5221. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5222. SNDRV_PCM_FMTBIT_S24_LE |
  5223. SNDRV_PCM_FMTBIT_S24_3LE,
  5224. .rate_min = 8000,
  5225. .rate_max = 48000,
  5226. },
  5227. .capture = {
  5228. .stream_name = "INT1 MI2S Capture",
  5229. .aif_name = "INT1_MI2S_TX",
  5230. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5231. SNDRV_PCM_RATE_16000,
  5232. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5233. .rate_min = 8000,
  5234. .rate_max = 48000,
  5235. },
  5236. .ops = &msm_dai_q6_mi2s_ops,
  5237. .name = "INT1 MI2S",
  5238. .id = MSM_INT1_MI2S,
  5239. .probe = msm_dai_q6_dai_mi2s_probe,
  5240. .remove = msm_dai_q6_dai_mi2s_remove,
  5241. },
  5242. {
  5243. .playback = {
  5244. .stream_name = "INT2 MI2S Playback",
  5245. .aif_name = "INT2_MI2S_RX",
  5246. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5247. SNDRV_PCM_RATE_16000,
  5248. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5249. SNDRV_PCM_FMTBIT_S24_LE |
  5250. SNDRV_PCM_FMTBIT_S24_3LE,
  5251. .rate_min = 8000,
  5252. .rate_max = 48000,
  5253. },
  5254. .capture = {
  5255. .stream_name = "INT2 MI2S Capture",
  5256. .aif_name = "INT2_MI2S_TX",
  5257. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5258. SNDRV_PCM_RATE_16000,
  5259. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5260. .rate_min = 8000,
  5261. .rate_max = 48000,
  5262. },
  5263. .ops = &msm_dai_q6_mi2s_ops,
  5264. .name = "INT2 MI2S",
  5265. .id = MSM_INT2_MI2S,
  5266. .probe = msm_dai_q6_dai_mi2s_probe,
  5267. .remove = msm_dai_q6_dai_mi2s_remove,
  5268. },
  5269. {
  5270. .playback = {
  5271. .stream_name = "INT3 MI2S Playback",
  5272. .aif_name = "INT3_MI2S_RX",
  5273. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5274. SNDRV_PCM_RATE_16000,
  5275. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5276. SNDRV_PCM_FMTBIT_S24_LE |
  5277. SNDRV_PCM_FMTBIT_S24_3LE,
  5278. .rate_min = 8000,
  5279. .rate_max = 48000,
  5280. },
  5281. .capture = {
  5282. .stream_name = "INT3 MI2S Capture",
  5283. .aif_name = "INT3_MI2S_TX",
  5284. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5285. SNDRV_PCM_RATE_16000,
  5286. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5287. .rate_min = 8000,
  5288. .rate_max = 48000,
  5289. },
  5290. .ops = &msm_dai_q6_mi2s_ops,
  5291. .name = "INT3 MI2S",
  5292. .id = MSM_INT3_MI2S,
  5293. .probe = msm_dai_q6_dai_mi2s_probe,
  5294. .remove = msm_dai_q6_dai_mi2s_remove,
  5295. },
  5296. {
  5297. .playback = {
  5298. .stream_name = "INT4 MI2S Playback",
  5299. .aif_name = "INT4_MI2S_RX",
  5300. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5301. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5302. SNDRV_PCM_RATE_192000,
  5303. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5304. SNDRV_PCM_FMTBIT_S24_LE |
  5305. SNDRV_PCM_FMTBIT_S24_3LE,
  5306. .rate_min = 8000,
  5307. .rate_max = 192000,
  5308. },
  5309. .capture = {
  5310. .stream_name = "INT4 MI2S Capture",
  5311. .aif_name = "INT4_MI2S_TX",
  5312. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5313. SNDRV_PCM_RATE_16000,
  5314. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5315. .rate_min = 8000,
  5316. .rate_max = 48000,
  5317. },
  5318. .ops = &msm_dai_q6_mi2s_ops,
  5319. .name = "INT4 MI2S",
  5320. .id = MSM_INT4_MI2S,
  5321. .probe = msm_dai_q6_dai_mi2s_probe,
  5322. .remove = msm_dai_q6_dai_mi2s_remove,
  5323. },
  5324. {
  5325. .playback = {
  5326. .stream_name = "INT5 MI2S Playback",
  5327. .aif_name = "INT5_MI2S_RX",
  5328. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5329. SNDRV_PCM_RATE_16000,
  5330. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5331. SNDRV_PCM_FMTBIT_S24_LE |
  5332. SNDRV_PCM_FMTBIT_S24_3LE,
  5333. .rate_min = 8000,
  5334. .rate_max = 48000,
  5335. },
  5336. .capture = {
  5337. .stream_name = "INT5 MI2S Capture",
  5338. .aif_name = "INT5_MI2S_TX",
  5339. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5340. SNDRV_PCM_RATE_16000,
  5341. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5342. .rate_min = 8000,
  5343. .rate_max = 48000,
  5344. },
  5345. .ops = &msm_dai_q6_mi2s_ops,
  5346. .name = "INT5 MI2S",
  5347. .id = MSM_INT5_MI2S,
  5348. .probe = msm_dai_q6_dai_mi2s_probe,
  5349. .remove = msm_dai_q6_dai_mi2s_remove,
  5350. },
  5351. {
  5352. .playback = {
  5353. .stream_name = "INT6 MI2S Playback",
  5354. .aif_name = "INT6_MI2S_RX",
  5355. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5356. SNDRV_PCM_RATE_16000,
  5357. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5358. SNDRV_PCM_FMTBIT_S24_LE |
  5359. SNDRV_PCM_FMTBIT_S24_3LE,
  5360. .rate_min = 8000,
  5361. .rate_max = 48000,
  5362. },
  5363. .capture = {
  5364. .stream_name = "INT6 MI2S Capture",
  5365. .aif_name = "INT6_MI2S_TX",
  5366. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5367. SNDRV_PCM_RATE_16000,
  5368. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5369. .rate_min = 8000,
  5370. .rate_max = 48000,
  5371. },
  5372. .ops = &msm_dai_q6_mi2s_ops,
  5373. .name = "INT6 MI2S",
  5374. .id = MSM_INT6_MI2S,
  5375. .probe = msm_dai_q6_dai_mi2s_probe,
  5376. .remove = msm_dai_q6_dai_mi2s_remove,
  5377. },
  5378. };
  5379. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  5380. unsigned int *ch_cnt)
  5381. {
  5382. u8 num_of_sd_lines;
  5383. num_of_sd_lines = num_of_bits_set(sd_lines);
  5384. switch (num_of_sd_lines) {
  5385. case 0:
  5386. pr_debug("%s: no line is assigned\n", __func__);
  5387. break;
  5388. case 1:
  5389. switch (sd_lines) {
  5390. case MSM_MI2S_SD0:
  5391. *config_ptr = AFE_PORT_I2S_SD0;
  5392. break;
  5393. case MSM_MI2S_SD1:
  5394. *config_ptr = AFE_PORT_I2S_SD1;
  5395. break;
  5396. case MSM_MI2S_SD2:
  5397. *config_ptr = AFE_PORT_I2S_SD2;
  5398. break;
  5399. case MSM_MI2S_SD3:
  5400. *config_ptr = AFE_PORT_I2S_SD3;
  5401. break;
  5402. case MSM_MI2S_SD4:
  5403. *config_ptr = AFE_PORT_I2S_SD4;
  5404. break;
  5405. case MSM_MI2S_SD5:
  5406. *config_ptr = AFE_PORT_I2S_SD5;
  5407. break;
  5408. case MSM_MI2S_SD6:
  5409. *config_ptr = AFE_PORT_I2S_SD6;
  5410. break;
  5411. case MSM_MI2S_SD7:
  5412. *config_ptr = AFE_PORT_I2S_SD7;
  5413. break;
  5414. default:
  5415. pr_err("%s: invalid SD lines %d\n",
  5416. __func__, sd_lines);
  5417. goto error_invalid_data;
  5418. }
  5419. break;
  5420. case 2:
  5421. switch (sd_lines) {
  5422. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  5423. *config_ptr = AFE_PORT_I2S_QUAD01;
  5424. break;
  5425. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5426. *config_ptr = AFE_PORT_I2S_QUAD23;
  5427. break;
  5428. case MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5429. *config_ptr = AFE_PORT_I2S_QUAD45;
  5430. break;
  5431. case MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5432. *config_ptr = AFE_PORT_I2S_QUAD67;
  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 3:
  5441. switch (sd_lines) {
  5442. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  5443. *config_ptr = AFE_PORT_I2S_6CHS;
  5444. break;
  5445. default:
  5446. pr_err("%s: invalid SD lines %d\n",
  5447. __func__, sd_lines);
  5448. goto error_invalid_data;
  5449. }
  5450. break;
  5451. case 4:
  5452. switch (sd_lines) {
  5453. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5454. *config_ptr = AFE_PORT_I2S_8CHS;
  5455. break;
  5456. case MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5457. *config_ptr = AFE_PORT_I2S_8CHS_2;
  5458. break;
  5459. default:
  5460. pr_err("%s: invalid SD lines %d\n",
  5461. __func__, sd_lines);
  5462. goto error_invalid_data;
  5463. }
  5464. break;
  5465. case 5:
  5466. switch (sd_lines) {
  5467. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5468. | MSM_MI2S_SD3 | MSM_MI2S_SD4:
  5469. *config_ptr = AFE_PORT_I2S_10CHS;
  5470. break;
  5471. default:
  5472. pr_err("%s: invalid SD lines %d\n",
  5473. __func__, sd_lines);
  5474. goto error_invalid_data;
  5475. }
  5476. break;
  5477. case 6:
  5478. switch (sd_lines) {
  5479. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5480. | MSM_MI2S_SD3 | MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5481. *config_ptr = AFE_PORT_I2S_12CHS;
  5482. break;
  5483. default:
  5484. pr_err("%s: invalid SD lines %d\n",
  5485. __func__, sd_lines);
  5486. goto error_invalid_data;
  5487. }
  5488. break;
  5489. case 7:
  5490. switch (sd_lines) {
  5491. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5492. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6:
  5493. *config_ptr = AFE_PORT_I2S_14CHS;
  5494. break;
  5495. default:
  5496. pr_err("%s: invalid SD lines %d\n",
  5497. __func__, sd_lines);
  5498. goto error_invalid_data;
  5499. }
  5500. break;
  5501. case 8:
  5502. switch (sd_lines) {
  5503. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5504. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5505. *config_ptr = AFE_PORT_I2S_16CHS;
  5506. break;
  5507. default:
  5508. pr_err("%s: invalid SD lines %d\n",
  5509. __func__, sd_lines);
  5510. goto error_invalid_data;
  5511. }
  5512. break;
  5513. default:
  5514. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  5515. goto error_invalid_data;
  5516. }
  5517. *ch_cnt = num_of_sd_lines;
  5518. return 0;
  5519. error_invalid_data:
  5520. pr_err("%s: invalid data\n", __func__);
  5521. return -EINVAL;
  5522. }
  5523. static int msm_dai_q6_mi2s_platform_data_validation(
  5524. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  5525. {
  5526. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  5527. struct msm_mi2s_pdata *mi2s_pdata =
  5528. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  5529. unsigned int ch_cnt;
  5530. int rc = 0;
  5531. u16 sd_line;
  5532. if (mi2s_pdata == NULL) {
  5533. pr_err("%s: mi2s_pdata NULL", __func__);
  5534. return -EINVAL;
  5535. }
  5536. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  5537. &sd_line, &ch_cnt);
  5538. if (rc < 0) {
  5539. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  5540. goto rtn;
  5541. }
  5542. if (ch_cnt) {
  5543. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5544. sd_line;
  5545. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  5546. dai_driver->playback.channels_min = 1;
  5547. dai_driver->playback.channels_max = ch_cnt << 1;
  5548. } else {
  5549. dai_driver->playback.channels_min = 0;
  5550. dai_driver->playback.channels_max = 0;
  5551. }
  5552. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  5553. &sd_line, &ch_cnt);
  5554. if (rc < 0) {
  5555. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  5556. goto rtn;
  5557. }
  5558. if (ch_cnt) {
  5559. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5560. sd_line;
  5561. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  5562. dai_driver->capture.channels_min = 1;
  5563. dai_driver->capture.channels_max = ch_cnt << 1;
  5564. } else {
  5565. dai_driver->capture.channels_min = 0;
  5566. dai_driver->capture.channels_max = 0;
  5567. }
  5568. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  5569. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  5570. dai_data->tx_dai.pdata_mi2s_lines);
  5571. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  5572. __func__, dai_driver->playback.channels_max,
  5573. dai_driver->capture.channels_max);
  5574. rtn:
  5575. return rc;
  5576. }
  5577. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  5578. .name = "msm-dai-q6-mi2s",
  5579. };
  5580. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  5581. {
  5582. struct msm_dai_q6_mi2s_dai_data *dai_data;
  5583. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  5584. u32 tx_line = 0;
  5585. u32 rx_line = 0;
  5586. u32 mi2s_intf = 0;
  5587. struct msm_mi2s_pdata *mi2s_pdata;
  5588. int rc;
  5589. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  5590. &mi2s_intf);
  5591. if (rc) {
  5592. dev_err(&pdev->dev,
  5593. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  5594. goto rtn;
  5595. }
  5596. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  5597. mi2s_intf);
  5598. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  5599. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  5600. dev_err(&pdev->dev,
  5601. "%s: Invalid MI2S ID %u from Device Tree\n",
  5602. __func__, mi2s_intf);
  5603. rc = -ENXIO;
  5604. goto rtn;
  5605. }
  5606. pdev->id = mi2s_intf;
  5607. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  5608. if (!mi2s_pdata) {
  5609. rc = -ENOMEM;
  5610. goto rtn;
  5611. }
  5612. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  5613. &rx_line);
  5614. if (rc) {
  5615. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  5616. "qcom,msm-mi2s-rx-lines");
  5617. goto free_pdata;
  5618. }
  5619. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  5620. &tx_line);
  5621. if (rc) {
  5622. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  5623. "qcom,msm-mi2s-tx-lines");
  5624. goto free_pdata;
  5625. }
  5626. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  5627. dev_name(&pdev->dev), rx_line, tx_line);
  5628. mi2s_pdata->rx_sd_lines = rx_line;
  5629. mi2s_pdata->tx_sd_lines = tx_line;
  5630. mi2s_pdata->intf_id = mi2s_intf;
  5631. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  5632. GFP_KERNEL);
  5633. if (!dai_data) {
  5634. rc = -ENOMEM;
  5635. goto free_pdata;
  5636. } else
  5637. dev_set_drvdata(&pdev->dev, dai_data);
  5638. rc = of_property_read_u32(pdev->dev.of_node,
  5639. "qcom,msm-dai-is-island-supported",
  5640. &dai_data->is_island_dai);
  5641. if (rc)
  5642. dev_dbg(&pdev->dev, "island supported entry not found\n");
  5643. pdev->dev.platform_data = mi2s_pdata;
  5644. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  5645. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  5646. if (rc < 0)
  5647. goto free_dai_data;
  5648. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  5649. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  5650. if (rc < 0)
  5651. goto err_register;
  5652. return 0;
  5653. err_register:
  5654. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  5655. free_dai_data:
  5656. kfree(dai_data);
  5657. free_pdata:
  5658. kfree(mi2s_pdata);
  5659. rtn:
  5660. return rc;
  5661. }
  5662. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  5663. {
  5664. snd_soc_unregister_component(&pdev->dev);
  5665. return 0;
  5666. }
  5667. static const struct snd_soc_component_driver msm_dai_q6_component = {
  5668. .name = "msm-dai-q6-dev",
  5669. };
  5670. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  5671. {
  5672. int rc, id, i, len;
  5673. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  5674. char stream_name[80];
  5675. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  5676. if (rc) {
  5677. dev_err(&pdev->dev,
  5678. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  5679. return rc;
  5680. }
  5681. pdev->id = id;
  5682. pr_debug("%s: dev name %s, id:%d\n", __func__,
  5683. dev_name(&pdev->dev), pdev->id);
  5684. switch (id) {
  5685. case SLIMBUS_0_RX:
  5686. strlcpy(stream_name, "Slimbus Playback", 80);
  5687. goto register_slim_playback;
  5688. case SLIMBUS_2_RX:
  5689. strlcpy(stream_name, "Slimbus2 Playback", 80);
  5690. goto register_slim_playback;
  5691. case SLIMBUS_1_RX:
  5692. strlcpy(stream_name, "Slimbus1 Playback", 80);
  5693. goto register_slim_playback;
  5694. case SLIMBUS_3_RX:
  5695. strlcpy(stream_name, "Slimbus3 Playback", 80);
  5696. goto register_slim_playback;
  5697. case SLIMBUS_4_RX:
  5698. strlcpy(stream_name, "Slimbus4 Playback", 80);
  5699. goto register_slim_playback;
  5700. case SLIMBUS_5_RX:
  5701. strlcpy(stream_name, "Slimbus5 Playback", 80);
  5702. goto register_slim_playback;
  5703. case SLIMBUS_6_RX:
  5704. strlcpy(stream_name, "Slimbus6 Playback", 80);
  5705. goto register_slim_playback;
  5706. case SLIMBUS_7_RX:
  5707. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  5708. goto register_slim_playback;
  5709. case SLIMBUS_8_RX:
  5710. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  5711. goto register_slim_playback;
  5712. case SLIMBUS_9_RX:
  5713. strlcpy(stream_name, "Slimbus9 Playback", sizeof(stream_name));
  5714. goto register_slim_playback;
  5715. register_slim_playback:
  5716. rc = -ENODEV;
  5717. len = strnlen(stream_name, 80);
  5718. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  5719. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  5720. !strcmp(stream_name,
  5721. msm_dai_q6_slimbus_rx_dai[i]
  5722. .playback.stream_name)) {
  5723. rc = snd_soc_register_component(&pdev->dev,
  5724. &msm_dai_q6_component,
  5725. &msm_dai_q6_slimbus_rx_dai[i], 1);
  5726. break;
  5727. }
  5728. }
  5729. if (rc)
  5730. pr_err("%s: Device not found stream name %s\n",
  5731. __func__, stream_name);
  5732. break;
  5733. case SLIMBUS_0_TX:
  5734. strlcpy(stream_name, "Slimbus Capture", 80);
  5735. goto register_slim_capture;
  5736. case SLIMBUS_1_TX:
  5737. strlcpy(stream_name, "Slimbus1 Capture", 80);
  5738. goto register_slim_capture;
  5739. case SLIMBUS_2_TX:
  5740. strlcpy(stream_name, "Slimbus2 Capture", 80);
  5741. goto register_slim_capture;
  5742. case SLIMBUS_3_TX:
  5743. strlcpy(stream_name, "Slimbus3 Capture", 80);
  5744. goto register_slim_capture;
  5745. case SLIMBUS_4_TX:
  5746. strlcpy(stream_name, "Slimbus4 Capture", 80);
  5747. goto register_slim_capture;
  5748. case SLIMBUS_5_TX:
  5749. strlcpy(stream_name, "Slimbus5 Capture", 80);
  5750. goto register_slim_capture;
  5751. case SLIMBUS_6_TX:
  5752. strlcpy(stream_name, "Slimbus6 Capture", 80);
  5753. goto register_slim_capture;
  5754. case SLIMBUS_7_TX:
  5755. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  5756. goto register_slim_capture;
  5757. case SLIMBUS_8_TX:
  5758. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  5759. goto register_slim_capture;
  5760. case SLIMBUS_9_TX:
  5761. strlcpy(stream_name, "Slimbus9 Capture", sizeof(stream_name));
  5762. goto register_slim_capture;
  5763. register_slim_capture:
  5764. rc = -ENODEV;
  5765. len = strnlen(stream_name, 80);
  5766. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  5767. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  5768. !strcmp(stream_name,
  5769. msm_dai_q6_slimbus_tx_dai[i]
  5770. .capture.stream_name)) {
  5771. rc = snd_soc_register_component(&pdev->dev,
  5772. &msm_dai_q6_component,
  5773. &msm_dai_q6_slimbus_tx_dai[i], 1);
  5774. break;
  5775. }
  5776. }
  5777. if (rc)
  5778. pr_err("%s: Device not found stream name %s\n",
  5779. __func__, stream_name);
  5780. break;
  5781. case AFE_LOOPBACK_TX:
  5782. rc = snd_soc_register_component(&pdev->dev,
  5783. &msm_dai_q6_component,
  5784. &msm_dai_q6_afe_lb_tx_dai[0],
  5785. 1);
  5786. break;
  5787. case INT_BT_SCO_RX:
  5788. rc = snd_soc_register_component(&pdev->dev,
  5789. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  5790. break;
  5791. case INT_BT_SCO_TX:
  5792. rc = snd_soc_register_component(&pdev->dev,
  5793. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  5794. break;
  5795. case INT_BT_A2DP_RX:
  5796. rc = snd_soc_register_component(&pdev->dev,
  5797. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  5798. break;
  5799. case INT_FM_RX:
  5800. rc = snd_soc_register_component(&pdev->dev,
  5801. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  5802. break;
  5803. case INT_FM_TX:
  5804. rc = snd_soc_register_component(&pdev->dev,
  5805. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  5806. break;
  5807. case AFE_PORT_ID_USB_RX:
  5808. rc = snd_soc_register_component(&pdev->dev,
  5809. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  5810. break;
  5811. case AFE_PORT_ID_USB_TX:
  5812. rc = snd_soc_register_component(&pdev->dev,
  5813. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  5814. break;
  5815. case RT_PROXY_DAI_001_RX:
  5816. strlcpy(stream_name, "AFE Playback", 80);
  5817. goto register_afe_playback;
  5818. case RT_PROXY_DAI_002_RX:
  5819. strlcpy(stream_name, "AFE-PROXY RX", 80);
  5820. register_afe_playback:
  5821. rc = -ENODEV;
  5822. len = strnlen(stream_name, 80);
  5823. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  5824. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  5825. !strcmp(stream_name,
  5826. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  5827. rc = snd_soc_register_component(&pdev->dev,
  5828. &msm_dai_q6_component,
  5829. &msm_dai_q6_afe_rx_dai[i], 1);
  5830. break;
  5831. }
  5832. }
  5833. if (rc)
  5834. pr_err("%s: Device not found stream name %s\n",
  5835. __func__, stream_name);
  5836. break;
  5837. case RT_PROXY_DAI_001_TX:
  5838. strlcpy(stream_name, "AFE-PROXY TX", 80);
  5839. goto register_afe_capture;
  5840. case RT_PROXY_DAI_002_TX:
  5841. strlcpy(stream_name, "AFE Capture", 80);
  5842. register_afe_capture:
  5843. rc = -ENODEV;
  5844. len = strnlen(stream_name, 80);
  5845. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  5846. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  5847. !strcmp(stream_name,
  5848. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  5849. rc = snd_soc_register_component(&pdev->dev,
  5850. &msm_dai_q6_component,
  5851. &msm_dai_q6_afe_tx_dai[i], 1);
  5852. break;
  5853. }
  5854. }
  5855. if (rc)
  5856. pr_err("%s: Device not found stream name %s\n",
  5857. __func__, stream_name);
  5858. break;
  5859. case VOICE_PLAYBACK_TX:
  5860. strlcpy(stream_name, "Voice Farend Playback", 80);
  5861. goto register_voice_playback;
  5862. case VOICE2_PLAYBACK_TX:
  5863. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  5864. register_voice_playback:
  5865. rc = -ENODEV;
  5866. len = strnlen(stream_name, 80);
  5867. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  5868. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  5869. && !strcmp(stream_name,
  5870. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  5871. rc = snd_soc_register_component(&pdev->dev,
  5872. &msm_dai_q6_component,
  5873. &msm_dai_q6_voc_playback_dai[i], 1);
  5874. break;
  5875. }
  5876. }
  5877. if (rc)
  5878. pr_err("%s Device not found stream name %s\n",
  5879. __func__, stream_name);
  5880. break;
  5881. case VOICE_RECORD_RX:
  5882. strlcpy(stream_name, "Voice Downlink Capture", 80);
  5883. goto register_uplink_capture;
  5884. case VOICE_RECORD_TX:
  5885. strlcpy(stream_name, "Voice Uplink Capture", 80);
  5886. register_uplink_capture:
  5887. rc = -ENODEV;
  5888. len = strnlen(stream_name, 80);
  5889. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  5890. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  5891. && !strcmp(stream_name,
  5892. msm_dai_q6_incall_record_dai[i].
  5893. capture.stream_name)) {
  5894. rc = snd_soc_register_component(&pdev->dev,
  5895. &msm_dai_q6_component,
  5896. &msm_dai_q6_incall_record_dai[i], 1);
  5897. break;
  5898. }
  5899. }
  5900. if (rc)
  5901. pr_err("%s: Device not found stream name %s\n",
  5902. __func__, stream_name);
  5903. break;
  5904. default:
  5905. rc = -ENODEV;
  5906. break;
  5907. }
  5908. return rc;
  5909. }
  5910. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  5911. {
  5912. snd_soc_unregister_component(&pdev->dev);
  5913. return 0;
  5914. }
  5915. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  5916. { .compatible = "qcom,msm-dai-q6-dev", },
  5917. { }
  5918. };
  5919. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  5920. static struct platform_driver msm_dai_q6_dev = {
  5921. .probe = msm_dai_q6_dev_probe,
  5922. .remove = msm_dai_q6_dev_remove,
  5923. .driver = {
  5924. .name = "msm-dai-q6-dev",
  5925. .owner = THIS_MODULE,
  5926. .of_match_table = msm_dai_q6_dev_dt_match,
  5927. .suppress_bind_attrs = true,
  5928. },
  5929. };
  5930. static int msm_dai_q6_probe(struct platform_device *pdev)
  5931. {
  5932. int rc;
  5933. pr_debug("%s: dev name %s, id:%d\n", __func__,
  5934. dev_name(&pdev->dev), pdev->id);
  5935. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5936. if (rc) {
  5937. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5938. __func__, rc);
  5939. } else
  5940. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5941. return rc;
  5942. }
  5943. static int msm_dai_q6_remove(struct platform_device *pdev)
  5944. {
  5945. of_platform_depopulate(&pdev->dev);
  5946. return 0;
  5947. }
  5948. static const struct of_device_id msm_dai_q6_dt_match[] = {
  5949. { .compatible = "qcom,msm-dai-q6", },
  5950. { }
  5951. };
  5952. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  5953. static struct platform_driver msm_dai_q6 = {
  5954. .probe = msm_dai_q6_probe,
  5955. .remove = msm_dai_q6_remove,
  5956. .driver = {
  5957. .name = "msm-dai-q6",
  5958. .owner = THIS_MODULE,
  5959. .of_match_table = msm_dai_q6_dt_match,
  5960. .suppress_bind_attrs = true,
  5961. },
  5962. };
  5963. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  5964. {
  5965. int rc;
  5966. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5967. if (rc) {
  5968. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5969. __func__, rc);
  5970. } else
  5971. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5972. return rc;
  5973. }
  5974. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  5975. {
  5976. return 0;
  5977. }
  5978. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  5979. { .compatible = "qcom,msm-dai-mi2s", },
  5980. { }
  5981. };
  5982. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  5983. static struct platform_driver msm_dai_mi2s_q6 = {
  5984. .probe = msm_dai_mi2s_q6_probe,
  5985. .remove = msm_dai_mi2s_q6_remove,
  5986. .driver = {
  5987. .name = "msm-dai-mi2s",
  5988. .owner = THIS_MODULE,
  5989. .of_match_table = msm_dai_mi2s_dt_match,
  5990. .suppress_bind_attrs = true,
  5991. },
  5992. };
  5993. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  5994. { .compatible = "qcom,msm-dai-q6-mi2s", },
  5995. { }
  5996. };
  5997. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  5998. static struct platform_driver msm_dai_q6_mi2s_driver = {
  5999. .probe = msm_dai_q6_mi2s_dev_probe,
  6000. .remove = msm_dai_q6_mi2s_dev_remove,
  6001. .driver = {
  6002. .name = "msm-dai-q6-mi2s",
  6003. .owner = THIS_MODULE,
  6004. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  6005. .suppress_bind_attrs = true,
  6006. },
  6007. };
  6008. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  6009. {
  6010. int rc, id;
  6011. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6012. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6013. if (rc) {
  6014. dev_err(&pdev->dev,
  6015. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6016. return rc;
  6017. }
  6018. pdev->id = id;
  6019. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6020. dev_name(&pdev->dev), pdev->id);
  6021. switch (pdev->id) {
  6022. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  6023. rc = snd_soc_register_component(&pdev->dev,
  6024. &msm_dai_spdif_q6_component,
  6025. &msm_dai_q6_spdif_spdif_rx_dai[0], 1);
  6026. break;
  6027. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  6028. rc = snd_soc_register_component(&pdev->dev,
  6029. &msm_dai_spdif_q6_component,
  6030. &msm_dai_q6_spdif_spdif_rx_dai[1], 1);
  6031. break;
  6032. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  6033. rc = snd_soc_register_component(&pdev->dev,
  6034. &msm_dai_spdif_q6_component,
  6035. &msm_dai_q6_spdif_spdif_tx_dai[0], 1);
  6036. break;
  6037. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  6038. rc = snd_soc_register_component(&pdev->dev,
  6039. &msm_dai_spdif_q6_component,
  6040. &msm_dai_q6_spdif_spdif_tx_dai[1], 1);
  6041. break;
  6042. default:
  6043. dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
  6044. rc = -ENODEV;
  6045. break;
  6046. }
  6047. return rc;
  6048. }
  6049. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  6050. {
  6051. snd_soc_unregister_component(&pdev->dev);
  6052. return 0;
  6053. }
  6054. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  6055. {.compatible = "qcom,msm-dai-q6-spdif"},
  6056. {}
  6057. };
  6058. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  6059. static struct platform_driver msm_dai_q6_spdif_driver = {
  6060. .probe = msm_dai_q6_spdif_dev_probe,
  6061. .remove = msm_dai_q6_spdif_dev_remove,
  6062. .driver = {
  6063. .name = "msm-dai-q6-spdif",
  6064. .owner = THIS_MODULE,
  6065. .of_match_table = msm_dai_q6_spdif_dt_match,
  6066. .suppress_bind_attrs = true,
  6067. },
  6068. };
  6069. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  6070. struct afe_clk_set *clk_set, u32 mode)
  6071. {
  6072. switch (group_id) {
  6073. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  6074. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  6075. if (mode)
  6076. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  6077. else
  6078. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  6079. break;
  6080. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  6081. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  6082. if (mode)
  6083. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  6084. else
  6085. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  6086. break;
  6087. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  6088. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  6089. if (mode)
  6090. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  6091. else
  6092. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  6093. break;
  6094. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  6095. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  6096. if (mode)
  6097. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  6098. else
  6099. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  6100. break;
  6101. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  6102. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  6103. if (mode)
  6104. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  6105. else
  6106. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  6107. break;
  6108. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  6109. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  6110. if (mode)
  6111. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_IBIT;
  6112. else
  6113. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_EBIT;
  6114. break;
  6115. default:
  6116. return -EINVAL;
  6117. }
  6118. return 0;
  6119. }
  6120. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  6121. {
  6122. int rc = 0;
  6123. const uint32_t *port_id_array = NULL;
  6124. uint32_t array_length = 0;
  6125. int i = 0;
  6126. int group_idx = 0;
  6127. u32 clk_mode = 0;
  6128. /* extract tdm group info into static */
  6129. rc = of_property_read_u32(pdev->dev.of_node,
  6130. "qcom,msm-cpudai-tdm-group-id",
  6131. (u32 *)&tdm_group_cfg.group_id);
  6132. if (rc) {
  6133. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  6134. __func__, "qcom,msm-cpudai-tdm-group-id");
  6135. goto rtn;
  6136. }
  6137. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  6138. __func__, tdm_group_cfg.group_id);
  6139. rc = of_property_read_u32(pdev->dev.of_node,
  6140. "qcom,msm-cpudai-tdm-group-num-ports",
  6141. &num_tdm_group_ports);
  6142. if (rc) {
  6143. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  6144. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  6145. goto rtn;
  6146. }
  6147. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  6148. __func__, num_tdm_group_ports);
  6149. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  6150. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  6151. __func__, num_tdm_group_ports,
  6152. AFE_GROUP_DEVICE_NUM_PORTS);
  6153. rc = -EINVAL;
  6154. goto rtn;
  6155. }
  6156. port_id_array = of_get_property(pdev->dev.of_node,
  6157. "qcom,msm-cpudai-tdm-group-port-id",
  6158. &array_length);
  6159. if (port_id_array == NULL) {
  6160. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  6161. __func__);
  6162. rc = -EINVAL;
  6163. goto rtn;
  6164. }
  6165. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  6166. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  6167. __func__, array_length,
  6168. sizeof(uint32_t) * num_tdm_group_ports);
  6169. rc = -EINVAL;
  6170. goto rtn;
  6171. }
  6172. for (i = 0; i < num_tdm_group_ports; i++)
  6173. tdm_group_cfg.port_id[i] =
  6174. (u16)be32_to_cpu(port_id_array[i]);
  6175. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  6176. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  6177. tdm_group_cfg.port_id[i] =
  6178. AFE_PORT_INVALID;
  6179. /* extract tdm clk info into static */
  6180. rc = of_property_read_u32(pdev->dev.of_node,
  6181. "qcom,msm-cpudai-tdm-clk-rate",
  6182. &tdm_clk_set.clk_freq_in_hz);
  6183. if (rc) {
  6184. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  6185. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  6186. goto rtn;
  6187. }
  6188. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  6189. __func__, tdm_clk_set.clk_freq_in_hz);
  6190. /* initialize static tdm clk attribute to default value */
  6191. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  6192. /* extract tdm clk attribute into static */
  6193. if (of_find_property(pdev->dev.of_node,
  6194. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  6195. rc = of_property_read_u16(pdev->dev.of_node,
  6196. "qcom,msm-cpudai-tdm-clk-attribute",
  6197. &tdm_clk_set.clk_attri);
  6198. if (rc) {
  6199. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  6200. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  6201. goto rtn;
  6202. }
  6203. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  6204. __func__, tdm_clk_set.clk_attri);
  6205. } else
  6206. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  6207. /* extract tdm lane cfg to static */
  6208. tdm_lane_cfg.port_id = tdm_group_cfg.group_id;
  6209. tdm_lane_cfg.lane_mask = AFE_LANE_MASK_INVALID;
  6210. if (of_find_property(pdev->dev.of_node,
  6211. "qcom,msm-cpudai-tdm-lane-mask", NULL)) {
  6212. rc = of_property_read_u16(pdev->dev.of_node,
  6213. "qcom,msm-cpudai-tdm-lane-mask",
  6214. &tdm_lane_cfg.lane_mask);
  6215. if (rc) {
  6216. dev_err(&pdev->dev, "%s: value for tdm lane mask not found %s\n",
  6217. __func__, "qcom,msm-cpudai-tdm-lane-mask");
  6218. goto rtn;
  6219. }
  6220. dev_dbg(&pdev->dev, "%s: tdm lane mask from DT file %d\n",
  6221. __func__, tdm_lane_cfg.lane_mask);
  6222. } else
  6223. dev_dbg(&pdev->dev, "%s: tdm lane mask not found\n", __func__);
  6224. /* extract tdm clk src master/slave info into static */
  6225. rc = of_property_read_u32(pdev->dev.of_node,
  6226. "qcom,msm-cpudai-tdm-clk-internal",
  6227. &clk_mode);
  6228. if (rc) {
  6229. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  6230. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  6231. goto rtn;
  6232. }
  6233. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  6234. __func__, clk_mode);
  6235. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  6236. &tdm_clk_set, clk_mode);
  6237. if (rc) {
  6238. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  6239. __func__, tdm_group_cfg.group_id);
  6240. goto rtn;
  6241. }
  6242. /* other initializations within device group */
  6243. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  6244. if (group_idx < 0) {
  6245. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  6246. __func__, tdm_group_cfg.group_id);
  6247. rc = -EINVAL;
  6248. goto rtn;
  6249. }
  6250. atomic_set(&tdm_group_ref[group_idx], 0);
  6251. /* probe child node info */
  6252. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6253. if (rc) {
  6254. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6255. __func__, rc);
  6256. goto rtn;
  6257. } else
  6258. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6259. rtn:
  6260. return rc;
  6261. }
  6262. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  6263. {
  6264. return 0;
  6265. }
  6266. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  6267. { .compatible = "qcom,msm-dai-tdm", },
  6268. {}
  6269. };
  6270. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  6271. static struct platform_driver msm_dai_tdm_q6 = {
  6272. .probe = msm_dai_tdm_q6_probe,
  6273. .remove = msm_dai_tdm_q6_remove,
  6274. .driver = {
  6275. .name = "msm-dai-tdm",
  6276. .owner = THIS_MODULE,
  6277. .of_match_table = msm_dai_tdm_dt_match,
  6278. .suppress_bind_attrs = true,
  6279. },
  6280. };
  6281. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  6282. struct snd_ctl_elem_value *ucontrol)
  6283. {
  6284. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6285. int value = ucontrol->value.integer.value[0];
  6286. switch (value) {
  6287. case 0:
  6288. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  6289. break;
  6290. case 1:
  6291. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  6292. break;
  6293. case 2:
  6294. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  6295. break;
  6296. default:
  6297. pr_err("%s: data_format invalid\n", __func__);
  6298. break;
  6299. }
  6300. pr_debug("%s: data_format = %d\n",
  6301. __func__, dai_data->port_cfg.tdm.data_format);
  6302. return 0;
  6303. }
  6304. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  6305. struct snd_ctl_elem_value *ucontrol)
  6306. {
  6307. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6308. ucontrol->value.integer.value[0] =
  6309. dai_data->port_cfg.tdm.data_format;
  6310. pr_debug("%s: data_format = %d\n",
  6311. __func__, dai_data->port_cfg.tdm.data_format);
  6312. return 0;
  6313. }
  6314. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  6315. struct snd_ctl_elem_value *ucontrol)
  6316. {
  6317. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6318. int value = ucontrol->value.integer.value[0];
  6319. dai_data->port_cfg.custom_tdm_header.header_type = value;
  6320. pr_debug("%s: header_type = %d\n",
  6321. __func__,
  6322. dai_data->port_cfg.custom_tdm_header.header_type);
  6323. return 0;
  6324. }
  6325. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  6326. struct snd_ctl_elem_value *ucontrol)
  6327. {
  6328. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6329. ucontrol->value.integer.value[0] =
  6330. dai_data->port_cfg.custom_tdm_header.header_type;
  6331. pr_debug("%s: header_type = %d\n",
  6332. __func__,
  6333. dai_data->port_cfg.custom_tdm_header.header_type);
  6334. return 0;
  6335. }
  6336. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  6337. struct snd_ctl_elem_value *ucontrol)
  6338. {
  6339. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6340. int i = 0;
  6341. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  6342. dai_data->port_cfg.custom_tdm_header.header[i] =
  6343. (u16)ucontrol->value.integer.value[i];
  6344. pr_debug("%s: header #%d = 0x%x\n",
  6345. __func__, i,
  6346. dai_data->port_cfg.custom_tdm_header.header[i]);
  6347. }
  6348. return 0;
  6349. }
  6350. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  6351. struct snd_ctl_elem_value *ucontrol)
  6352. {
  6353. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  6354. int i = 0;
  6355. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  6356. ucontrol->value.integer.value[i] =
  6357. dai_data->port_cfg.custom_tdm_header.header[i];
  6358. pr_debug("%s: header #%d = 0x%x\n",
  6359. __func__, i,
  6360. dai_data->port_cfg.custom_tdm_header.header[i]);
  6361. }
  6362. return 0;
  6363. }
  6364. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  6365. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  6366. msm_dai_q6_tdm_data_format_get,
  6367. msm_dai_q6_tdm_data_format_put),
  6368. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  6369. msm_dai_q6_tdm_data_format_get,
  6370. msm_dai_q6_tdm_data_format_put),
  6371. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  6372. msm_dai_q6_tdm_data_format_get,
  6373. msm_dai_q6_tdm_data_format_put),
  6374. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  6375. msm_dai_q6_tdm_data_format_get,
  6376. msm_dai_q6_tdm_data_format_put),
  6377. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  6378. msm_dai_q6_tdm_data_format_get,
  6379. msm_dai_q6_tdm_data_format_put),
  6380. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  6381. msm_dai_q6_tdm_data_format_get,
  6382. msm_dai_q6_tdm_data_format_put),
  6383. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  6384. msm_dai_q6_tdm_data_format_get,
  6385. msm_dai_q6_tdm_data_format_put),
  6386. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  6387. msm_dai_q6_tdm_data_format_get,
  6388. msm_dai_q6_tdm_data_format_put),
  6389. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  6390. msm_dai_q6_tdm_data_format_get,
  6391. msm_dai_q6_tdm_data_format_put),
  6392. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  6393. msm_dai_q6_tdm_data_format_get,
  6394. msm_dai_q6_tdm_data_format_put),
  6395. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  6396. msm_dai_q6_tdm_data_format_get,
  6397. msm_dai_q6_tdm_data_format_put),
  6398. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  6399. msm_dai_q6_tdm_data_format_get,
  6400. msm_dai_q6_tdm_data_format_put),
  6401. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  6402. msm_dai_q6_tdm_data_format_get,
  6403. msm_dai_q6_tdm_data_format_put),
  6404. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  6405. msm_dai_q6_tdm_data_format_get,
  6406. msm_dai_q6_tdm_data_format_put),
  6407. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  6408. msm_dai_q6_tdm_data_format_get,
  6409. msm_dai_q6_tdm_data_format_put),
  6410. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  6411. msm_dai_q6_tdm_data_format_get,
  6412. msm_dai_q6_tdm_data_format_put),
  6413. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  6414. msm_dai_q6_tdm_data_format_get,
  6415. msm_dai_q6_tdm_data_format_put),
  6416. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  6417. msm_dai_q6_tdm_data_format_get,
  6418. msm_dai_q6_tdm_data_format_put),
  6419. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  6420. msm_dai_q6_tdm_data_format_get,
  6421. msm_dai_q6_tdm_data_format_put),
  6422. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  6423. msm_dai_q6_tdm_data_format_get,
  6424. msm_dai_q6_tdm_data_format_put),
  6425. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  6426. msm_dai_q6_tdm_data_format_get,
  6427. msm_dai_q6_tdm_data_format_put),
  6428. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  6429. msm_dai_q6_tdm_data_format_get,
  6430. msm_dai_q6_tdm_data_format_put),
  6431. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  6432. msm_dai_q6_tdm_data_format_get,
  6433. msm_dai_q6_tdm_data_format_put),
  6434. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  6435. msm_dai_q6_tdm_data_format_get,
  6436. msm_dai_q6_tdm_data_format_put),
  6437. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  6438. msm_dai_q6_tdm_data_format_get,
  6439. msm_dai_q6_tdm_data_format_put),
  6440. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  6441. msm_dai_q6_tdm_data_format_get,
  6442. msm_dai_q6_tdm_data_format_put),
  6443. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  6444. msm_dai_q6_tdm_data_format_get,
  6445. msm_dai_q6_tdm_data_format_put),
  6446. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  6447. msm_dai_q6_tdm_data_format_get,
  6448. msm_dai_q6_tdm_data_format_put),
  6449. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  6450. msm_dai_q6_tdm_data_format_get,
  6451. msm_dai_q6_tdm_data_format_put),
  6452. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  6453. msm_dai_q6_tdm_data_format_get,
  6454. msm_dai_q6_tdm_data_format_put),
  6455. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  6456. msm_dai_q6_tdm_data_format_get,
  6457. msm_dai_q6_tdm_data_format_put),
  6458. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  6459. msm_dai_q6_tdm_data_format_get,
  6460. msm_dai_q6_tdm_data_format_put),
  6461. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  6462. msm_dai_q6_tdm_data_format_get,
  6463. msm_dai_q6_tdm_data_format_put),
  6464. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  6465. msm_dai_q6_tdm_data_format_get,
  6466. msm_dai_q6_tdm_data_format_put),
  6467. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  6468. msm_dai_q6_tdm_data_format_get,
  6469. msm_dai_q6_tdm_data_format_put),
  6470. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  6471. msm_dai_q6_tdm_data_format_get,
  6472. msm_dai_q6_tdm_data_format_put),
  6473. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  6474. msm_dai_q6_tdm_data_format_get,
  6475. msm_dai_q6_tdm_data_format_put),
  6476. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  6477. msm_dai_q6_tdm_data_format_get,
  6478. msm_dai_q6_tdm_data_format_put),
  6479. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  6480. msm_dai_q6_tdm_data_format_get,
  6481. msm_dai_q6_tdm_data_format_put),
  6482. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  6483. msm_dai_q6_tdm_data_format_get,
  6484. msm_dai_q6_tdm_data_format_put),
  6485. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  6486. msm_dai_q6_tdm_data_format_get,
  6487. msm_dai_q6_tdm_data_format_put),
  6488. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  6489. msm_dai_q6_tdm_data_format_get,
  6490. msm_dai_q6_tdm_data_format_put),
  6491. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  6492. msm_dai_q6_tdm_data_format_get,
  6493. msm_dai_q6_tdm_data_format_put),
  6494. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  6495. msm_dai_q6_tdm_data_format_get,
  6496. msm_dai_q6_tdm_data_format_put),
  6497. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  6498. msm_dai_q6_tdm_data_format_get,
  6499. msm_dai_q6_tdm_data_format_put),
  6500. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  6501. msm_dai_q6_tdm_data_format_get,
  6502. msm_dai_q6_tdm_data_format_put),
  6503. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  6504. msm_dai_q6_tdm_data_format_get,
  6505. msm_dai_q6_tdm_data_format_put),
  6506. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  6507. msm_dai_q6_tdm_data_format_get,
  6508. msm_dai_q6_tdm_data_format_put),
  6509. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  6510. msm_dai_q6_tdm_data_format_get,
  6511. msm_dai_q6_tdm_data_format_put),
  6512. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  6513. msm_dai_q6_tdm_data_format_get,
  6514. msm_dai_q6_tdm_data_format_put),
  6515. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  6516. msm_dai_q6_tdm_data_format_get,
  6517. msm_dai_q6_tdm_data_format_put),
  6518. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  6519. msm_dai_q6_tdm_data_format_get,
  6520. msm_dai_q6_tdm_data_format_put),
  6521. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  6522. msm_dai_q6_tdm_data_format_get,
  6523. msm_dai_q6_tdm_data_format_put),
  6524. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  6525. msm_dai_q6_tdm_data_format_get,
  6526. msm_dai_q6_tdm_data_format_put),
  6527. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  6528. msm_dai_q6_tdm_data_format_get,
  6529. msm_dai_q6_tdm_data_format_put),
  6530. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  6531. msm_dai_q6_tdm_data_format_get,
  6532. msm_dai_q6_tdm_data_format_put),
  6533. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  6534. msm_dai_q6_tdm_data_format_get,
  6535. msm_dai_q6_tdm_data_format_put),
  6536. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  6537. msm_dai_q6_tdm_data_format_get,
  6538. msm_dai_q6_tdm_data_format_put),
  6539. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  6540. msm_dai_q6_tdm_data_format_get,
  6541. msm_dai_q6_tdm_data_format_put),
  6542. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  6543. msm_dai_q6_tdm_data_format_get,
  6544. msm_dai_q6_tdm_data_format_put),
  6545. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  6546. msm_dai_q6_tdm_data_format_get,
  6547. msm_dai_q6_tdm_data_format_put),
  6548. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  6549. msm_dai_q6_tdm_data_format_get,
  6550. msm_dai_q6_tdm_data_format_put),
  6551. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  6552. msm_dai_q6_tdm_data_format_get,
  6553. msm_dai_q6_tdm_data_format_put),
  6554. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  6555. msm_dai_q6_tdm_data_format_get,
  6556. msm_dai_q6_tdm_data_format_put),
  6557. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  6558. msm_dai_q6_tdm_data_format_get,
  6559. msm_dai_q6_tdm_data_format_put),
  6560. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  6561. msm_dai_q6_tdm_data_format_get,
  6562. msm_dai_q6_tdm_data_format_put),
  6563. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  6564. msm_dai_q6_tdm_data_format_get,
  6565. msm_dai_q6_tdm_data_format_put),
  6566. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  6567. msm_dai_q6_tdm_data_format_get,
  6568. msm_dai_q6_tdm_data_format_put),
  6569. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  6570. msm_dai_q6_tdm_data_format_get,
  6571. msm_dai_q6_tdm_data_format_put),
  6572. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  6573. msm_dai_q6_tdm_data_format_get,
  6574. msm_dai_q6_tdm_data_format_put),
  6575. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  6576. msm_dai_q6_tdm_data_format_get,
  6577. msm_dai_q6_tdm_data_format_put),
  6578. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  6579. msm_dai_q6_tdm_data_format_get,
  6580. msm_dai_q6_tdm_data_format_put),
  6581. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  6582. msm_dai_q6_tdm_data_format_get,
  6583. msm_dai_q6_tdm_data_format_put),
  6584. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  6585. msm_dai_q6_tdm_data_format_get,
  6586. msm_dai_q6_tdm_data_format_put),
  6587. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  6588. msm_dai_q6_tdm_data_format_get,
  6589. msm_dai_q6_tdm_data_format_put),
  6590. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  6591. msm_dai_q6_tdm_data_format_get,
  6592. msm_dai_q6_tdm_data_format_put),
  6593. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  6594. msm_dai_q6_tdm_data_format_get,
  6595. msm_dai_q6_tdm_data_format_put),
  6596. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  6597. msm_dai_q6_tdm_data_format_get,
  6598. msm_dai_q6_tdm_data_format_put),
  6599. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  6600. msm_dai_q6_tdm_data_format_get,
  6601. msm_dai_q6_tdm_data_format_put),
  6602. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  6603. msm_dai_q6_tdm_data_format_get,
  6604. msm_dai_q6_tdm_data_format_put),
  6605. SOC_ENUM_EXT("SEN_TDM_RX_0 Data Format", tdm_config_enum[0],
  6606. msm_dai_q6_tdm_data_format_get,
  6607. msm_dai_q6_tdm_data_format_put),
  6608. SOC_ENUM_EXT("SEN_TDM_RX_1 Data Format", tdm_config_enum[0],
  6609. msm_dai_q6_tdm_data_format_get,
  6610. msm_dai_q6_tdm_data_format_put),
  6611. SOC_ENUM_EXT("SEN_TDM_RX_2 Data Format", tdm_config_enum[0],
  6612. msm_dai_q6_tdm_data_format_get,
  6613. msm_dai_q6_tdm_data_format_put),
  6614. SOC_ENUM_EXT("SEN_TDM_RX_3 Data Format", tdm_config_enum[0],
  6615. msm_dai_q6_tdm_data_format_get,
  6616. msm_dai_q6_tdm_data_format_put),
  6617. SOC_ENUM_EXT("SEN_TDM_RX_4 Data Format", tdm_config_enum[0],
  6618. msm_dai_q6_tdm_data_format_get,
  6619. msm_dai_q6_tdm_data_format_put),
  6620. SOC_ENUM_EXT("SEN_TDM_RX_5 Data Format", tdm_config_enum[0],
  6621. msm_dai_q6_tdm_data_format_get,
  6622. msm_dai_q6_tdm_data_format_put),
  6623. SOC_ENUM_EXT("SEN_TDM_RX_6 Data Format", tdm_config_enum[0],
  6624. msm_dai_q6_tdm_data_format_get,
  6625. msm_dai_q6_tdm_data_format_put),
  6626. SOC_ENUM_EXT("SEN_TDM_RX_7 Data Format", tdm_config_enum[0],
  6627. msm_dai_q6_tdm_data_format_get,
  6628. msm_dai_q6_tdm_data_format_put),
  6629. SOC_ENUM_EXT("SEN_TDM_TX_0 Data Format", tdm_config_enum[0],
  6630. msm_dai_q6_tdm_data_format_get,
  6631. msm_dai_q6_tdm_data_format_put),
  6632. SOC_ENUM_EXT("SEN_TDM_TX_1 Data Format", tdm_config_enum[0],
  6633. msm_dai_q6_tdm_data_format_get,
  6634. msm_dai_q6_tdm_data_format_put),
  6635. SOC_ENUM_EXT("SEN_TDM_TX_2 Data Format", tdm_config_enum[0],
  6636. msm_dai_q6_tdm_data_format_get,
  6637. msm_dai_q6_tdm_data_format_put),
  6638. SOC_ENUM_EXT("SEN_TDM_TX_3 Data Format", tdm_config_enum[0],
  6639. msm_dai_q6_tdm_data_format_get,
  6640. msm_dai_q6_tdm_data_format_put),
  6641. SOC_ENUM_EXT("SEN_TDM_TX_4 Data Format", tdm_config_enum[0],
  6642. msm_dai_q6_tdm_data_format_get,
  6643. msm_dai_q6_tdm_data_format_put),
  6644. SOC_ENUM_EXT("SEN_TDM_TX_5 Data Format", tdm_config_enum[0],
  6645. msm_dai_q6_tdm_data_format_get,
  6646. msm_dai_q6_tdm_data_format_put),
  6647. SOC_ENUM_EXT("SEN_TDM_TX_6 Data Format", tdm_config_enum[0],
  6648. msm_dai_q6_tdm_data_format_get,
  6649. msm_dai_q6_tdm_data_format_put),
  6650. SOC_ENUM_EXT("SEN_TDM_TX_7 Data Format", tdm_config_enum[0],
  6651. msm_dai_q6_tdm_data_format_get,
  6652. msm_dai_q6_tdm_data_format_put),
  6653. };
  6654. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  6655. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  6656. msm_dai_q6_tdm_header_type_get,
  6657. msm_dai_q6_tdm_header_type_put),
  6658. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  6659. msm_dai_q6_tdm_header_type_get,
  6660. msm_dai_q6_tdm_header_type_put),
  6661. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  6662. msm_dai_q6_tdm_header_type_get,
  6663. msm_dai_q6_tdm_header_type_put),
  6664. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  6665. msm_dai_q6_tdm_header_type_get,
  6666. msm_dai_q6_tdm_header_type_put),
  6667. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  6668. msm_dai_q6_tdm_header_type_get,
  6669. msm_dai_q6_tdm_header_type_put),
  6670. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  6671. msm_dai_q6_tdm_header_type_get,
  6672. msm_dai_q6_tdm_header_type_put),
  6673. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  6674. msm_dai_q6_tdm_header_type_get,
  6675. msm_dai_q6_tdm_header_type_put),
  6676. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  6677. msm_dai_q6_tdm_header_type_get,
  6678. msm_dai_q6_tdm_header_type_put),
  6679. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  6680. msm_dai_q6_tdm_header_type_get,
  6681. msm_dai_q6_tdm_header_type_put),
  6682. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  6683. msm_dai_q6_tdm_header_type_get,
  6684. msm_dai_q6_tdm_header_type_put),
  6685. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  6686. msm_dai_q6_tdm_header_type_get,
  6687. msm_dai_q6_tdm_header_type_put),
  6688. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  6689. msm_dai_q6_tdm_header_type_get,
  6690. msm_dai_q6_tdm_header_type_put),
  6691. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  6692. msm_dai_q6_tdm_header_type_get,
  6693. msm_dai_q6_tdm_header_type_put),
  6694. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  6695. msm_dai_q6_tdm_header_type_get,
  6696. msm_dai_q6_tdm_header_type_put),
  6697. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  6698. msm_dai_q6_tdm_header_type_get,
  6699. msm_dai_q6_tdm_header_type_put),
  6700. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  6701. msm_dai_q6_tdm_header_type_get,
  6702. msm_dai_q6_tdm_header_type_put),
  6703. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  6704. msm_dai_q6_tdm_header_type_get,
  6705. msm_dai_q6_tdm_header_type_put),
  6706. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  6707. msm_dai_q6_tdm_header_type_get,
  6708. msm_dai_q6_tdm_header_type_put),
  6709. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  6710. msm_dai_q6_tdm_header_type_get,
  6711. msm_dai_q6_tdm_header_type_put),
  6712. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  6713. msm_dai_q6_tdm_header_type_get,
  6714. msm_dai_q6_tdm_header_type_put),
  6715. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  6716. msm_dai_q6_tdm_header_type_get,
  6717. msm_dai_q6_tdm_header_type_put),
  6718. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  6719. msm_dai_q6_tdm_header_type_get,
  6720. msm_dai_q6_tdm_header_type_put),
  6721. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  6722. msm_dai_q6_tdm_header_type_get,
  6723. msm_dai_q6_tdm_header_type_put),
  6724. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  6725. msm_dai_q6_tdm_header_type_get,
  6726. msm_dai_q6_tdm_header_type_put),
  6727. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  6728. msm_dai_q6_tdm_header_type_get,
  6729. msm_dai_q6_tdm_header_type_put),
  6730. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  6731. msm_dai_q6_tdm_header_type_get,
  6732. msm_dai_q6_tdm_header_type_put),
  6733. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  6734. msm_dai_q6_tdm_header_type_get,
  6735. msm_dai_q6_tdm_header_type_put),
  6736. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  6737. msm_dai_q6_tdm_header_type_get,
  6738. msm_dai_q6_tdm_header_type_put),
  6739. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  6740. msm_dai_q6_tdm_header_type_get,
  6741. msm_dai_q6_tdm_header_type_put),
  6742. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  6743. msm_dai_q6_tdm_header_type_get,
  6744. msm_dai_q6_tdm_header_type_put),
  6745. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  6746. msm_dai_q6_tdm_header_type_get,
  6747. msm_dai_q6_tdm_header_type_put),
  6748. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  6749. msm_dai_q6_tdm_header_type_get,
  6750. msm_dai_q6_tdm_header_type_put),
  6751. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  6752. msm_dai_q6_tdm_header_type_get,
  6753. msm_dai_q6_tdm_header_type_put),
  6754. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  6755. msm_dai_q6_tdm_header_type_get,
  6756. msm_dai_q6_tdm_header_type_put),
  6757. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  6758. msm_dai_q6_tdm_header_type_get,
  6759. msm_dai_q6_tdm_header_type_put),
  6760. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  6761. msm_dai_q6_tdm_header_type_get,
  6762. msm_dai_q6_tdm_header_type_put),
  6763. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  6764. msm_dai_q6_tdm_header_type_get,
  6765. msm_dai_q6_tdm_header_type_put),
  6766. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  6767. msm_dai_q6_tdm_header_type_get,
  6768. msm_dai_q6_tdm_header_type_put),
  6769. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  6770. msm_dai_q6_tdm_header_type_get,
  6771. msm_dai_q6_tdm_header_type_put),
  6772. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  6773. msm_dai_q6_tdm_header_type_get,
  6774. msm_dai_q6_tdm_header_type_put),
  6775. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  6776. msm_dai_q6_tdm_header_type_get,
  6777. msm_dai_q6_tdm_header_type_put),
  6778. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  6779. msm_dai_q6_tdm_header_type_get,
  6780. msm_dai_q6_tdm_header_type_put),
  6781. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  6782. msm_dai_q6_tdm_header_type_get,
  6783. msm_dai_q6_tdm_header_type_put),
  6784. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  6785. msm_dai_q6_tdm_header_type_get,
  6786. msm_dai_q6_tdm_header_type_put),
  6787. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  6788. msm_dai_q6_tdm_header_type_get,
  6789. msm_dai_q6_tdm_header_type_put),
  6790. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  6791. msm_dai_q6_tdm_header_type_get,
  6792. msm_dai_q6_tdm_header_type_put),
  6793. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  6794. msm_dai_q6_tdm_header_type_get,
  6795. msm_dai_q6_tdm_header_type_put),
  6796. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  6797. msm_dai_q6_tdm_header_type_get,
  6798. msm_dai_q6_tdm_header_type_put),
  6799. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  6800. msm_dai_q6_tdm_header_type_get,
  6801. msm_dai_q6_tdm_header_type_put),
  6802. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  6803. msm_dai_q6_tdm_header_type_get,
  6804. msm_dai_q6_tdm_header_type_put),
  6805. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  6806. msm_dai_q6_tdm_header_type_get,
  6807. msm_dai_q6_tdm_header_type_put),
  6808. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  6809. msm_dai_q6_tdm_header_type_get,
  6810. msm_dai_q6_tdm_header_type_put),
  6811. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  6812. msm_dai_q6_tdm_header_type_get,
  6813. msm_dai_q6_tdm_header_type_put),
  6814. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  6815. msm_dai_q6_tdm_header_type_get,
  6816. msm_dai_q6_tdm_header_type_put),
  6817. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  6818. msm_dai_q6_tdm_header_type_get,
  6819. msm_dai_q6_tdm_header_type_put),
  6820. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  6821. msm_dai_q6_tdm_header_type_get,
  6822. msm_dai_q6_tdm_header_type_put),
  6823. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  6824. msm_dai_q6_tdm_header_type_get,
  6825. msm_dai_q6_tdm_header_type_put),
  6826. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  6827. msm_dai_q6_tdm_header_type_get,
  6828. msm_dai_q6_tdm_header_type_put),
  6829. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  6830. msm_dai_q6_tdm_header_type_get,
  6831. msm_dai_q6_tdm_header_type_put),
  6832. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  6833. msm_dai_q6_tdm_header_type_get,
  6834. msm_dai_q6_tdm_header_type_put),
  6835. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  6836. msm_dai_q6_tdm_header_type_get,
  6837. msm_dai_q6_tdm_header_type_put),
  6838. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  6839. msm_dai_q6_tdm_header_type_get,
  6840. msm_dai_q6_tdm_header_type_put),
  6841. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  6842. msm_dai_q6_tdm_header_type_get,
  6843. msm_dai_q6_tdm_header_type_put),
  6844. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  6845. msm_dai_q6_tdm_header_type_get,
  6846. msm_dai_q6_tdm_header_type_put),
  6847. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  6848. msm_dai_q6_tdm_header_type_get,
  6849. msm_dai_q6_tdm_header_type_put),
  6850. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  6851. msm_dai_q6_tdm_header_type_get,
  6852. msm_dai_q6_tdm_header_type_put),
  6853. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  6854. msm_dai_q6_tdm_header_type_get,
  6855. msm_dai_q6_tdm_header_type_put),
  6856. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  6857. msm_dai_q6_tdm_header_type_get,
  6858. msm_dai_q6_tdm_header_type_put),
  6859. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  6860. msm_dai_q6_tdm_header_type_get,
  6861. msm_dai_q6_tdm_header_type_put),
  6862. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  6863. msm_dai_q6_tdm_header_type_get,
  6864. msm_dai_q6_tdm_header_type_put),
  6865. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  6866. msm_dai_q6_tdm_header_type_get,
  6867. msm_dai_q6_tdm_header_type_put),
  6868. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  6869. msm_dai_q6_tdm_header_type_get,
  6870. msm_dai_q6_tdm_header_type_put),
  6871. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  6872. msm_dai_q6_tdm_header_type_get,
  6873. msm_dai_q6_tdm_header_type_put),
  6874. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  6875. msm_dai_q6_tdm_header_type_get,
  6876. msm_dai_q6_tdm_header_type_put),
  6877. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  6878. msm_dai_q6_tdm_header_type_get,
  6879. msm_dai_q6_tdm_header_type_put),
  6880. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  6881. msm_dai_q6_tdm_header_type_get,
  6882. msm_dai_q6_tdm_header_type_put),
  6883. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  6884. msm_dai_q6_tdm_header_type_get,
  6885. msm_dai_q6_tdm_header_type_put),
  6886. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  6887. msm_dai_q6_tdm_header_type_get,
  6888. msm_dai_q6_tdm_header_type_put),
  6889. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  6890. msm_dai_q6_tdm_header_type_get,
  6891. msm_dai_q6_tdm_header_type_put),
  6892. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  6893. msm_dai_q6_tdm_header_type_get,
  6894. msm_dai_q6_tdm_header_type_put),
  6895. SOC_ENUM_EXT("SEN_TDM_RX_0 Header Type", tdm_config_enum[1],
  6896. msm_dai_q6_tdm_header_type_get,
  6897. msm_dai_q6_tdm_header_type_put),
  6898. SOC_ENUM_EXT("SEN_TDM_RX_1 Header Type", tdm_config_enum[1],
  6899. msm_dai_q6_tdm_header_type_get,
  6900. msm_dai_q6_tdm_header_type_put),
  6901. SOC_ENUM_EXT("SEN_TDM_RX_2 Header Type", tdm_config_enum[1],
  6902. msm_dai_q6_tdm_header_type_get,
  6903. msm_dai_q6_tdm_header_type_put),
  6904. SOC_ENUM_EXT("SEN_TDM_RX_3 Header Type", tdm_config_enum[1],
  6905. msm_dai_q6_tdm_header_type_get,
  6906. msm_dai_q6_tdm_header_type_put),
  6907. SOC_ENUM_EXT("SEN_TDM_RX_4 Header Type", tdm_config_enum[1],
  6908. msm_dai_q6_tdm_header_type_get,
  6909. msm_dai_q6_tdm_header_type_put),
  6910. SOC_ENUM_EXT("SEN_TDM_RX_5 Header Type", tdm_config_enum[1],
  6911. msm_dai_q6_tdm_header_type_get,
  6912. msm_dai_q6_tdm_header_type_put),
  6913. SOC_ENUM_EXT("SEN_TDM_RX_6 Header Type", tdm_config_enum[1],
  6914. msm_dai_q6_tdm_header_type_get,
  6915. msm_dai_q6_tdm_header_type_put),
  6916. SOC_ENUM_EXT("SEN_TDM_RX_7 Header Type", tdm_config_enum[1],
  6917. msm_dai_q6_tdm_header_type_get,
  6918. msm_dai_q6_tdm_header_type_put),
  6919. SOC_ENUM_EXT("SEN_TDM_TX_0 Header Type", tdm_config_enum[1],
  6920. msm_dai_q6_tdm_header_type_get,
  6921. msm_dai_q6_tdm_header_type_put),
  6922. SOC_ENUM_EXT("SEN_TDM_TX_1 Header Type", tdm_config_enum[1],
  6923. msm_dai_q6_tdm_header_type_get,
  6924. msm_dai_q6_tdm_header_type_put),
  6925. SOC_ENUM_EXT("SEN_TDM_TX_2 Header Type", tdm_config_enum[1],
  6926. msm_dai_q6_tdm_header_type_get,
  6927. msm_dai_q6_tdm_header_type_put),
  6928. SOC_ENUM_EXT("SEN_TDM_TX_3 Header Type", tdm_config_enum[1],
  6929. msm_dai_q6_tdm_header_type_get,
  6930. msm_dai_q6_tdm_header_type_put),
  6931. SOC_ENUM_EXT("SEN_TDM_TX_4 Header Type", tdm_config_enum[1],
  6932. msm_dai_q6_tdm_header_type_get,
  6933. msm_dai_q6_tdm_header_type_put),
  6934. SOC_ENUM_EXT("SEN_TDM_TX_5 Header Type", tdm_config_enum[1],
  6935. msm_dai_q6_tdm_header_type_get,
  6936. msm_dai_q6_tdm_header_type_put),
  6937. SOC_ENUM_EXT("SEN_TDM_TX_6 Header Type", tdm_config_enum[1],
  6938. msm_dai_q6_tdm_header_type_get,
  6939. msm_dai_q6_tdm_header_type_put),
  6940. SOC_ENUM_EXT("SEN_TDM_TX_7 Header Type", tdm_config_enum[1],
  6941. msm_dai_q6_tdm_header_type_get,
  6942. msm_dai_q6_tdm_header_type_put),
  6943. };
  6944. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  6945. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  6946. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6947. msm_dai_q6_tdm_header_get,
  6948. msm_dai_q6_tdm_header_put),
  6949. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  6950. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6951. msm_dai_q6_tdm_header_get,
  6952. msm_dai_q6_tdm_header_put),
  6953. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  6954. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6955. msm_dai_q6_tdm_header_get,
  6956. msm_dai_q6_tdm_header_put),
  6957. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  6958. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6959. msm_dai_q6_tdm_header_get,
  6960. msm_dai_q6_tdm_header_put),
  6961. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  6962. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6963. msm_dai_q6_tdm_header_get,
  6964. msm_dai_q6_tdm_header_put),
  6965. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 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_6 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_7 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_TX_0 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_TX_1 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_TX_2 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_TX_3 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_TX_4 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_5 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_6 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_7 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("SEC_TDM_RX_0 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("SEC_TDM_RX_1 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("SEC_TDM_RX_2 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("SEC_TDM_RX_3 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("SEC_TDM_RX_4 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_5 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_6 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_7 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_TX_0 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_TX_1 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_TX_2 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_TX_3 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_TX_4 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_5 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_6 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_7 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("TERT_TDM_RX_0 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("TERT_TDM_RX_1 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("TERT_TDM_RX_2 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("TERT_TDM_RX_3 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("TERT_TDM_RX_4 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_5 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_6 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_7 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_TX_0 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_TX_1 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_TX_2 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_TX_3 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_TX_4 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_5 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_6 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_7 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("QUAT_TDM_RX_0 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("QUAT_TDM_RX_1 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("QUAT_TDM_RX_2 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("QUAT_TDM_RX_3 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("QUAT_TDM_RX_4 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_5 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_6 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_7 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_TX_0 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_TX_1 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_TX_2 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_TX_3 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_TX_4 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_5 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_6 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_7 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("QUIN_TDM_RX_0 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("QUIN_TDM_RX_1 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("QUIN_TDM_RX_2 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("QUIN_TDM_RX_3 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("QUIN_TDM_RX_4 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_5 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_6 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_7 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_TX_0 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_TX_1 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_TX_2 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_TX_3 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_TX_4 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_5 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_6 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_7 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("SEN_TDM_RX_0 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("SEN_TDM_RX_1 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("SEN_TDM_RX_2 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("SEN_TDM_RX_3 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("SEN_TDM_RX_4 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_5 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_6 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_7 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_TX_0 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_TX_1 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_TX_2 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_TX_3 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_TX_4 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_5 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_6 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_7 Header",
  7326. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7327. msm_dai_q6_tdm_header_get,
  7328. msm_dai_q6_tdm_header_put),
  7329. };
  7330. static int msm_dai_q6_tdm_set_clk(
  7331. struct msm_dai_q6_tdm_dai_data *dai_data,
  7332. u16 port_id, bool enable)
  7333. {
  7334. int rc = 0;
  7335. dai_data->clk_set.enable = enable;
  7336. rc = afe_set_lpass_clock_v2(port_id,
  7337. &dai_data->clk_set);
  7338. if (rc < 0)
  7339. pr_err("%s: afe lpass clock failed, err:%d\n",
  7340. __func__, rc);
  7341. return rc;
  7342. }
  7343. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  7344. {
  7345. int rc = 0;
  7346. struct msm_dai_q6_tdm_dai_data *tdm_dai_data = NULL;
  7347. struct snd_kcontrol *data_format_kcontrol = NULL;
  7348. struct snd_kcontrol *header_type_kcontrol = NULL;
  7349. struct snd_kcontrol *header_kcontrol = NULL;
  7350. int port_idx = 0;
  7351. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  7352. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  7353. const struct snd_kcontrol_new *header_ctrl = NULL;
  7354. tdm_dai_data = dev_get_drvdata(dai->dev);
  7355. msm_dai_q6_set_dai_id(dai);
  7356. port_idx = msm_dai_q6_get_port_idx(dai->id);
  7357. if (port_idx < 0) {
  7358. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  7359. __func__, dai->id);
  7360. rc = -EINVAL;
  7361. goto rtn;
  7362. }
  7363. data_format_ctrl =
  7364. &tdm_config_controls_data_format[port_idx];
  7365. header_type_ctrl =
  7366. &tdm_config_controls_header_type[port_idx];
  7367. header_ctrl =
  7368. &tdm_config_controls_header[port_idx];
  7369. if (data_format_ctrl) {
  7370. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  7371. tdm_dai_data);
  7372. rc = snd_ctl_add(dai->component->card->snd_card,
  7373. data_format_kcontrol);
  7374. if (rc < 0) {
  7375. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  7376. __func__, dai->name);
  7377. goto rtn;
  7378. }
  7379. }
  7380. if (header_type_ctrl) {
  7381. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  7382. tdm_dai_data);
  7383. rc = snd_ctl_add(dai->component->card->snd_card,
  7384. header_type_kcontrol);
  7385. if (rc < 0) {
  7386. if (data_format_kcontrol)
  7387. snd_ctl_remove(dai->component->card->snd_card,
  7388. data_format_kcontrol);
  7389. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  7390. __func__, dai->name);
  7391. goto rtn;
  7392. }
  7393. }
  7394. if (header_ctrl) {
  7395. header_kcontrol = snd_ctl_new1(header_ctrl,
  7396. tdm_dai_data);
  7397. rc = snd_ctl_add(dai->component->card->snd_card,
  7398. header_kcontrol);
  7399. if (rc < 0) {
  7400. if (header_type_kcontrol)
  7401. snd_ctl_remove(dai->component->card->snd_card,
  7402. header_type_kcontrol);
  7403. if (data_format_kcontrol)
  7404. snd_ctl_remove(dai->component->card->snd_card,
  7405. data_format_kcontrol);
  7406. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  7407. __func__, dai->name);
  7408. goto rtn;
  7409. }
  7410. }
  7411. if (tdm_dai_data->is_island_dai)
  7412. rc = msm_dai_q6_add_island_mx_ctls(
  7413. dai->component->card->snd_card,
  7414. dai->name,
  7415. dai->id, (void *)tdm_dai_data);
  7416. rc = msm_dai_q6_dai_add_route(dai);
  7417. rtn:
  7418. return rc;
  7419. }
  7420. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  7421. {
  7422. int rc = 0;
  7423. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  7424. dev_get_drvdata(dai->dev);
  7425. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  7426. int group_idx = 0;
  7427. atomic_t *group_ref = NULL;
  7428. group_idx = msm_dai_q6_get_group_idx(dai->id);
  7429. if (group_idx < 0) {
  7430. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  7431. __func__, dai->id);
  7432. return -EINVAL;
  7433. }
  7434. group_ref = &tdm_group_ref[group_idx];
  7435. /* If AFE port is still up, close it */
  7436. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  7437. rc = afe_close(dai->id); /* can block */
  7438. if (rc < 0) {
  7439. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  7440. __func__, dai->id);
  7441. }
  7442. atomic_dec(group_ref);
  7443. clear_bit(STATUS_PORT_STARTED,
  7444. tdm_dai_data->status_mask);
  7445. if (atomic_read(group_ref) == 0) {
  7446. rc = afe_port_group_enable(group_id,
  7447. NULL, false, NULL);
  7448. if (rc < 0) {
  7449. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  7450. group_id);
  7451. }
  7452. }
  7453. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  7454. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  7455. dai->id, false);
  7456. if (rc < 0) {
  7457. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  7458. __func__, dai->id);
  7459. }
  7460. }
  7461. }
  7462. return 0;
  7463. }
  7464. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  7465. unsigned int tx_mask,
  7466. unsigned int rx_mask,
  7467. int slots, int slot_width)
  7468. {
  7469. int rc = 0;
  7470. struct msm_dai_q6_tdm_dai_data *dai_data =
  7471. dev_get_drvdata(dai->dev);
  7472. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  7473. &dai_data->group_cfg.tdm_cfg;
  7474. unsigned int cap_mask;
  7475. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  7476. /* HW only supports 16 and 32 bit slot width configuration */
  7477. if ((slot_width != 16) && (slot_width != 32)) {
  7478. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  7479. __func__, slot_width);
  7480. return -EINVAL;
  7481. }
  7482. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  7483. switch (slots) {
  7484. case 1:
  7485. cap_mask = 0x01;
  7486. break;
  7487. case 2:
  7488. cap_mask = 0x03;
  7489. break;
  7490. case 4:
  7491. cap_mask = 0x0F;
  7492. break;
  7493. case 8:
  7494. cap_mask = 0xFF;
  7495. break;
  7496. case 16:
  7497. cap_mask = 0xFFFF;
  7498. break;
  7499. default:
  7500. dev_err(dai->dev, "%s: invalid slots %d\n",
  7501. __func__, slots);
  7502. return -EINVAL;
  7503. }
  7504. switch (dai->id) {
  7505. case AFE_PORT_ID_PRIMARY_TDM_RX:
  7506. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  7507. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  7508. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  7509. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  7510. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  7511. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  7512. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  7513. case AFE_PORT_ID_SECONDARY_TDM_RX:
  7514. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  7515. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  7516. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  7517. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  7518. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  7519. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  7520. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  7521. case AFE_PORT_ID_TERTIARY_TDM_RX:
  7522. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  7523. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  7524. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  7525. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  7526. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  7527. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  7528. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  7529. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  7530. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  7531. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  7532. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  7533. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  7534. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  7535. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  7536. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  7537. case AFE_PORT_ID_QUINARY_TDM_RX:
  7538. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  7539. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  7540. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  7541. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  7542. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  7543. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  7544. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  7545. case AFE_PORT_ID_SENARY_TDM_RX:
  7546. case AFE_PORT_ID_SENARY_TDM_RX_1:
  7547. case AFE_PORT_ID_SENARY_TDM_RX_2:
  7548. case AFE_PORT_ID_SENARY_TDM_RX_3:
  7549. case AFE_PORT_ID_SENARY_TDM_RX_4:
  7550. case AFE_PORT_ID_SENARY_TDM_RX_5:
  7551. case AFE_PORT_ID_SENARY_TDM_RX_6:
  7552. case AFE_PORT_ID_SENARY_TDM_RX_7:
  7553. tdm_group->nslots_per_frame = slots;
  7554. tdm_group->slot_width = slot_width;
  7555. tdm_group->slot_mask = rx_mask & cap_mask;
  7556. break;
  7557. case AFE_PORT_ID_PRIMARY_TDM_TX:
  7558. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  7559. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  7560. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  7561. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  7562. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  7563. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  7564. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  7565. case AFE_PORT_ID_SECONDARY_TDM_TX:
  7566. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  7567. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  7568. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  7569. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  7570. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  7571. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  7572. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  7573. case AFE_PORT_ID_TERTIARY_TDM_TX:
  7574. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  7575. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  7576. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  7577. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  7578. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  7579. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  7580. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  7581. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  7582. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  7583. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  7584. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  7585. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  7586. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  7587. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  7588. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  7589. case AFE_PORT_ID_QUINARY_TDM_TX:
  7590. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  7591. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  7592. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  7593. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  7594. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  7595. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  7596. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  7597. case AFE_PORT_ID_SENARY_TDM_TX:
  7598. case AFE_PORT_ID_SENARY_TDM_TX_1:
  7599. case AFE_PORT_ID_SENARY_TDM_TX_2:
  7600. case AFE_PORT_ID_SENARY_TDM_TX_3:
  7601. case AFE_PORT_ID_SENARY_TDM_TX_4:
  7602. case AFE_PORT_ID_SENARY_TDM_TX_5:
  7603. case AFE_PORT_ID_SENARY_TDM_TX_6:
  7604. case AFE_PORT_ID_SENARY_TDM_TX_7:
  7605. tdm_group->nslots_per_frame = slots;
  7606. tdm_group->slot_width = slot_width;
  7607. tdm_group->slot_mask = tx_mask & cap_mask;
  7608. break;
  7609. default:
  7610. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  7611. __func__, dai->id);
  7612. return -EINVAL;
  7613. }
  7614. return rc;
  7615. }
  7616. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  7617. int clk_id, unsigned int freq, int dir)
  7618. {
  7619. struct msm_dai_q6_tdm_dai_data *dai_data =
  7620. dev_get_drvdata(dai->dev);
  7621. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  7622. (dai->id <= AFE_PORT_ID_SENARY_TDM_TX_7)) {
  7623. dai_data->clk_set.clk_freq_in_hz = freq;
  7624. } else {
  7625. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  7626. __func__, dai->id);
  7627. return -EINVAL;
  7628. }
  7629. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  7630. __func__, dai->id, freq);
  7631. return 0;
  7632. }
  7633. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  7634. unsigned int tx_num, unsigned int *tx_slot,
  7635. unsigned int rx_num, unsigned int *rx_slot)
  7636. {
  7637. int rc = 0;
  7638. struct msm_dai_q6_tdm_dai_data *dai_data =
  7639. dev_get_drvdata(dai->dev);
  7640. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  7641. &dai_data->port_cfg.slot_mapping;
  7642. int i = 0;
  7643. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  7644. switch (dai->id) {
  7645. case AFE_PORT_ID_PRIMARY_TDM_RX:
  7646. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  7647. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  7648. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  7649. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  7650. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  7651. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  7652. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  7653. case AFE_PORT_ID_SECONDARY_TDM_RX:
  7654. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  7655. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  7656. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  7657. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  7658. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  7659. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  7660. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  7661. case AFE_PORT_ID_TERTIARY_TDM_RX:
  7662. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  7663. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  7664. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  7665. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  7666. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  7667. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  7668. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  7669. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  7670. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  7671. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  7672. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  7673. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  7674. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  7675. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  7676. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  7677. case AFE_PORT_ID_QUINARY_TDM_RX:
  7678. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  7679. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  7680. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  7681. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  7682. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  7683. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  7684. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  7685. case AFE_PORT_ID_SENARY_TDM_RX:
  7686. case AFE_PORT_ID_SENARY_TDM_RX_1:
  7687. case AFE_PORT_ID_SENARY_TDM_RX_2:
  7688. case AFE_PORT_ID_SENARY_TDM_RX_3:
  7689. case AFE_PORT_ID_SENARY_TDM_RX_4:
  7690. case AFE_PORT_ID_SENARY_TDM_RX_5:
  7691. case AFE_PORT_ID_SENARY_TDM_RX_6:
  7692. case AFE_PORT_ID_SENARY_TDM_RX_7:
  7693. if (!rx_slot) {
  7694. dev_err(dai->dev, "%s: rx slot not found\n", __func__);
  7695. return -EINVAL;
  7696. }
  7697. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  7698. dev_err(dai->dev, "%s: invalid rx num %d\n", __func__,
  7699. rx_num);
  7700. return -EINVAL;
  7701. }
  7702. for (i = 0; i < rx_num; i++)
  7703. slot_mapping->offset[i] = rx_slot[i];
  7704. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  7705. slot_mapping->offset[i] =
  7706. AFE_SLOT_MAPPING_OFFSET_INVALID;
  7707. slot_mapping->num_channel = rx_num;
  7708. break;
  7709. case AFE_PORT_ID_PRIMARY_TDM_TX:
  7710. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  7711. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  7712. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  7713. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  7714. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  7715. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  7716. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  7717. case AFE_PORT_ID_SECONDARY_TDM_TX:
  7718. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  7719. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  7720. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  7721. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  7722. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  7723. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  7724. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  7725. case AFE_PORT_ID_TERTIARY_TDM_TX:
  7726. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  7727. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  7728. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  7729. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  7730. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  7731. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  7732. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  7733. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  7734. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  7735. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  7736. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  7737. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  7738. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  7739. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  7740. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  7741. case AFE_PORT_ID_QUINARY_TDM_TX:
  7742. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  7743. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  7744. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  7745. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  7746. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  7747. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  7748. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  7749. case AFE_PORT_ID_SENARY_TDM_TX:
  7750. case AFE_PORT_ID_SENARY_TDM_TX_1:
  7751. case AFE_PORT_ID_SENARY_TDM_TX_2:
  7752. case AFE_PORT_ID_SENARY_TDM_TX_3:
  7753. case AFE_PORT_ID_SENARY_TDM_TX_4:
  7754. case AFE_PORT_ID_SENARY_TDM_TX_5:
  7755. case AFE_PORT_ID_SENARY_TDM_TX_6:
  7756. case AFE_PORT_ID_SENARY_TDM_TX_7:
  7757. if (!tx_slot) {
  7758. dev_err(dai->dev, "%s: tx slot not found\n", __func__);
  7759. return -EINVAL;
  7760. }
  7761. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  7762. dev_err(dai->dev, "%s: invalid tx num %d\n", __func__,
  7763. tx_num);
  7764. return -EINVAL;
  7765. }
  7766. for (i = 0; i < tx_num; i++)
  7767. slot_mapping->offset[i] = tx_slot[i];
  7768. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  7769. slot_mapping->offset[i] =
  7770. AFE_SLOT_MAPPING_OFFSET_INVALID;
  7771. slot_mapping->num_channel = tx_num;
  7772. break;
  7773. default:
  7774. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  7775. __func__, dai->id);
  7776. return -EINVAL;
  7777. }
  7778. return rc;
  7779. }
  7780. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  7781. struct snd_pcm_hw_params *params,
  7782. struct snd_soc_dai *dai)
  7783. {
  7784. struct msm_dai_q6_tdm_dai_data *dai_data =
  7785. dev_get_drvdata(dai->dev);
  7786. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  7787. &dai_data->group_cfg.tdm_cfg;
  7788. struct afe_param_id_tdm_cfg *tdm =
  7789. &dai_data->port_cfg.tdm;
  7790. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  7791. &dai_data->port_cfg.slot_mapping;
  7792. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  7793. &dai_data->port_cfg.custom_tdm_header;
  7794. pr_debug("%s: dev_name: %s\n",
  7795. __func__, dev_name(dai->dev));
  7796. if ((params_channels(params) == 0) ||
  7797. (params_channels(params) > 8)) {
  7798. dev_err(dai->dev, "%s: invalid param channels %d\n",
  7799. __func__, params_channels(params));
  7800. return -EINVAL;
  7801. }
  7802. switch (params_format(params)) {
  7803. case SNDRV_PCM_FORMAT_S16_LE:
  7804. dai_data->bitwidth = 16;
  7805. break;
  7806. case SNDRV_PCM_FORMAT_S24_LE:
  7807. case SNDRV_PCM_FORMAT_S24_3LE:
  7808. dai_data->bitwidth = 24;
  7809. break;
  7810. case SNDRV_PCM_FORMAT_S32_LE:
  7811. dai_data->bitwidth = 32;
  7812. break;
  7813. default:
  7814. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  7815. __func__, params_format(params));
  7816. return -EINVAL;
  7817. }
  7818. dai_data->channels = params_channels(params);
  7819. dai_data->rate = params_rate(params);
  7820. /*
  7821. * update tdm group config param
  7822. * NOTE: group config is set to the same as slot config.
  7823. */
  7824. tdm_group->bit_width = tdm_group->slot_width;
  7825. /*
  7826. * for multi lane scenario
  7827. * Total number of active channels = number of active lanes * number of active slots.
  7828. */
  7829. if (dai_data->lane_cfg.lane_mask != AFE_LANE_MASK_INVALID)
  7830. tdm_group->num_channels = tdm_group->nslots_per_frame
  7831. * num_of_bits_set(dai_data->lane_cfg.lane_mask);
  7832. else
  7833. tdm_group->num_channels = tdm_group->nslots_per_frame;
  7834. tdm_group->sample_rate = dai_data->rate;
  7835. pr_debug("%s: TDM GROUP:\n"
  7836. "num_channels=%d sample_rate=%d bit_width=%d\n"
  7837. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  7838. __func__,
  7839. tdm_group->num_channels,
  7840. tdm_group->sample_rate,
  7841. tdm_group->bit_width,
  7842. tdm_group->nslots_per_frame,
  7843. tdm_group->slot_width,
  7844. tdm_group->slot_mask);
  7845. pr_debug("%s: TDM GROUP:\n"
  7846. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  7847. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  7848. __func__,
  7849. tdm_group->port_id[0],
  7850. tdm_group->port_id[1],
  7851. tdm_group->port_id[2],
  7852. tdm_group->port_id[3],
  7853. tdm_group->port_id[4],
  7854. tdm_group->port_id[5],
  7855. tdm_group->port_id[6],
  7856. tdm_group->port_id[7]);
  7857. pr_debug("%s: TDM GROUP ID 0x%x lane mask 0x%x:\n",
  7858. __func__,
  7859. tdm_group->group_id,
  7860. dai_data->lane_cfg.lane_mask);
  7861. /*
  7862. * update tdm config param
  7863. * NOTE: channels/rate/bitwidth are per stream property
  7864. */
  7865. tdm->num_channels = dai_data->channels;
  7866. tdm->sample_rate = dai_data->rate;
  7867. tdm->bit_width = dai_data->bitwidth;
  7868. /*
  7869. * port slot config is the same as group slot config
  7870. * port slot mask should be set according to offset
  7871. */
  7872. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  7873. tdm->slot_width = tdm_group->slot_width;
  7874. tdm->slot_mask = tdm_group->slot_mask;
  7875. pr_debug("%s: TDM:\n"
  7876. "num_channels=%d sample_rate=%d bit_width=%d\n"
  7877. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  7878. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  7879. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  7880. __func__,
  7881. tdm->num_channels,
  7882. tdm->sample_rate,
  7883. tdm->bit_width,
  7884. tdm->nslots_per_frame,
  7885. tdm->slot_width,
  7886. tdm->slot_mask,
  7887. tdm->data_format,
  7888. tdm->sync_mode,
  7889. tdm->sync_src,
  7890. tdm->ctrl_data_out_enable,
  7891. tdm->ctrl_invert_sync_pulse,
  7892. tdm->ctrl_sync_data_delay);
  7893. /*
  7894. * update slot mapping config param
  7895. * NOTE: channels/rate/bitwidth are per stream property
  7896. */
  7897. slot_mapping->bitwidth = dai_data->bitwidth;
  7898. pr_debug("%s: SLOT MAPPING:\n"
  7899. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  7900. __func__,
  7901. slot_mapping->num_channel,
  7902. slot_mapping->bitwidth,
  7903. slot_mapping->data_align_type);
  7904. pr_debug("%s: SLOT MAPPING:\n"
  7905. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  7906. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  7907. __func__,
  7908. slot_mapping->offset[0],
  7909. slot_mapping->offset[1],
  7910. slot_mapping->offset[2],
  7911. slot_mapping->offset[3],
  7912. slot_mapping->offset[4],
  7913. slot_mapping->offset[5],
  7914. slot_mapping->offset[6],
  7915. slot_mapping->offset[7]);
  7916. /*
  7917. * update custom header config param
  7918. * NOTE: channels/rate/bitwidth are per playback stream property.
  7919. * custom tdm header only applicable to playback stream.
  7920. */
  7921. if (custom_tdm_header->header_type !=
  7922. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  7923. pr_debug("%s: CUSTOM TDM HEADER:\n"
  7924. "start_offset=0x%x header_width=%d\n"
  7925. "num_frame_repeat=%d header_type=0x%x\n",
  7926. __func__,
  7927. custom_tdm_header->start_offset,
  7928. custom_tdm_header->header_width,
  7929. custom_tdm_header->num_frame_repeat,
  7930. custom_tdm_header->header_type);
  7931. pr_debug("%s: CUSTOM TDM HEADER:\n"
  7932. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  7933. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  7934. __func__,
  7935. custom_tdm_header->header[0],
  7936. custom_tdm_header->header[1],
  7937. custom_tdm_header->header[2],
  7938. custom_tdm_header->header[3],
  7939. custom_tdm_header->header[4],
  7940. custom_tdm_header->header[5],
  7941. custom_tdm_header->header[6],
  7942. custom_tdm_header->header[7]);
  7943. }
  7944. return 0;
  7945. }
  7946. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  7947. struct snd_soc_dai *dai)
  7948. {
  7949. int rc = 0;
  7950. struct msm_dai_q6_tdm_dai_data *dai_data =
  7951. dev_get_drvdata(dai->dev);
  7952. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  7953. int group_idx = 0;
  7954. atomic_t *group_ref = NULL;
  7955. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  7956. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  7957. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  7958. dev_dbg(dai->dev,
  7959. "%s: Custom tdm header not supported\n", __func__);
  7960. group_idx = msm_dai_q6_get_group_idx(dai->id);
  7961. if (group_idx < 0) {
  7962. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  7963. __func__, dai->id);
  7964. return -EINVAL;
  7965. }
  7966. mutex_lock(&tdm_mutex);
  7967. group_ref = &tdm_group_ref[group_idx];
  7968. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  7969. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  7970. /* TX and RX share the same clk. So enable the clk
  7971. * per TDM interface. */
  7972. rc = msm_dai_q6_tdm_set_clk(dai_data,
  7973. dai->id, true);
  7974. if (rc < 0) {
  7975. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  7976. __func__, dai->id);
  7977. goto rtn;
  7978. }
  7979. }
  7980. /* PORT START should be set if prepare called
  7981. * in active state.
  7982. */
  7983. if (atomic_read(group_ref) == 0) {
  7984. /*
  7985. * if only one port, don't do group enable as there
  7986. * is no group need for only one port
  7987. */
  7988. if (dai_data->num_group_ports > 1) {
  7989. rc = afe_port_group_enable(group_id,
  7990. &dai_data->group_cfg, true,
  7991. &dai_data->lane_cfg);
  7992. if (rc < 0) {
  7993. dev_err(dai->dev,
  7994. "%s: fail to enable AFE group 0x%x\n",
  7995. __func__, group_id);
  7996. goto rtn;
  7997. }
  7998. }
  7999. }
  8000. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  8001. dai_data->rate, dai_data->num_group_ports);
  8002. if (rc < 0) {
  8003. if (atomic_read(group_ref) == 0) {
  8004. afe_port_group_enable(group_id,
  8005. NULL, false, NULL);
  8006. }
  8007. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8008. msm_dai_q6_tdm_set_clk(dai_data,
  8009. dai->id, false);
  8010. }
  8011. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  8012. __func__, dai->id);
  8013. } else {
  8014. set_bit(STATUS_PORT_STARTED,
  8015. dai_data->status_mask);
  8016. atomic_inc(group_ref);
  8017. }
  8018. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  8019. /* NOTE: AFE should error out if HW resource contention */
  8020. }
  8021. rtn:
  8022. mutex_unlock(&tdm_mutex);
  8023. return rc;
  8024. }
  8025. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  8026. struct snd_soc_dai *dai)
  8027. {
  8028. int rc = 0;
  8029. struct msm_dai_q6_tdm_dai_data *dai_data =
  8030. dev_get_drvdata(dai->dev);
  8031. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  8032. int group_idx = 0;
  8033. atomic_t *group_ref = NULL;
  8034. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8035. if (group_idx < 0) {
  8036. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8037. __func__, dai->id);
  8038. return;
  8039. }
  8040. mutex_lock(&tdm_mutex);
  8041. group_ref = &tdm_group_ref[group_idx];
  8042. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8043. rc = afe_close(dai->id);
  8044. if (rc < 0) {
  8045. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8046. __func__, dai->id);
  8047. }
  8048. atomic_dec(group_ref);
  8049. clear_bit(STATUS_PORT_STARTED,
  8050. dai_data->status_mask);
  8051. if (atomic_read(group_ref) == 0) {
  8052. rc = afe_port_group_enable(group_id,
  8053. NULL, false, NULL);
  8054. if (rc < 0) {
  8055. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  8056. __func__, group_id);
  8057. }
  8058. }
  8059. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8060. rc = msm_dai_q6_tdm_set_clk(dai_data,
  8061. dai->id, false);
  8062. if (rc < 0) {
  8063. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  8064. __func__, dai->id);
  8065. }
  8066. }
  8067. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  8068. /* NOTE: AFE should error out if HW resource contention */
  8069. }
  8070. mutex_unlock(&tdm_mutex);
  8071. }
  8072. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  8073. .prepare = msm_dai_q6_tdm_prepare,
  8074. .hw_params = msm_dai_q6_tdm_hw_params,
  8075. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  8076. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  8077. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  8078. .shutdown = msm_dai_q6_tdm_shutdown,
  8079. };
  8080. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  8081. {
  8082. .playback = {
  8083. .stream_name = "Primary TDM0 Playback",
  8084. .aif_name = "PRI_TDM_RX_0",
  8085. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8086. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8087. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8088. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8089. SNDRV_PCM_FMTBIT_S24_LE |
  8090. SNDRV_PCM_FMTBIT_S32_LE,
  8091. .channels_min = 1,
  8092. .channels_max = 8,
  8093. .rate_min = 8000,
  8094. .rate_max = 352800,
  8095. },
  8096. .name = "PRI_TDM_RX_0",
  8097. .ops = &msm_dai_q6_tdm_ops,
  8098. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  8099. .probe = msm_dai_q6_dai_tdm_probe,
  8100. .remove = msm_dai_q6_dai_tdm_remove,
  8101. },
  8102. {
  8103. .playback = {
  8104. .stream_name = "Primary TDM1 Playback",
  8105. .aif_name = "PRI_TDM_RX_1",
  8106. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8107. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8108. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8109. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8110. SNDRV_PCM_FMTBIT_S24_LE |
  8111. SNDRV_PCM_FMTBIT_S32_LE,
  8112. .channels_min = 1,
  8113. .channels_max = 8,
  8114. .rate_min = 8000,
  8115. .rate_max = 352800,
  8116. },
  8117. .name = "PRI_TDM_RX_1",
  8118. .ops = &msm_dai_q6_tdm_ops,
  8119. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  8120. .probe = msm_dai_q6_dai_tdm_probe,
  8121. .remove = msm_dai_q6_dai_tdm_remove,
  8122. },
  8123. {
  8124. .playback = {
  8125. .stream_name = "Primary TDM2 Playback",
  8126. .aif_name = "PRI_TDM_RX_2",
  8127. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8128. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8129. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8130. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8131. SNDRV_PCM_FMTBIT_S24_LE |
  8132. SNDRV_PCM_FMTBIT_S32_LE,
  8133. .channels_min = 1,
  8134. .channels_max = 8,
  8135. .rate_min = 8000,
  8136. .rate_max = 352800,
  8137. },
  8138. .name = "PRI_TDM_RX_2",
  8139. .ops = &msm_dai_q6_tdm_ops,
  8140. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  8141. .probe = msm_dai_q6_dai_tdm_probe,
  8142. .remove = msm_dai_q6_dai_tdm_remove,
  8143. },
  8144. {
  8145. .playback = {
  8146. .stream_name = "Primary TDM3 Playback",
  8147. .aif_name = "PRI_TDM_RX_3",
  8148. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8149. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8150. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8151. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8152. SNDRV_PCM_FMTBIT_S24_LE |
  8153. SNDRV_PCM_FMTBIT_S32_LE,
  8154. .channels_min = 1,
  8155. .channels_max = 8,
  8156. .rate_min = 8000,
  8157. .rate_max = 352800,
  8158. },
  8159. .name = "PRI_TDM_RX_3",
  8160. .ops = &msm_dai_q6_tdm_ops,
  8161. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  8162. .probe = msm_dai_q6_dai_tdm_probe,
  8163. .remove = msm_dai_q6_dai_tdm_remove,
  8164. },
  8165. {
  8166. .playback = {
  8167. .stream_name = "Primary TDM4 Playback",
  8168. .aif_name = "PRI_TDM_RX_4",
  8169. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8170. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8171. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8172. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8173. SNDRV_PCM_FMTBIT_S24_LE |
  8174. SNDRV_PCM_FMTBIT_S32_LE,
  8175. .channels_min = 1,
  8176. .channels_max = 8,
  8177. .rate_min = 8000,
  8178. .rate_max = 352800,
  8179. },
  8180. .name = "PRI_TDM_RX_4",
  8181. .ops = &msm_dai_q6_tdm_ops,
  8182. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  8183. .probe = msm_dai_q6_dai_tdm_probe,
  8184. .remove = msm_dai_q6_dai_tdm_remove,
  8185. },
  8186. {
  8187. .playback = {
  8188. .stream_name = "Primary TDM5 Playback",
  8189. .aif_name = "PRI_TDM_RX_5",
  8190. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8191. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8192. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8193. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8194. SNDRV_PCM_FMTBIT_S24_LE |
  8195. SNDRV_PCM_FMTBIT_S32_LE,
  8196. .channels_min = 1,
  8197. .channels_max = 8,
  8198. .rate_min = 8000,
  8199. .rate_max = 352800,
  8200. },
  8201. .name = "PRI_TDM_RX_5",
  8202. .ops = &msm_dai_q6_tdm_ops,
  8203. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  8204. .probe = msm_dai_q6_dai_tdm_probe,
  8205. .remove = msm_dai_q6_dai_tdm_remove,
  8206. },
  8207. {
  8208. .playback = {
  8209. .stream_name = "Primary TDM6 Playback",
  8210. .aif_name = "PRI_TDM_RX_6",
  8211. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8212. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8213. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8214. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8215. SNDRV_PCM_FMTBIT_S24_LE |
  8216. SNDRV_PCM_FMTBIT_S32_LE,
  8217. .channels_min = 1,
  8218. .channels_max = 8,
  8219. .rate_min = 8000,
  8220. .rate_max = 352800,
  8221. },
  8222. .name = "PRI_TDM_RX_6",
  8223. .ops = &msm_dai_q6_tdm_ops,
  8224. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  8225. .probe = msm_dai_q6_dai_tdm_probe,
  8226. .remove = msm_dai_q6_dai_tdm_remove,
  8227. },
  8228. {
  8229. .playback = {
  8230. .stream_name = "Primary TDM7 Playback",
  8231. .aif_name = "PRI_TDM_RX_7",
  8232. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8233. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8234. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8235. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8236. SNDRV_PCM_FMTBIT_S24_LE |
  8237. SNDRV_PCM_FMTBIT_S32_LE,
  8238. .channels_min = 1,
  8239. .channels_max = 8,
  8240. .rate_min = 8000,
  8241. .rate_max = 352800,
  8242. },
  8243. .name = "PRI_TDM_RX_7",
  8244. .ops = &msm_dai_q6_tdm_ops,
  8245. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  8246. .probe = msm_dai_q6_dai_tdm_probe,
  8247. .remove = msm_dai_q6_dai_tdm_remove,
  8248. },
  8249. {
  8250. .capture = {
  8251. .stream_name = "Primary TDM0 Capture",
  8252. .aif_name = "PRI_TDM_TX_0",
  8253. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8254. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8255. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8256. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8257. SNDRV_PCM_FMTBIT_S24_LE |
  8258. SNDRV_PCM_FMTBIT_S32_LE,
  8259. .channels_min = 1,
  8260. .channels_max = 8,
  8261. .rate_min = 8000,
  8262. .rate_max = 352800,
  8263. },
  8264. .name = "PRI_TDM_TX_0",
  8265. .ops = &msm_dai_q6_tdm_ops,
  8266. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  8267. .probe = msm_dai_q6_dai_tdm_probe,
  8268. .remove = msm_dai_q6_dai_tdm_remove,
  8269. },
  8270. {
  8271. .capture = {
  8272. .stream_name = "Primary TDM1 Capture",
  8273. .aif_name = "PRI_TDM_TX_1",
  8274. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8275. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8276. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8277. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8278. SNDRV_PCM_FMTBIT_S24_LE |
  8279. SNDRV_PCM_FMTBIT_S32_LE,
  8280. .channels_min = 1,
  8281. .channels_max = 8,
  8282. .rate_min = 8000,
  8283. .rate_max = 352800,
  8284. },
  8285. .name = "PRI_TDM_TX_1",
  8286. .ops = &msm_dai_q6_tdm_ops,
  8287. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  8288. .probe = msm_dai_q6_dai_tdm_probe,
  8289. .remove = msm_dai_q6_dai_tdm_remove,
  8290. },
  8291. {
  8292. .capture = {
  8293. .stream_name = "Primary TDM2 Capture",
  8294. .aif_name = "PRI_TDM_TX_2",
  8295. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8296. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8297. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8298. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8299. SNDRV_PCM_FMTBIT_S24_LE |
  8300. SNDRV_PCM_FMTBIT_S32_LE,
  8301. .channels_min = 1,
  8302. .channels_max = 8,
  8303. .rate_min = 8000,
  8304. .rate_max = 352800,
  8305. },
  8306. .name = "PRI_TDM_TX_2",
  8307. .ops = &msm_dai_q6_tdm_ops,
  8308. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  8309. .probe = msm_dai_q6_dai_tdm_probe,
  8310. .remove = msm_dai_q6_dai_tdm_remove,
  8311. },
  8312. {
  8313. .capture = {
  8314. .stream_name = "Primary TDM3 Capture",
  8315. .aif_name = "PRI_TDM_TX_3",
  8316. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8317. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8318. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8319. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8320. SNDRV_PCM_FMTBIT_S24_LE |
  8321. SNDRV_PCM_FMTBIT_S32_LE,
  8322. .channels_min = 1,
  8323. .channels_max = 8,
  8324. .rate_min = 8000,
  8325. .rate_max = 352800,
  8326. },
  8327. .name = "PRI_TDM_TX_3",
  8328. .ops = &msm_dai_q6_tdm_ops,
  8329. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  8330. .probe = msm_dai_q6_dai_tdm_probe,
  8331. .remove = msm_dai_q6_dai_tdm_remove,
  8332. },
  8333. {
  8334. .capture = {
  8335. .stream_name = "Primary TDM4 Capture",
  8336. .aif_name = "PRI_TDM_TX_4",
  8337. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8338. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8339. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8340. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8341. SNDRV_PCM_FMTBIT_S24_LE |
  8342. SNDRV_PCM_FMTBIT_S32_LE,
  8343. .channels_min = 1,
  8344. .channels_max = 8,
  8345. .rate_min = 8000,
  8346. .rate_max = 352800,
  8347. },
  8348. .name = "PRI_TDM_TX_4",
  8349. .ops = &msm_dai_q6_tdm_ops,
  8350. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  8351. .probe = msm_dai_q6_dai_tdm_probe,
  8352. .remove = msm_dai_q6_dai_tdm_remove,
  8353. },
  8354. {
  8355. .capture = {
  8356. .stream_name = "Primary TDM5 Capture",
  8357. .aif_name = "PRI_TDM_TX_5",
  8358. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8359. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8360. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8361. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8362. SNDRV_PCM_FMTBIT_S24_LE |
  8363. SNDRV_PCM_FMTBIT_S32_LE,
  8364. .channels_min = 1,
  8365. .channels_max = 8,
  8366. .rate_min = 8000,
  8367. .rate_max = 352800,
  8368. },
  8369. .name = "PRI_TDM_TX_5",
  8370. .ops = &msm_dai_q6_tdm_ops,
  8371. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  8372. .probe = msm_dai_q6_dai_tdm_probe,
  8373. .remove = msm_dai_q6_dai_tdm_remove,
  8374. },
  8375. {
  8376. .capture = {
  8377. .stream_name = "Primary TDM6 Capture",
  8378. .aif_name = "PRI_TDM_TX_6",
  8379. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8380. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8381. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8382. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8383. SNDRV_PCM_FMTBIT_S24_LE |
  8384. SNDRV_PCM_FMTBIT_S32_LE,
  8385. .channels_min = 1,
  8386. .channels_max = 8,
  8387. .rate_min = 8000,
  8388. .rate_max = 352800,
  8389. },
  8390. .name = "PRI_TDM_TX_6",
  8391. .ops = &msm_dai_q6_tdm_ops,
  8392. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  8393. .probe = msm_dai_q6_dai_tdm_probe,
  8394. .remove = msm_dai_q6_dai_tdm_remove,
  8395. },
  8396. {
  8397. .capture = {
  8398. .stream_name = "Primary TDM7 Capture",
  8399. .aif_name = "PRI_TDM_TX_7",
  8400. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8401. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8402. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8403. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8404. SNDRV_PCM_FMTBIT_S24_LE |
  8405. SNDRV_PCM_FMTBIT_S32_LE,
  8406. .channels_min = 1,
  8407. .channels_max = 8,
  8408. .rate_min = 8000,
  8409. .rate_max = 352800,
  8410. },
  8411. .name = "PRI_TDM_TX_7",
  8412. .ops = &msm_dai_q6_tdm_ops,
  8413. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  8414. .probe = msm_dai_q6_dai_tdm_probe,
  8415. .remove = msm_dai_q6_dai_tdm_remove,
  8416. },
  8417. {
  8418. .playback = {
  8419. .stream_name = "Secondary TDM0 Playback",
  8420. .aif_name = "SEC_TDM_RX_0",
  8421. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8422. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8423. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8424. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8425. SNDRV_PCM_FMTBIT_S24_LE |
  8426. SNDRV_PCM_FMTBIT_S32_LE,
  8427. .channels_min = 1,
  8428. .channels_max = 8,
  8429. .rate_min = 8000,
  8430. .rate_max = 352800,
  8431. },
  8432. .name = "SEC_TDM_RX_0",
  8433. .ops = &msm_dai_q6_tdm_ops,
  8434. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  8435. .probe = msm_dai_q6_dai_tdm_probe,
  8436. .remove = msm_dai_q6_dai_tdm_remove,
  8437. },
  8438. {
  8439. .playback = {
  8440. .stream_name = "Secondary TDM1 Playback",
  8441. .aif_name = "SEC_TDM_RX_1",
  8442. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8443. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8444. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8445. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8446. SNDRV_PCM_FMTBIT_S24_LE |
  8447. SNDRV_PCM_FMTBIT_S32_LE,
  8448. .channels_min = 1,
  8449. .channels_max = 8,
  8450. .rate_min = 8000,
  8451. .rate_max = 352800,
  8452. },
  8453. .name = "SEC_TDM_RX_1",
  8454. .ops = &msm_dai_q6_tdm_ops,
  8455. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  8456. .probe = msm_dai_q6_dai_tdm_probe,
  8457. .remove = msm_dai_q6_dai_tdm_remove,
  8458. },
  8459. {
  8460. .playback = {
  8461. .stream_name = "Secondary TDM2 Playback",
  8462. .aif_name = "SEC_TDM_RX_2",
  8463. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8464. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8465. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8466. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8467. SNDRV_PCM_FMTBIT_S24_LE |
  8468. SNDRV_PCM_FMTBIT_S32_LE,
  8469. .channels_min = 1,
  8470. .channels_max = 8,
  8471. .rate_min = 8000,
  8472. .rate_max = 352800,
  8473. },
  8474. .name = "SEC_TDM_RX_2",
  8475. .ops = &msm_dai_q6_tdm_ops,
  8476. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  8477. .probe = msm_dai_q6_dai_tdm_probe,
  8478. .remove = msm_dai_q6_dai_tdm_remove,
  8479. },
  8480. {
  8481. .playback = {
  8482. .stream_name = "Secondary TDM3 Playback",
  8483. .aif_name = "SEC_TDM_RX_3",
  8484. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8485. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8486. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8487. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8488. SNDRV_PCM_FMTBIT_S24_LE |
  8489. SNDRV_PCM_FMTBIT_S32_LE,
  8490. .channels_min = 1,
  8491. .channels_max = 8,
  8492. .rate_min = 8000,
  8493. .rate_max = 352800,
  8494. },
  8495. .name = "SEC_TDM_RX_3",
  8496. .ops = &msm_dai_q6_tdm_ops,
  8497. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  8498. .probe = msm_dai_q6_dai_tdm_probe,
  8499. .remove = msm_dai_q6_dai_tdm_remove,
  8500. },
  8501. {
  8502. .playback = {
  8503. .stream_name = "Secondary TDM4 Playback",
  8504. .aif_name = "SEC_TDM_RX_4",
  8505. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8506. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8507. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8508. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8509. SNDRV_PCM_FMTBIT_S24_LE |
  8510. SNDRV_PCM_FMTBIT_S32_LE,
  8511. .channels_min = 1,
  8512. .channels_max = 8,
  8513. .rate_min = 8000,
  8514. .rate_max = 352800,
  8515. },
  8516. .name = "SEC_TDM_RX_4",
  8517. .ops = &msm_dai_q6_tdm_ops,
  8518. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  8519. .probe = msm_dai_q6_dai_tdm_probe,
  8520. .remove = msm_dai_q6_dai_tdm_remove,
  8521. },
  8522. {
  8523. .playback = {
  8524. .stream_name = "Secondary TDM5 Playback",
  8525. .aif_name = "SEC_TDM_RX_5",
  8526. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8527. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8528. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8529. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8530. SNDRV_PCM_FMTBIT_S24_LE |
  8531. SNDRV_PCM_FMTBIT_S32_LE,
  8532. .channels_min = 1,
  8533. .channels_max = 8,
  8534. .rate_min = 8000,
  8535. .rate_max = 352800,
  8536. },
  8537. .name = "SEC_TDM_RX_5",
  8538. .ops = &msm_dai_q6_tdm_ops,
  8539. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  8540. .probe = msm_dai_q6_dai_tdm_probe,
  8541. .remove = msm_dai_q6_dai_tdm_remove,
  8542. },
  8543. {
  8544. .playback = {
  8545. .stream_name = "Secondary TDM6 Playback",
  8546. .aif_name = "SEC_TDM_RX_6",
  8547. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8548. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8549. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8550. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8551. SNDRV_PCM_FMTBIT_S24_LE |
  8552. SNDRV_PCM_FMTBIT_S32_LE,
  8553. .channels_min = 1,
  8554. .channels_max = 8,
  8555. .rate_min = 8000,
  8556. .rate_max = 352800,
  8557. },
  8558. .name = "SEC_TDM_RX_6",
  8559. .ops = &msm_dai_q6_tdm_ops,
  8560. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  8561. .probe = msm_dai_q6_dai_tdm_probe,
  8562. .remove = msm_dai_q6_dai_tdm_remove,
  8563. },
  8564. {
  8565. .playback = {
  8566. .stream_name = "Secondary TDM7 Playback",
  8567. .aif_name = "SEC_TDM_RX_7",
  8568. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8569. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8570. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8571. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8572. SNDRV_PCM_FMTBIT_S24_LE |
  8573. SNDRV_PCM_FMTBIT_S32_LE,
  8574. .channels_min = 1,
  8575. .channels_max = 8,
  8576. .rate_min = 8000,
  8577. .rate_max = 352800,
  8578. },
  8579. .name = "SEC_TDM_RX_7",
  8580. .ops = &msm_dai_q6_tdm_ops,
  8581. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  8582. .probe = msm_dai_q6_dai_tdm_probe,
  8583. .remove = msm_dai_q6_dai_tdm_remove,
  8584. },
  8585. {
  8586. .capture = {
  8587. .stream_name = "Secondary TDM0 Capture",
  8588. .aif_name = "SEC_TDM_TX_0",
  8589. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8590. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8591. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8592. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8593. SNDRV_PCM_FMTBIT_S24_LE |
  8594. SNDRV_PCM_FMTBIT_S32_LE,
  8595. .channels_min = 1,
  8596. .channels_max = 8,
  8597. .rate_min = 8000,
  8598. .rate_max = 352800,
  8599. },
  8600. .name = "SEC_TDM_TX_0",
  8601. .ops = &msm_dai_q6_tdm_ops,
  8602. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  8603. .probe = msm_dai_q6_dai_tdm_probe,
  8604. .remove = msm_dai_q6_dai_tdm_remove,
  8605. },
  8606. {
  8607. .capture = {
  8608. .stream_name = "Secondary TDM1 Capture",
  8609. .aif_name = "SEC_TDM_TX_1",
  8610. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8611. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8612. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8613. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8614. SNDRV_PCM_FMTBIT_S24_LE |
  8615. SNDRV_PCM_FMTBIT_S32_LE,
  8616. .channels_min = 1,
  8617. .channels_max = 8,
  8618. .rate_min = 8000,
  8619. .rate_max = 352800,
  8620. },
  8621. .name = "SEC_TDM_TX_1",
  8622. .ops = &msm_dai_q6_tdm_ops,
  8623. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  8624. .probe = msm_dai_q6_dai_tdm_probe,
  8625. .remove = msm_dai_q6_dai_tdm_remove,
  8626. },
  8627. {
  8628. .capture = {
  8629. .stream_name = "Secondary TDM2 Capture",
  8630. .aif_name = "SEC_TDM_TX_2",
  8631. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8632. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8633. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8634. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8635. SNDRV_PCM_FMTBIT_S24_LE |
  8636. SNDRV_PCM_FMTBIT_S32_LE,
  8637. .channels_min = 1,
  8638. .channels_max = 8,
  8639. .rate_min = 8000,
  8640. .rate_max = 352800,
  8641. },
  8642. .name = "SEC_TDM_TX_2",
  8643. .ops = &msm_dai_q6_tdm_ops,
  8644. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  8645. .probe = msm_dai_q6_dai_tdm_probe,
  8646. .remove = msm_dai_q6_dai_tdm_remove,
  8647. },
  8648. {
  8649. .capture = {
  8650. .stream_name = "Secondary TDM3 Capture",
  8651. .aif_name = "SEC_TDM_TX_3",
  8652. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8653. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8654. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8655. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8656. SNDRV_PCM_FMTBIT_S24_LE |
  8657. SNDRV_PCM_FMTBIT_S32_LE,
  8658. .channels_min = 1,
  8659. .channels_max = 8,
  8660. .rate_min = 8000,
  8661. .rate_max = 352800,
  8662. },
  8663. .name = "SEC_TDM_TX_3",
  8664. .ops = &msm_dai_q6_tdm_ops,
  8665. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  8666. .probe = msm_dai_q6_dai_tdm_probe,
  8667. .remove = msm_dai_q6_dai_tdm_remove,
  8668. },
  8669. {
  8670. .capture = {
  8671. .stream_name = "Secondary TDM4 Capture",
  8672. .aif_name = "SEC_TDM_TX_4",
  8673. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8674. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8675. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8676. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8677. SNDRV_PCM_FMTBIT_S24_LE |
  8678. SNDRV_PCM_FMTBIT_S32_LE,
  8679. .channels_min = 1,
  8680. .channels_max = 8,
  8681. .rate_min = 8000,
  8682. .rate_max = 352800,
  8683. },
  8684. .name = "SEC_TDM_TX_4",
  8685. .ops = &msm_dai_q6_tdm_ops,
  8686. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  8687. .probe = msm_dai_q6_dai_tdm_probe,
  8688. .remove = msm_dai_q6_dai_tdm_remove,
  8689. },
  8690. {
  8691. .capture = {
  8692. .stream_name = "Secondary TDM5 Capture",
  8693. .aif_name = "SEC_TDM_TX_5",
  8694. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8695. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8696. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8697. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8698. SNDRV_PCM_FMTBIT_S24_LE |
  8699. SNDRV_PCM_FMTBIT_S32_LE,
  8700. .channels_min = 1,
  8701. .channels_max = 8,
  8702. .rate_min = 8000,
  8703. .rate_max = 352800,
  8704. },
  8705. .name = "SEC_TDM_TX_5",
  8706. .ops = &msm_dai_q6_tdm_ops,
  8707. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  8708. .probe = msm_dai_q6_dai_tdm_probe,
  8709. .remove = msm_dai_q6_dai_tdm_remove,
  8710. },
  8711. {
  8712. .capture = {
  8713. .stream_name = "Secondary TDM6 Capture",
  8714. .aif_name = "SEC_TDM_TX_6",
  8715. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8716. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8717. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8718. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8719. SNDRV_PCM_FMTBIT_S24_LE |
  8720. SNDRV_PCM_FMTBIT_S32_LE,
  8721. .channels_min = 1,
  8722. .channels_max = 8,
  8723. .rate_min = 8000,
  8724. .rate_max = 352800,
  8725. },
  8726. .name = "SEC_TDM_TX_6",
  8727. .ops = &msm_dai_q6_tdm_ops,
  8728. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  8729. .probe = msm_dai_q6_dai_tdm_probe,
  8730. .remove = msm_dai_q6_dai_tdm_remove,
  8731. },
  8732. {
  8733. .capture = {
  8734. .stream_name = "Secondary TDM7 Capture",
  8735. .aif_name = "SEC_TDM_TX_7",
  8736. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8737. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8738. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8739. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8740. SNDRV_PCM_FMTBIT_S24_LE |
  8741. SNDRV_PCM_FMTBIT_S32_LE,
  8742. .channels_min = 1,
  8743. .channels_max = 8,
  8744. .rate_min = 8000,
  8745. .rate_max = 352800,
  8746. },
  8747. .name = "SEC_TDM_TX_7",
  8748. .ops = &msm_dai_q6_tdm_ops,
  8749. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  8750. .probe = msm_dai_q6_dai_tdm_probe,
  8751. .remove = msm_dai_q6_dai_tdm_remove,
  8752. },
  8753. {
  8754. .playback = {
  8755. .stream_name = "Tertiary TDM0 Playback",
  8756. .aif_name = "TERT_TDM_RX_0",
  8757. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8758. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8759. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8760. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8761. SNDRV_PCM_FMTBIT_S24_LE |
  8762. SNDRV_PCM_FMTBIT_S32_LE,
  8763. .channels_min = 1,
  8764. .channels_max = 8,
  8765. .rate_min = 8000,
  8766. .rate_max = 352800,
  8767. },
  8768. .name = "TERT_TDM_RX_0",
  8769. .ops = &msm_dai_q6_tdm_ops,
  8770. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  8771. .probe = msm_dai_q6_dai_tdm_probe,
  8772. .remove = msm_dai_q6_dai_tdm_remove,
  8773. },
  8774. {
  8775. .playback = {
  8776. .stream_name = "Tertiary TDM1 Playback",
  8777. .aif_name = "TERT_TDM_RX_1",
  8778. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8779. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8780. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8781. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8782. SNDRV_PCM_FMTBIT_S24_LE |
  8783. SNDRV_PCM_FMTBIT_S32_LE,
  8784. .channels_min = 1,
  8785. .channels_max = 8,
  8786. .rate_min = 8000,
  8787. .rate_max = 352800,
  8788. },
  8789. .name = "TERT_TDM_RX_1",
  8790. .ops = &msm_dai_q6_tdm_ops,
  8791. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  8792. .probe = msm_dai_q6_dai_tdm_probe,
  8793. .remove = msm_dai_q6_dai_tdm_remove,
  8794. },
  8795. {
  8796. .playback = {
  8797. .stream_name = "Tertiary TDM2 Playback",
  8798. .aif_name = "TERT_TDM_RX_2",
  8799. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8800. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8801. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8802. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8803. SNDRV_PCM_FMTBIT_S24_LE |
  8804. SNDRV_PCM_FMTBIT_S32_LE,
  8805. .channels_min = 1,
  8806. .channels_max = 8,
  8807. .rate_min = 8000,
  8808. .rate_max = 352800,
  8809. },
  8810. .name = "TERT_TDM_RX_2",
  8811. .ops = &msm_dai_q6_tdm_ops,
  8812. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  8813. .probe = msm_dai_q6_dai_tdm_probe,
  8814. .remove = msm_dai_q6_dai_tdm_remove,
  8815. },
  8816. {
  8817. .playback = {
  8818. .stream_name = "Tertiary TDM3 Playback",
  8819. .aif_name = "TERT_TDM_RX_3",
  8820. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8821. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8822. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8823. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8824. SNDRV_PCM_FMTBIT_S24_LE |
  8825. SNDRV_PCM_FMTBIT_S32_LE,
  8826. .channels_min = 1,
  8827. .channels_max = 8,
  8828. .rate_min = 8000,
  8829. .rate_max = 352800,
  8830. },
  8831. .name = "TERT_TDM_RX_3",
  8832. .ops = &msm_dai_q6_tdm_ops,
  8833. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  8834. .probe = msm_dai_q6_dai_tdm_probe,
  8835. .remove = msm_dai_q6_dai_tdm_remove,
  8836. },
  8837. {
  8838. .playback = {
  8839. .stream_name = "Tertiary TDM4 Playback",
  8840. .aif_name = "TERT_TDM_RX_4",
  8841. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8842. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8843. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8844. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8845. SNDRV_PCM_FMTBIT_S24_LE |
  8846. SNDRV_PCM_FMTBIT_S32_LE,
  8847. .channels_min = 1,
  8848. .channels_max = 8,
  8849. .rate_min = 8000,
  8850. .rate_max = 352800,
  8851. },
  8852. .name = "TERT_TDM_RX_4",
  8853. .ops = &msm_dai_q6_tdm_ops,
  8854. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  8855. .probe = msm_dai_q6_dai_tdm_probe,
  8856. .remove = msm_dai_q6_dai_tdm_remove,
  8857. },
  8858. {
  8859. .playback = {
  8860. .stream_name = "Tertiary TDM5 Playback",
  8861. .aif_name = "TERT_TDM_RX_5",
  8862. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8863. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8864. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8865. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8866. SNDRV_PCM_FMTBIT_S24_LE |
  8867. SNDRV_PCM_FMTBIT_S32_LE,
  8868. .channels_min = 1,
  8869. .channels_max = 8,
  8870. .rate_min = 8000,
  8871. .rate_max = 352800,
  8872. },
  8873. .name = "TERT_TDM_RX_5",
  8874. .ops = &msm_dai_q6_tdm_ops,
  8875. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  8876. .probe = msm_dai_q6_dai_tdm_probe,
  8877. .remove = msm_dai_q6_dai_tdm_remove,
  8878. },
  8879. {
  8880. .playback = {
  8881. .stream_name = "Tertiary TDM6 Playback",
  8882. .aif_name = "TERT_TDM_RX_6",
  8883. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8884. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8885. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8886. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8887. SNDRV_PCM_FMTBIT_S24_LE |
  8888. SNDRV_PCM_FMTBIT_S32_LE,
  8889. .channels_min = 1,
  8890. .channels_max = 8,
  8891. .rate_min = 8000,
  8892. .rate_max = 352800,
  8893. },
  8894. .name = "TERT_TDM_RX_6",
  8895. .ops = &msm_dai_q6_tdm_ops,
  8896. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  8897. .probe = msm_dai_q6_dai_tdm_probe,
  8898. .remove = msm_dai_q6_dai_tdm_remove,
  8899. },
  8900. {
  8901. .playback = {
  8902. .stream_name = "Tertiary TDM7 Playback",
  8903. .aif_name = "TERT_TDM_RX_7",
  8904. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8905. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8906. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8907. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8908. SNDRV_PCM_FMTBIT_S24_LE |
  8909. SNDRV_PCM_FMTBIT_S32_LE,
  8910. .channels_min = 1,
  8911. .channels_max = 8,
  8912. .rate_min = 8000,
  8913. .rate_max = 352800,
  8914. },
  8915. .name = "TERT_TDM_RX_7",
  8916. .ops = &msm_dai_q6_tdm_ops,
  8917. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  8918. .probe = msm_dai_q6_dai_tdm_probe,
  8919. .remove = msm_dai_q6_dai_tdm_remove,
  8920. },
  8921. {
  8922. .capture = {
  8923. .stream_name = "Tertiary TDM0 Capture",
  8924. .aif_name = "TERT_TDM_TX_0",
  8925. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8926. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8927. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8928. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8929. SNDRV_PCM_FMTBIT_S24_LE |
  8930. SNDRV_PCM_FMTBIT_S32_LE,
  8931. .channels_min = 1,
  8932. .channels_max = 8,
  8933. .rate_min = 8000,
  8934. .rate_max = 352800,
  8935. },
  8936. .name = "TERT_TDM_TX_0",
  8937. .ops = &msm_dai_q6_tdm_ops,
  8938. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  8939. .probe = msm_dai_q6_dai_tdm_probe,
  8940. .remove = msm_dai_q6_dai_tdm_remove,
  8941. },
  8942. {
  8943. .capture = {
  8944. .stream_name = "Tertiary TDM1 Capture",
  8945. .aif_name = "TERT_TDM_TX_1",
  8946. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8947. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8948. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8949. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8950. SNDRV_PCM_FMTBIT_S24_LE |
  8951. SNDRV_PCM_FMTBIT_S32_LE,
  8952. .channels_min = 1,
  8953. .channels_max = 8,
  8954. .rate_min = 8000,
  8955. .rate_max = 352800,
  8956. },
  8957. .name = "TERT_TDM_TX_1",
  8958. .ops = &msm_dai_q6_tdm_ops,
  8959. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  8960. .probe = msm_dai_q6_dai_tdm_probe,
  8961. .remove = msm_dai_q6_dai_tdm_remove,
  8962. },
  8963. {
  8964. .capture = {
  8965. .stream_name = "Tertiary TDM2 Capture",
  8966. .aif_name = "TERT_TDM_TX_2",
  8967. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8968. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8969. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8970. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8971. SNDRV_PCM_FMTBIT_S24_LE |
  8972. SNDRV_PCM_FMTBIT_S32_LE,
  8973. .channels_min = 1,
  8974. .channels_max = 8,
  8975. .rate_min = 8000,
  8976. .rate_max = 352800,
  8977. },
  8978. .name = "TERT_TDM_TX_2",
  8979. .ops = &msm_dai_q6_tdm_ops,
  8980. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  8981. .probe = msm_dai_q6_dai_tdm_probe,
  8982. .remove = msm_dai_q6_dai_tdm_remove,
  8983. },
  8984. {
  8985. .capture = {
  8986. .stream_name = "Tertiary TDM3 Capture",
  8987. .aif_name = "TERT_TDM_TX_3",
  8988. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8989. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8990. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8991. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8992. SNDRV_PCM_FMTBIT_S24_LE |
  8993. SNDRV_PCM_FMTBIT_S32_LE,
  8994. .channels_min = 1,
  8995. .channels_max = 8,
  8996. .rate_min = 8000,
  8997. .rate_max = 352800,
  8998. },
  8999. .name = "TERT_TDM_TX_3",
  9000. .ops = &msm_dai_q6_tdm_ops,
  9001. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  9002. .probe = msm_dai_q6_dai_tdm_probe,
  9003. .remove = msm_dai_q6_dai_tdm_remove,
  9004. },
  9005. {
  9006. .capture = {
  9007. .stream_name = "Tertiary TDM4 Capture",
  9008. .aif_name = "TERT_TDM_TX_4",
  9009. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9010. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9011. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9012. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9013. SNDRV_PCM_FMTBIT_S24_LE |
  9014. SNDRV_PCM_FMTBIT_S32_LE,
  9015. .channels_min = 1,
  9016. .channels_max = 8,
  9017. .rate_min = 8000,
  9018. .rate_max = 352800,
  9019. },
  9020. .name = "TERT_TDM_TX_4",
  9021. .ops = &msm_dai_q6_tdm_ops,
  9022. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  9023. .probe = msm_dai_q6_dai_tdm_probe,
  9024. .remove = msm_dai_q6_dai_tdm_remove,
  9025. },
  9026. {
  9027. .capture = {
  9028. .stream_name = "Tertiary TDM5 Capture",
  9029. .aif_name = "TERT_TDM_TX_5",
  9030. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9031. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9032. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9033. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9034. SNDRV_PCM_FMTBIT_S24_LE |
  9035. SNDRV_PCM_FMTBIT_S32_LE,
  9036. .channels_min = 1,
  9037. .channels_max = 8,
  9038. .rate_min = 8000,
  9039. .rate_max = 352800,
  9040. },
  9041. .name = "TERT_TDM_TX_5",
  9042. .ops = &msm_dai_q6_tdm_ops,
  9043. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  9044. .probe = msm_dai_q6_dai_tdm_probe,
  9045. .remove = msm_dai_q6_dai_tdm_remove,
  9046. },
  9047. {
  9048. .capture = {
  9049. .stream_name = "Tertiary TDM6 Capture",
  9050. .aif_name = "TERT_TDM_TX_6",
  9051. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9052. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9053. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9054. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9055. SNDRV_PCM_FMTBIT_S24_LE |
  9056. SNDRV_PCM_FMTBIT_S32_LE,
  9057. .channels_min = 1,
  9058. .channels_max = 8,
  9059. .rate_min = 8000,
  9060. .rate_max = 352800,
  9061. },
  9062. .name = "TERT_TDM_TX_6",
  9063. .ops = &msm_dai_q6_tdm_ops,
  9064. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  9065. .probe = msm_dai_q6_dai_tdm_probe,
  9066. .remove = msm_dai_q6_dai_tdm_remove,
  9067. },
  9068. {
  9069. .capture = {
  9070. .stream_name = "Tertiary TDM7 Capture",
  9071. .aif_name = "TERT_TDM_TX_7",
  9072. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9073. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9074. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9075. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9076. SNDRV_PCM_FMTBIT_S24_LE |
  9077. SNDRV_PCM_FMTBIT_S32_LE,
  9078. .channels_min = 1,
  9079. .channels_max = 8,
  9080. .rate_min = 8000,
  9081. .rate_max = 352800,
  9082. },
  9083. .name = "TERT_TDM_TX_7",
  9084. .ops = &msm_dai_q6_tdm_ops,
  9085. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  9086. .probe = msm_dai_q6_dai_tdm_probe,
  9087. .remove = msm_dai_q6_dai_tdm_remove,
  9088. },
  9089. {
  9090. .playback = {
  9091. .stream_name = "Quaternary TDM0 Playback",
  9092. .aif_name = "QUAT_TDM_RX_0",
  9093. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9094. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9095. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9096. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9097. SNDRV_PCM_FMTBIT_S24_LE |
  9098. SNDRV_PCM_FMTBIT_S32_LE,
  9099. .channels_min = 1,
  9100. .channels_max = 8,
  9101. .rate_min = 8000,
  9102. .rate_max = 352800,
  9103. },
  9104. .name = "QUAT_TDM_RX_0",
  9105. .ops = &msm_dai_q6_tdm_ops,
  9106. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  9107. .probe = msm_dai_q6_dai_tdm_probe,
  9108. .remove = msm_dai_q6_dai_tdm_remove,
  9109. },
  9110. {
  9111. .playback = {
  9112. .stream_name = "Quaternary TDM1 Playback",
  9113. .aif_name = "QUAT_TDM_RX_1",
  9114. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9115. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9116. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9117. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9118. SNDRV_PCM_FMTBIT_S24_LE |
  9119. SNDRV_PCM_FMTBIT_S32_LE,
  9120. .channels_min = 1,
  9121. .channels_max = 8,
  9122. .rate_min = 8000,
  9123. .rate_max = 352800,
  9124. },
  9125. .name = "QUAT_TDM_RX_1",
  9126. .ops = &msm_dai_q6_tdm_ops,
  9127. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  9128. .probe = msm_dai_q6_dai_tdm_probe,
  9129. .remove = msm_dai_q6_dai_tdm_remove,
  9130. },
  9131. {
  9132. .playback = {
  9133. .stream_name = "Quaternary TDM2 Playback",
  9134. .aif_name = "QUAT_TDM_RX_2",
  9135. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9136. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9137. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9138. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9139. SNDRV_PCM_FMTBIT_S24_LE |
  9140. SNDRV_PCM_FMTBIT_S32_LE,
  9141. .channels_min = 1,
  9142. .channels_max = 8,
  9143. .rate_min = 8000,
  9144. .rate_max = 352800,
  9145. },
  9146. .name = "QUAT_TDM_RX_2",
  9147. .ops = &msm_dai_q6_tdm_ops,
  9148. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  9149. .probe = msm_dai_q6_dai_tdm_probe,
  9150. .remove = msm_dai_q6_dai_tdm_remove,
  9151. },
  9152. {
  9153. .playback = {
  9154. .stream_name = "Quaternary TDM3 Playback",
  9155. .aif_name = "QUAT_TDM_RX_3",
  9156. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9157. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9158. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9159. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9160. SNDRV_PCM_FMTBIT_S24_LE |
  9161. SNDRV_PCM_FMTBIT_S32_LE,
  9162. .channels_min = 1,
  9163. .channels_max = 8,
  9164. .rate_min = 8000,
  9165. .rate_max = 352800,
  9166. },
  9167. .name = "QUAT_TDM_RX_3",
  9168. .ops = &msm_dai_q6_tdm_ops,
  9169. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  9170. .probe = msm_dai_q6_dai_tdm_probe,
  9171. .remove = msm_dai_q6_dai_tdm_remove,
  9172. },
  9173. {
  9174. .playback = {
  9175. .stream_name = "Quaternary TDM4 Playback",
  9176. .aif_name = "QUAT_TDM_RX_4",
  9177. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9178. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9179. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9180. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9181. SNDRV_PCM_FMTBIT_S24_LE |
  9182. SNDRV_PCM_FMTBIT_S32_LE,
  9183. .channels_min = 1,
  9184. .channels_max = 8,
  9185. .rate_min = 8000,
  9186. .rate_max = 352800,
  9187. },
  9188. .name = "QUAT_TDM_RX_4",
  9189. .ops = &msm_dai_q6_tdm_ops,
  9190. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  9191. .probe = msm_dai_q6_dai_tdm_probe,
  9192. .remove = msm_dai_q6_dai_tdm_remove,
  9193. },
  9194. {
  9195. .playback = {
  9196. .stream_name = "Quaternary TDM5 Playback",
  9197. .aif_name = "QUAT_TDM_RX_5",
  9198. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9199. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9200. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9201. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9202. SNDRV_PCM_FMTBIT_S24_LE |
  9203. SNDRV_PCM_FMTBIT_S32_LE,
  9204. .channels_min = 1,
  9205. .channels_max = 8,
  9206. .rate_min = 8000,
  9207. .rate_max = 352800,
  9208. },
  9209. .name = "QUAT_TDM_RX_5",
  9210. .ops = &msm_dai_q6_tdm_ops,
  9211. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  9212. .probe = msm_dai_q6_dai_tdm_probe,
  9213. .remove = msm_dai_q6_dai_tdm_remove,
  9214. },
  9215. {
  9216. .playback = {
  9217. .stream_name = "Quaternary TDM6 Playback",
  9218. .aif_name = "QUAT_TDM_RX_6",
  9219. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9220. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9221. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9222. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9223. SNDRV_PCM_FMTBIT_S24_LE |
  9224. SNDRV_PCM_FMTBIT_S32_LE,
  9225. .channels_min = 1,
  9226. .channels_max = 8,
  9227. .rate_min = 8000,
  9228. .rate_max = 352800,
  9229. },
  9230. .name = "QUAT_TDM_RX_6",
  9231. .ops = &msm_dai_q6_tdm_ops,
  9232. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  9233. .probe = msm_dai_q6_dai_tdm_probe,
  9234. .remove = msm_dai_q6_dai_tdm_remove,
  9235. },
  9236. {
  9237. .playback = {
  9238. .stream_name = "Quaternary TDM7 Playback",
  9239. .aif_name = "QUAT_TDM_RX_7",
  9240. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9241. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9242. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9243. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9244. SNDRV_PCM_FMTBIT_S24_LE |
  9245. SNDRV_PCM_FMTBIT_S32_LE,
  9246. .channels_min = 1,
  9247. .channels_max = 8,
  9248. .rate_min = 8000,
  9249. .rate_max = 352800,
  9250. },
  9251. .name = "QUAT_TDM_RX_7",
  9252. .ops = &msm_dai_q6_tdm_ops,
  9253. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  9254. .probe = msm_dai_q6_dai_tdm_probe,
  9255. .remove = msm_dai_q6_dai_tdm_remove,
  9256. },
  9257. {
  9258. .capture = {
  9259. .stream_name = "Quaternary TDM0 Capture",
  9260. .aif_name = "QUAT_TDM_TX_0",
  9261. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9262. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9263. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9264. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9265. SNDRV_PCM_FMTBIT_S24_LE |
  9266. SNDRV_PCM_FMTBIT_S32_LE,
  9267. .channels_min = 1,
  9268. .channels_max = 8,
  9269. .rate_min = 8000,
  9270. .rate_max = 352800,
  9271. },
  9272. .name = "QUAT_TDM_TX_0",
  9273. .ops = &msm_dai_q6_tdm_ops,
  9274. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  9275. .probe = msm_dai_q6_dai_tdm_probe,
  9276. .remove = msm_dai_q6_dai_tdm_remove,
  9277. },
  9278. {
  9279. .capture = {
  9280. .stream_name = "Quaternary TDM1 Capture",
  9281. .aif_name = "QUAT_TDM_TX_1",
  9282. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9283. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9284. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9285. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9286. SNDRV_PCM_FMTBIT_S24_LE |
  9287. SNDRV_PCM_FMTBIT_S32_LE,
  9288. .channels_min = 1,
  9289. .channels_max = 8,
  9290. .rate_min = 8000,
  9291. .rate_max = 352800,
  9292. },
  9293. .name = "QUAT_TDM_TX_1",
  9294. .ops = &msm_dai_q6_tdm_ops,
  9295. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  9296. .probe = msm_dai_q6_dai_tdm_probe,
  9297. .remove = msm_dai_q6_dai_tdm_remove,
  9298. },
  9299. {
  9300. .capture = {
  9301. .stream_name = "Quaternary TDM2 Capture",
  9302. .aif_name = "QUAT_TDM_TX_2",
  9303. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9304. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9305. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9306. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9307. SNDRV_PCM_FMTBIT_S24_LE |
  9308. SNDRV_PCM_FMTBIT_S32_LE,
  9309. .channels_min = 1,
  9310. .channels_max = 8,
  9311. .rate_min = 8000,
  9312. .rate_max = 352800,
  9313. },
  9314. .name = "QUAT_TDM_TX_2",
  9315. .ops = &msm_dai_q6_tdm_ops,
  9316. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  9317. .probe = msm_dai_q6_dai_tdm_probe,
  9318. .remove = msm_dai_q6_dai_tdm_remove,
  9319. },
  9320. {
  9321. .capture = {
  9322. .stream_name = "Quaternary TDM3 Capture",
  9323. .aif_name = "QUAT_TDM_TX_3",
  9324. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9325. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9326. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9327. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9328. SNDRV_PCM_FMTBIT_S24_LE |
  9329. SNDRV_PCM_FMTBIT_S32_LE,
  9330. .channels_min = 1,
  9331. .channels_max = 8,
  9332. .rate_min = 8000,
  9333. .rate_max = 352800,
  9334. },
  9335. .name = "QUAT_TDM_TX_3",
  9336. .ops = &msm_dai_q6_tdm_ops,
  9337. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  9338. .probe = msm_dai_q6_dai_tdm_probe,
  9339. .remove = msm_dai_q6_dai_tdm_remove,
  9340. },
  9341. {
  9342. .capture = {
  9343. .stream_name = "Quaternary TDM4 Capture",
  9344. .aif_name = "QUAT_TDM_TX_4",
  9345. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9346. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9347. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9348. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9349. SNDRV_PCM_FMTBIT_S24_LE |
  9350. SNDRV_PCM_FMTBIT_S32_LE,
  9351. .channels_min = 1,
  9352. .channels_max = 8,
  9353. .rate_min = 8000,
  9354. .rate_max = 352800,
  9355. },
  9356. .name = "QUAT_TDM_TX_4",
  9357. .ops = &msm_dai_q6_tdm_ops,
  9358. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  9359. .probe = msm_dai_q6_dai_tdm_probe,
  9360. .remove = msm_dai_q6_dai_tdm_remove,
  9361. },
  9362. {
  9363. .capture = {
  9364. .stream_name = "Quaternary TDM5 Capture",
  9365. .aif_name = "QUAT_TDM_TX_5",
  9366. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9367. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9368. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9369. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9370. SNDRV_PCM_FMTBIT_S24_LE |
  9371. SNDRV_PCM_FMTBIT_S32_LE,
  9372. .channels_min = 1,
  9373. .channels_max = 8,
  9374. .rate_min = 8000,
  9375. .rate_max = 352800,
  9376. },
  9377. .name = "QUAT_TDM_TX_5",
  9378. .ops = &msm_dai_q6_tdm_ops,
  9379. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  9380. .probe = msm_dai_q6_dai_tdm_probe,
  9381. .remove = msm_dai_q6_dai_tdm_remove,
  9382. },
  9383. {
  9384. .capture = {
  9385. .stream_name = "Quaternary TDM6 Capture",
  9386. .aif_name = "QUAT_TDM_TX_6",
  9387. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9388. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9389. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9390. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9391. SNDRV_PCM_FMTBIT_S24_LE |
  9392. SNDRV_PCM_FMTBIT_S32_LE,
  9393. .channels_min = 1,
  9394. .channels_max = 8,
  9395. .rate_min = 8000,
  9396. .rate_max = 352800,
  9397. },
  9398. .name = "QUAT_TDM_TX_6",
  9399. .ops = &msm_dai_q6_tdm_ops,
  9400. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  9401. .probe = msm_dai_q6_dai_tdm_probe,
  9402. .remove = msm_dai_q6_dai_tdm_remove,
  9403. },
  9404. {
  9405. .capture = {
  9406. .stream_name = "Quaternary TDM7 Capture",
  9407. .aif_name = "QUAT_TDM_TX_7",
  9408. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9409. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9410. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9411. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9412. SNDRV_PCM_FMTBIT_S24_LE |
  9413. SNDRV_PCM_FMTBIT_S32_LE,
  9414. .channels_min = 1,
  9415. .channels_max = 8,
  9416. .rate_min = 8000,
  9417. .rate_max = 352800,
  9418. },
  9419. .name = "QUAT_TDM_TX_7",
  9420. .ops = &msm_dai_q6_tdm_ops,
  9421. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  9422. .probe = msm_dai_q6_dai_tdm_probe,
  9423. .remove = msm_dai_q6_dai_tdm_remove,
  9424. },
  9425. {
  9426. .playback = {
  9427. .stream_name = "Quinary TDM0 Playback",
  9428. .aif_name = "QUIN_TDM_RX_0",
  9429. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9430. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9431. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9432. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9433. SNDRV_PCM_FMTBIT_S24_LE |
  9434. SNDRV_PCM_FMTBIT_S32_LE,
  9435. .channels_min = 1,
  9436. .channels_max = 8,
  9437. .rate_min = 8000,
  9438. .rate_max = 352800,
  9439. },
  9440. .name = "QUIN_TDM_RX_0",
  9441. .ops = &msm_dai_q6_tdm_ops,
  9442. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  9443. .probe = msm_dai_q6_dai_tdm_probe,
  9444. .remove = msm_dai_q6_dai_tdm_remove,
  9445. },
  9446. {
  9447. .playback = {
  9448. .stream_name = "Quinary TDM1 Playback",
  9449. .aif_name = "QUIN_TDM_RX_1",
  9450. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9451. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9452. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9453. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9454. SNDRV_PCM_FMTBIT_S24_LE |
  9455. SNDRV_PCM_FMTBIT_S32_LE,
  9456. .channels_min = 1,
  9457. .channels_max = 8,
  9458. .rate_min = 8000,
  9459. .rate_max = 352800,
  9460. },
  9461. .name = "QUIN_TDM_RX_1",
  9462. .ops = &msm_dai_q6_tdm_ops,
  9463. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  9464. .probe = msm_dai_q6_dai_tdm_probe,
  9465. .remove = msm_dai_q6_dai_tdm_remove,
  9466. },
  9467. {
  9468. .playback = {
  9469. .stream_name = "Quinary TDM2 Playback",
  9470. .aif_name = "QUIN_TDM_RX_2",
  9471. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9472. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9473. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9474. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9475. SNDRV_PCM_FMTBIT_S24_LE |
  9476. SNDRV_PCM_FMTBIT_S32_LE,
  9477. .channels_min = 1,
  9478. .channels_max = 8,
  9479. .rate_min = 8000,
  9480. .rate_max = 352800,
  9481. },
  9482. .name = "QUIN_TDM_RX_2",
  9483. .ops = &msm_dai_q6_tdm_ops,
  9484. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  9485. .probe = msm_dai_q6_dai_tdm_probe,
  9486. .remove = msm_dai_q6_dai_tdm_remove,
  9487. },
  9488. {
  9489. .playback = {
  9490. .stream_name = "Quinary TDM3 Playback",
  9491. .aif_name = "QUIN_TDM_RX_3",
  9492. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9493. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9494. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9495. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9496. SNDRV_PCM_FMTBIT_S24_LE |
  9497. SNDRV_PCM_FMTBIT_S32_LE,
  9498. .channels_min = 1,
  9499. .channels_max = 8,
  9500. .rate_min = 8000,
  9501. .rate_max = 352800,
  9502. },
  9503. .name = "QUIN_TDM_RX_3",
  9504. .ops = &msm_dai_q6_tdm_ops,
  9505. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  9506. .probe = msm_dai_q6_dai_tdm_probe,
  9507. .remove = msm_dai_q6_dai_tdm_remove,
  9508. },
  9509. {
  9510. .playback = {
  9511. .stream_name = "Quinary TDM4 Playback",
  9512. .aif_name = "QUIN_TDM_RX_4",
  9513. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9514. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9515. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9516. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9517. SNDRV_PCM_FMTBIT_S24_LE |
  9518. SNDRV_PCM_FMTBIT_S32_LE,
  9519. .channels_min = 1,
  9520. .channels_max = 8,
  9521. .rate_min = 8000,
  9522. .rate_max = 352800,
  9523. },
  9524. .name = "QUIN_TDM_RX_4",
  9525. .ops = &msm_dai_q6_tdm_ops,
  9526. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  9527. .probe = msm_dai_q6_dai_tdm_probe,
  9528. .remove = msm_dai_q6_dai_tdm_remove,
  9529. },
  9530. {
  9531. .playback = {
  9532. .stream_name = "Quinary TDM5 Playback",
  9533. .aif_name = "QUIN_TDM_RX_5",
  9534. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9535. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9536. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9537. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9538. SNDRV_PCM_FMTBIT_S24_LE |
  9539. SNDRV_PCM_FMTBIT_S32_LE,
  9540. .channels_min = 1,
  9541. .channels_max = 8,
  9542. .rate_min = 8000,
  9543. .rate_max = 352800,
  9544. },
  9545. .name = "QUIN_TDM_RX_5",
  9546. .ops = &msm_dai_q6_tdm_ops,
  9547. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  9548. .probe = msm_dai_q6_dai_tdm_probe,
  9549. .remove = msm_dai_q6_dai_tdm_remove,
  9550. },
  9551. {
  9552. .playback = {
  9553. .stream_name = "Quinary TDM6 Playback",
  9554. .aif_name = "QUIN_TDM_RX_6",
  9555. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9556. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9557. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9558. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9559. SNDRV_PCM_FMTBIT_S24_LE |
  9560. SNDRV_PCM_FMTBIT_S32_LE,
  9561. .channels_min = 1,
  9562. .channels_max = 8,
  9563. .rate_min = 8000,
  9564. .rate_max = 352800,
  9565. },
  9566. .name = "QUIN_TDM_RX_6",
  9567. .ops = &msm_dai_q6_tdm_ops,
  9568. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  9569. .probe = msm_dai_q6_dai_tdm_probe,
  9570. .remove = msm_dai_q6_dai_tdm_remove,
  9571. },
  9572. {
  9573. .playback = {
  9574. .stream_name = "Quinary TDM7 Playback",
  9575. .aif_name = "QUIN_TDM_RX_7",
  9576. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9577. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9578. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9579. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9580. SNDRV_PCM_FMTBIT_S24_LE |
  9581. SNDRV_PCM_FMTBIT_S32_LE,
  9582. .channels_min = 1,
  9583. .channels_max = 8,
  9584. .rate_min = 8000,
  9585. .rate_max = 352800,
  9586. },
  9587. .name = "QUIN_TDM_RX_7",
  9588. .ops = &msm_dai_q6_tdm_ops,
  9589. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  9590. .probe = msm_dai_q6_dai_tdm_probe,
  9591. .remove = msm_dai_q6_dai_tdm_remove,
  9592. },
  9593. {
  9594. .capture = {
  9595. .stream_name = "Quinary TDM0 Capture",
  9596. .aif_name = "QUIN_TDM_TX_0",
  9597. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9598. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9599. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9600. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9601. SNDRV_PCM_FMTBIT_S24_LE |
  9602. SNDRV_PCM_FMTBIT_S32_LE,
  9603. .channels_min = 1,
  9604. .channels_max = 8,
  9605. .rate_min = 8000,
  9606. .rate_max = 352800,
  9607. },
  9608. .name = "QUIN_TDM_TX_0",
  9609. .ops = &msm_dai_q6_tdm_ops,
  9610. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  9611. .probe = msm_dai_q6_dai_tdm_probe,
  9612. .remove = msm_dai_q6_dai_tdm_remove,
  9613. },
  9614. {
  9615. .capture = {
  9616. .stream_name = "Quinary TDM1 Capture",
  9617. .aif_name = "QUIN_TDM_TX_1",
  9618. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9619. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9620. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9621. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9622. SNDRV_PCM_FMTBIT_S24_LE |
  9623. SNDRV_PCM_FMTBIT_S32_LE,
  9624. .channels_min = 1,
  9625. .channels_max = 8,
  9626. .rate_min = 8000,
  9627. .rate_max = 352800,
  9628. },
  9629. .name = "QUIN_TDM_TX_1",
  9630. .ops = &msm_dai_q6_tdm_ops,
  9631. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  9632. .probe = msm_dai_q6_dai_tdm_probe,
  9633. .remove = msm_dai_q6_dai_tdm_remove,
  9634. },
  9635. {
  9636. .capture = {
  9637. .stream_name = "Quinary TDM2 Capture",
  9638. .aif_name = "QUIN_TDM_TX_2",
  9639. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9640. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9641. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9642. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9643. SNDRV_PCM_FMTBIT_S24_LE |
  9644. SNDRV_PCM_FMTBIT_S32_LE,
  9645. .channels_min = 1,
  9646. .channels_max = 8,
  9647. .rate_min = 8000,
  9648. .rate_max = 352800,
  9649. },
  9650. .name = "QUIN_TDM_TX_2",
  9651. .ops = &msm_dai_q6_tdm_ops,
  9652. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  9653. .probe = msm_dai_q6_dai_tdm_probe,
  9654. .remove = msm_dai_q6_dai_tdm_remove,
  9655. },
  9656. {
  9657. .capture = {
  9658. .stream_name = "Quinary TDM3 Capture",
  9659. .aif_name = "QUIN_TDM_TX_3",
  9660. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9661. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9662. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9663. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9664. SNDRV_PCM_FMTBIT_S24_LE |
  9665. SNDRV_PCM_FMTBIT_S32_LE,
  9666. .channels_min = 1,
  9667. .channels_max = 8,
  9668. .rate_min = 8000,
  9669. .rate_max = 352800,
  9670. },
  9671. .name = "QUIN_TDM_TX_3",
  9672. .ops = &msm_dai_q6_tdm_ops,
  9673. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  9674. .probe = msm_dai_q6_dai_tdm_probe,
  9675. .remove = msm_dai_q6_dai_tdm_remove,
  9676. },
  9677. {
  9678. .capture = {
  9679. .stream_name = "Quinary TDM4 Capture",
  9680. .aif_name = "QUIN_TDM_TX_4",
  9681. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9682. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9683. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9684. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9685. SNDRV_PCM_FMTBIT_S24_LE |
  9686. SNDRV_PCM_FMTBIT_S32_LE,
  9687. .channels_min = 1,
  9688. .channels_max = 8,
  9689. .rate_min = 8000,
  9690. .rate_max = 352800,
  9691. },
  9692. .name = "QUIN_TDM_TX_4",
  9693. .ops = &msm_dai_q6_tdm_ops,
  9694. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  9695. .probe = msm_dai_q6_dai_tdm_probe,
  9696. .remove = msm_dai_q6_dai_tdm_remove,
  9697. },
  9698. {
  9699. .capture = {
  9700. .stream_name = "Quinary TDM5 Capture",
  9701. .aif_name = "QUIN_TDM_TX_5",
  9702. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9703. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9704. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9705. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9706. SNDRV_PCM_FMTBIT_S24_LE |
  9707. SNDRV_PCM_FMTBIT_S32_LE,
  9708. .channels_min = 1,
  9709. .channels_max = 8,
  9710. .rate_min = 8000,
  9711. .rate_max = 352800,
  9712. },
  9713. .name = "QUIN_TDM_TX_5",
  9714. .ops = &msm_dai_q6_tdm_ops,
  9715. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  9716. .probe = msm_dai_q6_dai_tdm_probe,
  9717. .remove = msm_dai_q6_dai_tdm_remove,
  9718. },
  9719. {
  9720. .capture = {
  9721. .stream_name = "Quinary TDM6 Capture",
  9722. .aif_name = "QUIN_TDM_TX_6",
  9723. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9724. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9725. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9726. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9727. SNDRV_PCM_FMTBIT_S24_LE |
  9728. SNDRV_PCM_FMTBIT_S32_LE,
  9729. .channels_min = 1,
  9730. .channels_max = 8,
  9731. .rate_min = 8000,
  9732. .rate_max = 352800,
  9733. },
  9734. .name = "QUIN_TDM_TX_6",
  9735. .ops = &msm_dai_q6_tdm_ops,
  9736. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  9737. .probe = msm_dai_q6_dai_tdm_probe,
  9738. .remove = msm_dai_q6_dai_tdm_remove,
  9739. },
  9740. {
  9741. .capture = {
  9742. .stream_name = "Quinary TDM7 Capture",
  9743. .aif_name = "QUIN_TDM_TX_7",
  9744. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9745. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9746. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9747. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9748. SNDRV_PCM_FMTBIT_S24_LE |
  9749. SNDRV_PCM_FMTBIT_S32_LE,
  9750. .channels_min = 1,
  9751. .channels_max = 8,
  9752. .rate_min = 8000,
  9753. .rate_max = 352800,
  9754. },
  9755. .name = "QUIN_TDM_TX_7",
  9756. .ops = &msm_dai_q6_tdm_ops,
  9757. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  9758. .probe = msm_dai_q6_dai_tdm_probe,
  9759. .remove = msm_dai_q6_dai_tdm_remove,
  9760. },
  9761. {
  9762. .playback = {
  9763. .stream_name = "Senary TDM0 Playback",
  9764. .aif_name = "SEN_TDM_RX_0",
  9765. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9766. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9767. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9768. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9769. SNDRV_PCM_FMTBIT_S24_LE |
  9770. SNDRV_PCM_FMTBIT_S32_LE,
  9771. .channels_min = 1,
  9772. .channels_max = 8,
  9773. .rate_min = 8000,
  9774. .rate_max = 352800,
  9775. },
  9776. .name = "SEN_TDM_RX_0",
  9777. .ops = &msm_dai_q6_tdm_ops,
  9778. .id = AFE_PORT_ID_SENARY_TDM_RX,
  9779. .probe = msm_dai_q6_dai_tdm_probe,
  9780. .remove = msm_dai_q6_dai_tdm_remove,
  9781. },
  9782. {
  9783. .playback = {
  9784. .stream_name = "Senary TDM1 Playback",
  9785. .aif_name = "SEN_TDM_RX_1",
  9786. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9787. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9788. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9789. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9790. SNDRV_PCM_FMTBIT_S24_LE |
  9791. SNDRV_PCM_FMTBIT_S32_LE,
  9792. .channels_min = 1,
  9793. .channels_max = 8,
  9794. .rate_min = 8000,
  9795. .rate_max = 352800,
  9796. },
  9797. .name = "SEN_TDM_RX_1",
  9798. .ops = &msm_dai_q6_tdm_ops,
  9799. .id = AFE_PORT_ID_SENARY_TDM_RX_1,
  9800. .probe = msm_dai_q6_dai_tdm_probe,
  9801. .remove = msm_dai_q6_dai_tdm_remove,
  9802. },
  9803. {
  9804. .playback = {
  9805. .stream_name = "Senary TDM2 Playback",
  9806. .aif_name = "SEN_TDM_RX_2",
  9807. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9808. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9809. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9810. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9811. SNDRV_PCM_FMTBIT_S24_LE |
  9812. SNDRV_PCM_FMTBIT_S32_LE,
  9813. .channels_min = 1,
  9814. .channels_max = 8,
  9815. .rate_min = 8000,
  9816. .rate_max = 352800,
  9817. },
  9818. .name = "SEN_TDM_RX_2",
  9819. .ops = &msm_dai_q6_tdm_ops,
  9820. .id = AFE_PORT_ID_SENARY_TDM_RX_2,
  9821. .probe = msm_dai_q6_dai_tdm_probe,
  9822. .remove = msm_dai_q6_dai_tdm_remove,
  9823. },
  9824. {
  9825. .playback = {
  9826. .stream_name = "Senary TDM3 Playback",
  9827. .aif_name = "SEN_TDM_RX_3",
  9828. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9829. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9830. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9831. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9832. SNDRV_PCM_FMTBIT_S24_LE |
  9833. SNDRV_PCM_FMTBIT_S32_LE,
  9834. .channels_min = 1,
  9835. .channels_max = 8,
  9836. .rate_min = 8000,
  9837. .rate_max = 352800,
  9838. },
  9839. .name = "SEN_TDM_RX_3",
  9840. .ops = &msm_dai_q6_tdm_ops,
  9841. .id = AFE_PORT_ID_SENARY_TDM_RX_3,
  9842. .probe = msm_dai_q6_dai_tdm_probe,
  9843. .remove = msm_dai_q6_dai_tdm_remove,
  9844. },
  9845. {
  9846. .playback = {
  9847. .stream_name = "Senary TDM4 Playback",
  9848. .aif_name = "SEN_TDM_RX_4",
  9849. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9850. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9851. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9852. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9853. SNDRV_PCM_FMTBIT_S24_LE |
  9854. SNDRV_PCM_FMTBIT_S32_LE,
  9855. .channels_min = 1,
  9856. .channels_max = 8,
  9857. .rate_min = 8000,
  9858. .rate_max = 352800,
  9859. },
  9860. .name = "SEN_TDM_RX_4",
  9861. .ops = &msm_dai_q6_tdm_ops,
  9862. .id = AFE_PORT_ID_SENARY_TDM_RX_4,
  9863. .probe = msm_dai_q6_dai_tdm_probe,
  9864. .remove = msm_dai_q6_dai_tdm_remove,
  9865. },
  9866. {
  9867. .playback = {
  9868. .stream_name = "Senary TDM5 Playback",
  9869. .aif_name = "SEN_TDM_RX_5",
  9870. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9871. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9872. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9873. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9874. SNDRV_PCM_FMTBIT_S24_LE |
  9875. SNDRV_PCM_FMTBIT_S32_LE,
  9876. .channels_min = 1,
  9877. .channels_max = 8,
  9878. .rate_min = 8000,
  9879. .rate_max = 352800,
  9880. },
  9881. .name = "SEN_TDM_RX_5",
  9882. .ops = &msm_dai_q6_tdm_ops,
  9883. .id = AFE_PORT_ID_SENARY_TDM_RX_5,
  9884. .probe = msm_dai_q6_dai_tdm_probe,
  9885. .remove = msm_dai_q6_dai_tdm_remove,
  9886. },
  9887. {
  9888. .playback = {
  9889. .stream_name = "Senary TDM6 Playback",
  9890. .aif_name = "SEN_TDM_RX_6",
  9891. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9892. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9893. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9894. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9895. SNDRV_PCM_FMTBIT_S24_LE |
  9896. SNDRV_PCM_FMTBIT_S32_LE,
  9897. .channels_min = 1,
  9898. .channels_max = 8,
  9899. .rate_min = 8000,
  9900. .rate_max = 352800,
  9901. },
  9902. .name = "SEN_TDM_RX_6",
  9903. .ops = &msm_dai_q6_tdm_ops,
  9904. .id = AFE_PORT_ID_SENARY_TDM_RX_6,
  9905. .probe = msm_dai_q6_dai_tdm_probe,
  9906. .remove = msm_dai_q6_dai_tdm_remove,
  9907. },
  9908. {
  9909. .playback = {
  9910. .stream_name = "Senary TDM7 Playback",
  9911. .aif_name = "SEN_TDM_RX_7",
  9912. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9913. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9914. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9915. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9916. SNDRV_PCM_FMTBIT_S24_LE |
  9917. SNDRV_PCM_FMTBIT_S32_LE,
  9918. .channels_min = 1,
  9919. .channels_max = 8,
  9920. .rate_min = 8000,
  9921. .rate_max = 352800,
  9922. },
  9923. .name = "SEN_TDM_RX_7",
  9924. .ops = &msm_dai_q6_tdm_ops,
  9925. .id = AFE_PORT_ID_SENARY_TDM_RX_7,
  9926. .probe = msm_dai_q6_dai_tdm_probe,
  9927. .remove = msm_dai_q6_dai_tdm_remove,
  9928. },
  9929. {
  9930. .capture = {
  9931. .stream_name = "Senary TDM0 Capture",
  9932. .aif_name = "SEN_TDM_TX_0",
  9933. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9934. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9935. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9936. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9937. SNDRV_PCM_FMTBIT_S24_LE |
  9938. SNDRV_PCM_FMTBIT_S32_LE,
  9939. .channels_min = 1,
  9940. .channels_max = 8,
  9941. .rate_min = 8000,
  9942. .rate_max = 352800,
  9943. },
  9944. .name = "SEN_TDM_TX_0",
  9945. .ops = &msm_dai_q6_tdm_ops,
  9946. .id = AFE_PORT_ID_SENARY_TDM_TX,
  9947. .probe = msm_dai_q6_dai_tdm_probe,
  9948. .remove = msm_dai_q6_dai_tdm_remove,
  9949. },
  9950. {
  9951. .capture = {
  9952. .stream_name = "Senary TDM1 Capture",
  9953. .aif_name = "SEN_TDM_TX_1",
  9954. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9955. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9956. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9957. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9958. SNDRV_PCM_FMTBIT_S24_LE |
  9959. SNDRV_PCM_FMTBIT_S32_LE,
  9960. .channels_min = 1,
  9961. .channels_max = 8,
  9962. .rate_min = 8000,
  9963. .rate_max = 352800,
  9964. },
  9965. .name = "SEN_TDM_TX_1",
  9966. .ops = &msm_dai_q6_tdm_ops,
  9967. .id = AFE_PORT_ID_SENARY_TDM_TX_1,
  9968. .probe = msm_dai_q6_dai_tdm_probe,
  9969. .remove = msm_dai_q6_dai_tdm_remove,
  9970. },
  9971. {
  9972. .capture = {
  9973. .stream_name = "Senary TDM2 Capture",
  9974. .aif_name = "SEN_TDM_TX_2",
  9975. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9976. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9977. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9978. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9979. SNDRV_PCM_FMTBIT_S24_LE |
  9980. SNDRV_PCM_FMTBIT_S32_LE,
  9981. .channels_min = 1,
  9982. .channels_max = 8,
  9983. .rate_min = 8000,
  9984. .rate_max = 352800,
  9985. },
  9986. .name = "SEN_TDM_TX_2",
  9987. .ops = &msm_dai_q6_tdm_ops,
  9988. .id = AFE_PORT_ID_SENARY_TDM_TX_2,
  9989. .probe = msm_dai_q6_dai_tdm_probe,
  9990. .remove = msm_dai_q6_dai_tdm_remove,
  9991. },
  9992. {
  9993. .capture = {
  9994. .stream_name = "Senary TDM3 Capture",
  9995. .aif_name = "SEN_TDM_TX_3",
  9996. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9997. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9998. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9999. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10000. SNDRV_PCM_FMTBIT_S24_LE |
  10001. SNDRV_PCM_FMTBIT_S32_LE,
  10002. .channels_min = 1,
  10003. .channels_max = 8,
  10004. .rate_min = 8000,
  10005. .rate_max = 352800,
  10006. },
  10007. .name = "SEN_TDM_TX_3",
  10008. .ops = &msm_dai_q6_tdm_ops,
  10009. .id = AFE_PORT_ID_SENARY_TDM_TX_3,
  10010. .probe = msm_dai_q6_dai_tdm_probe,
  10011. .remove = msm_dai_q6_dai_tdm_remove,
  10012. },
  10013. {
  10014. .capture = {
  10015. .stream_name = "Senary TDM4 Capture",
  10016. .aif_name = "SEN_TDM_TX_4",
  10017. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10018. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10019. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10020. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10021. SNDRV_PCM_FMTBIT_S24_LE |
  10022. SNDRV_PCM_FMTBIT_S32_LE,
  10023. .channels_min = 1,
  10024. .channels_max = 8,
  10025. .rate_min = 8000,
  10026. .rate_max = 352800,
  10027. },
  10028. .name = "SEN_TDM_TX_4",
  10029. .ops = &msm_dai_q6_tdm_ops,
  10030. .id = AFE_PORT_ID_SENARY_TDM_TX_4,
  10031. .probe = msm_dai_q6_dai_tdm_probe,
  10032. .remove = msm_dai_q6_dai_tdm_remove,
  10033. },
  10034. {
  10035. .capture = {
  10036. .stream_name = "Senary TDM5 Capture",
  10037. .aif_name = "SEN_TDM_TX_5",
  10038. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10039. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10040. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10041. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10042. SNDRV_PCM_FMTBIT_S24_LE |
  10043. SNDRV_PCM_FMTBIT_S32_LE,
  10044. .channels_min = 1,
  10045. .channels_max = 8,
  10046. .rate_min = 8000,
  10047. .rate_max = 352800,
  10048. },
  10049. .name = "SEN_TDM_TX_5",
  10050. .ops = &msm_dai_q6_tdm_ops,
  10051. .id = AFE_PORT_ID_SENARY_TDM_TX_5,
  10052. .probe = msm_dai_q6_dai_tdm_probe,
  10053. .remove = msm_dai_q6_dai_tdm_remove,
  10054. },
  10055. {
  10056. .capture = {
  10057. .stream_name = "Senary TDM6 Capture",
  10058. .aif_name = "SEN_TDM_TX_6",
  10059. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10060. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10061. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10062. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10063. SNDRV_PCM_FMTBIT_S24_LE |
  10064. SNDRV_PCM_FMTBIT_S32_LE,
  10065. .channels_min = 1,
  10066. .channels_max = 8,
  10067. .rate_min = 8000,
  10068. .rate_max = 352800,
  10069. },
  10070. .name = "SEN_TDM_TX_6",
  10071. .ops = &msm_dai_q6_tdm_ops,
  10072. .id = AFE_PORT_ID_SENARY_TDM_TX_6,
  10073. .probe = msm_dai_q6_dai_tdm_probe,
  10074. .remove = msm_dai_q6_dai_tdm_remove,
  10075. },
  10076. {
  10077. .capture = {
  10078. .stream_name = "Senary TDM7 Capture",
  10079. .aif_name = "SEN_TDM_TX_7",
  10080. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10081. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10082. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10083. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10084. SNDRV_PCM_FMTBIT_S24_LE |
  10085. SNDRV_PCM_FMTBIT_S32_LE,
  10086. .channels_min = 1,
  10087. .channels_max = 8,
  10088. .rate_min = 8000,
  10089. .rate_max = 352800,
  10090. },
  10091. .name = "SEN_TDM_TX_7",
  10092. .ops = &msm_dai_q6_tdm_ops,
  10093. .id = AFE_PORT_ID_SENARY_TDM_TX_7,
  10094. .probe = msm_dai_q6_dai_tdm_probe,
  10095. .remove = msm_dai_q6_dai_tdm_remove,
  10096. },
  10097. };
  10098. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  10099. .name = "msm-dai-q6-tdm",
  10100. };
  10101. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  10102. {
  10103. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  10104. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  10105. int rc = 0;
  10106. u32 tdm_dev_id = 0;
  10107. int port_idx = 0;
  10108. struct device_node *tdm_parent_node = NULL;
  10109. /* retrieve device/afe id */
  10110. rc = of_property_read_u32(pdev->dev.of_node,
  10111. "qcom,msm-cpudai-tdm-dev-id",
  10112. &tdm_dev_id);
  10113. if (rc) {
  10114. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  10115. __func__);
  10116. goto rtn;
  10117. }
  10118. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  10119. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  10120. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  10121. __func__, tdm_dev_id);
  10122. rc = -ENXIO;
  10123. goto rtn;
  10124. }
  10125. pdev->id = tdm_dev_id;
  10126. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  10127. GFP_KERNEL);
  10128. if (!dai_data) {
  10129. rc = -ENOMEM;
  10130. dev_err(&pdev->dev,
  10131. "%s Failed to allocate memory for tdm dai_data\n",
  10132. __func__);
  10133. goto rtn;
  10134. }
  10135. memset(dai_data, 0, sizeof(*dai_data));
  10136. rc = of_property_read_u32(pdev->dev.of_node,
  10137. "qcom,msm-dai-is-island-supported",
  10138. &dai_data->is_island_dai);
  10139. if (rc)
  10140. dev_dbg(&pdev->dev, "island supported entry not found\n");
  10141. /* TDM CFG */
  10142. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  10143. rc = of_property_read_u32(tdm_parent_node,
  10144. "qcom,msm-cpudai-tdm-sync-mode",
  10145. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  10146. if (rc) {
  10147. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  10148. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  10149. goto free_dai_data;
  10150. }
  10151. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  10152. __func__, dai_data->port_cfg.tdm.sync_mode);
  10153. rc = of_property_read_u32(tdm_parent_node,
  10154. "qcom,msm-cpudai-tdm-sync-src",
  10155. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  10156. if (rc) {
  10157. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  10158. __func__, "qcom,msm-cpudai-tdm-sync-src");
  10159. goto free_dai_data;
  10160. }
  10161. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  10162. __func__, dai_data->port_cfg.tdm.sync_src);
  10163. rc = of_property_read_u32(tdm_parent_node,
  10164. "qcom,msm-cpudai-tdm-data-out",
  10165. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  10166. if (rc) {
  10167. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  10168. __func__, "qcom,msm-cpudai-tdm-data-out");
  10169. goto free_dai_data;
  10170. }
  10171. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  10172. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  10173. rc = of_property_read_u32(tdm_parent_node,
  10174. "qcom,msm-cpudai-tdm-invert-sync",
  10175. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  10176. if (rc) {
  10177. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  10178. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  10179. goto free_dai_data;
  10180. }
  10181. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  10182. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  10183. rc = of_property_read_u32(tdm_parent_node,
  10184. "qcom,msm-cpudai-tdm-data-delay",
  10185. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  10186. if (rc) {
  10187. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  10188. __func__, "qcom,msm-cpudai-tdm-data-delay");
  10189. goto free_dai_data;
  10190. }
  10191. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  10192. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  10193. /* TDM CFG -- set default */
  10194. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  10195. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  10196. AFE_API_VERSION_TDM_CONFIG;
  10197. /* TDM SLOT MAPPING CFG */
  10198. rc = of_property_read_u32(pdev->dev.of_node,
  10199. "qcom,msm-cpudai-tdm-data-align",
  10200. &dai_data->port_cfg.slot_mapping.data_align_type);
  10201. if (rc) {
  10202. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  10203. __func__,
  10204. "qcom,msm-cpudai-tdm-data-align");
  10205. goto free_dai_data;
  10206. }
  10207. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  10208. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  10209. /* TDM SLOT MAPPING CFG -- set default */
  10210. dai_data->port_cfg.slot_mapping.minor_version =
  10211. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  10212. /* CUSTOM TDM HEADER CFG */
  10213. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  10214. if (of_find_property(pdev->dev.of_node,
  10215. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  10216. of_find_property(pdev->dev.of_node,
  10217. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  10218. of_find_property(pdev->dev.of_node,
  10219. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  10220. /* if the property exist */
  10221. rc = of_property_read_u32(pdev->dev.of_node,
  10222. "qcom,msm-cpudai-tdm-header-start-offset",
  10223. (u32 *)&custom_tdm_header->start_offset);
  10224. if (rc) {
  10225. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  10226. __func__,
  10227. "qcom,msm-cpudai-tdm-header-start-offset");
  10228. goto free_dai_data;
  10229. }
  10230. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  10231. __func__, custom_tdm_header->start_offset);
  10232. rc = of_property_read_u32(pdev->dev.of_node,
  10233. "qcom,msm-cpudai-tdm-header-width",
  10234. (u32 *)&custom_tdm_header->header_width);
  10235. if (rc) {
  10236. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  10237. __func__, "qcom,msm-cpudai-tdm-header-width");
  10238. goto free_dai_data;
  10239. }
  10240. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  10241. __func__, custom_tdm_header->header_width);
  10242. rc = of_property_read_u32(pdev->dev.of_node,
  10243. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  10244. (u32 *)&custom_tdm_header->num_frame_repeat);
  10245. if (rc) {
  10246. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  10247. __func__,
  10248. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  10249. goto free_dai_data;
  10250. }
  10251. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  10252. __func__, custom_tdm_header->num_frame_repeat);
  10253. /* CUSTOM TDM HEADER CFG -- set default */
  10254. custom_tdm_header->minor_version =
  10255. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  10256. custom_tdm_header->header_type =
  10257. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  10258. } else {
  10259. /* CUSTOM TDM HEADER CFG -- set default */
  10260. custom_tdm_header->header_type =
  10261. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  10262. /* proceed with probe */
  10263. }
  10264. /* copy static clk per parent node */
  10265. dai_data->clk_set = tdm_clk_set;
  10266. /* copy static group cfg per parent node */
  10267. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  10268. /* copy static num group ports per parent node */
  10269. dai_data->num_group_ports = num_tdm_group_ports;
  10270. dai_data->lane_cfg = tdm_lane_cfg;
  10271. dev_set_drvdata(&pdev->dev, dai_data);
  10272. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  10273. if (port_idx < 0) {
  10274. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  10275. __func__, tdm_dev_id);
  10276. rc = -EINVAL;
  10277. goto free_dai_data;
  10278. }
  10279. rc = snd_soc_register_component(&pdev->dev,
  10280. &msm_q6_tdm_dai_component,
  10281. &msm_dai_q6_tdm_dai[port_idx], 1);
  10282. if (rc) {
  10283. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  10284. __func__, tdm_dev_id, rc);
  10285. goto err_register;
  10286. }
  10287. return 0;
  10288. err_register:
  10289. free_dai_data:
  10290. kfree(dai_data);
  10291. rtn:
  10292. return rc;
  10293. }
  10294. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  10295. {
  10296. struct msm_dai_q6_tdm_dai_data *dai_data =
  10297. dev_get_drvdata(&pdev->dev);
  10298. snd_soc_unregister_component(&pdev->dev);
  10299. kfree(dai_data);
  10300. return 0;
  10301. }
  10302. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  10303. { .compatible = "qcom,msm-dai-q6-tdm", },
  10304. {}
  10305. };
  10306. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  10307. static struct platform_driver msm_dai_q6_tdm_driver = {
  10308. .probe = msm_dai_q6_tdm_dev_probe,
  10309. .remove = msm_dai_q6_tdm_dev_remove,
  10310. .driver = {
  10311. .name = "msm-dai-q6-tdm",
  10312. .owner = THIS_MODULE,
  10313. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  10314. .suppress_bind_attrs = true,
  10315. },
  10316. };
  10317. static int msm_dai_q6_cdc_dma_format_put(struct snd_kcontrol *kcontrol,
  10318. struct snd_ctl_elem_value *ucontrol)
  10319. {
  10320. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  10321. int value = ucontrol->value.integer.value[0];
  10322. dai_data->port_config.cdc_dma.data_format = value;
  10323. pr_debug("%s: format = %d\n", __func__, value);
  10324. return 0;
  10325. }
  10326. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  10327. struct snd_ctl_elem_value *ucontrol)
  10328. {
  10329. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  10330. ucontrol->value.integer.value[0] =
  10331. dai_data->port_config.cdc_dma.data_format;
  10332. return 0;
  10333. }
  10334. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  10335. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  10336. msm_dai_q6_cdc_dma_format_get,
  10337. msm_dai_q6_cdc_dma_format_put),
  10338. };
  10339. /* SOC probe for codec DMA interface */
  10340. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  10341. {
  10342. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  10343. int rc = 0;
  10344. if (!dai) {
  10345. pr_err("%s: Invalid params dai\n", __func__);
  10346. return -EINVAL;
  10347. }
  10348. if (!dai->dev) {
  10349. pr_err("%s: Invalid params dai dev\n", __func__);
  10350. return -EINVAL;
  10351. }
  10352. msm_dai_q6_set_dai_id(dai);
  10353. dai_data = dev_get_drvdata(dai->dev);
  10354. switch (dai->id) {
  10355. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  10356. rc = snd_ctl_add(dai->component->card->snd_card,
  10357. snd_ctl_new1(&cdc_dma_config_controls[0],
  10358. dai_data));
  10359. break;
  10360. default:
  10361. break;
  10362. }
  10363. if (rc < 0)
  10364. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  10365. __func__, dai->name);
  10366. if (dai_data->is_island_dai)
  10367. rc = msm_dai_q6_add_island_mx_ctls(
  10368. dai->component->card->snd_card,
  10369. dai->name, dai->id,
  10370. (void *)dai_data);
  10371. rc = msm_dai_q6_dai_add_route(dai);
  10372. return rc;
  10373. }
  10374. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  10375. {
  10376. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10377. dev_get_drvdata(dai->dev);
  10378. int rc = 0;
  10379. /* If AFE port is still up, close it */
  10380. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  10381. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  10382. dai->id);
  10383. rc = afe_close(dai->id); /* can block */
  10384. if (rc < 0)
  10385. dev_err(dai->dev, "fail to close AFE port\n");
  10386. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  10387. }
  10388. return rc;
  10389. }
  10390. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  10391. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  10392. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  10393. {
  10394. int rc = 0;
  10395. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10396. dev_get_drvdata(dai->dev);
  10397. unsigned int ch_mask = 0, ch_num = 0;
  10398. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  10399. switch (dai->id) {
  10400. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  10401. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  10402. case AFE_PORT_ID_RX_CODEC_DMA_RX_0:
  10403. case AFE_PORT_ID_RX_CODEC_DMA_RX_1:
  10404. case AFE_PORT_ID_RX_CODEC_DMA_RX_2:
  10405. case AFE_PORT_ID_RX_CODEC_DMA_RX_3:
  10406. case AFE_PORT_ID_RX_CODEC_DMA_RX_4:
  10407. case AFE_PORT_ID_RX_CODEC_DMA_RX_5:
  10408. case AFE_PORT_ID_RX_CODEC_DMA_RX_6:
  10409. case AFE_PORT_ID_RX_CODEC_DMA_RX_7:
  10410. if (!rx_ch_mask) {
  10411. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  10412. return -EINVAL;
  10413. }
  10414. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  10415. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  10416. __func__, rx_num_ch);
  10417. return -EINVAL;
  10418. }
  10419. ch_mask = *rx_ch_mask;
  10420. ch_num = rx_num_ch;
  10421. break;
  10422. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  10423. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  10424. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  10425. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  10426. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  10427. case AFE_PORT_ID_TX_CODEC_DMA_TX_0:
  10428. case AFE_PORT_ID_TX_CODEC_DMA_TX_1:
  10429. case AFE_PORT_ID_TX_CODEC_DMA_TX_2:
  10430. case AFE_PORT_ID_TX_CODEC_DMA_TX_3:
  10431. case AFE_PORT_ID_TX_CODEC_DMA_TX_4:
  10432. case AFE_PORT_ID_TX_CODEC_DMA_TX_5:
  10433. if (!tx_ch_mask) {
  10434. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  10435. return -EINVAL;
  10436. }
  10437. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  10438. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  10439. __func__, tx_num_ch);
  10440. return -EINVAL;
  10441. }
  10442. ch_mask = *tx_ch_mask;
  10443. ch_num = tx_num_ch;
  10444. break;
  10445. default:
  10446. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  10447. return -EINVAL;
  10448. }
  10449. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  10450. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  10451. dai->id, ch_num, ch_mask);
  10452. return rc;
  10453. }
  10454. static int msm_dai_q6_cdc_dma_hw_params(
  10455. struct snd_pcm_substream *substream,
  10456. struct snd_pcm_hw_params *params,
  10457. struct snd_soc_dai *dai)
  10458. {
  10459. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10460. dev_get_drvdata(dai->dev);
  10461. switch (params_format(params)) {
  10462. case SNDRV_PCM_FORMAT_S16_LE:
  10463. case SNDRV_PCM_FORMAT_SPECIAL:
  10464. dai_data->port_config.cdc_dma.bit_width = 16;
  10465. break;
  10466. case SNDRV_PCM_FORMAT_S24_LE:
  10467. case SNDRV_PCM_FORMAT_S24_3LE:
  10468. dai_data->port_config.cdc_dma.bit_width = 24;
  10469. break;
  10470. case SNDRV_PCM_FORMAT_S32_LE:
  10471. dai_data->port_config.cdc_dma.bit_width = 32;
  10472. break;
  10473. default:
  10474. dev_err(dai->dev, "%s: format %d\n",
  10475. __func__, params_format(params));
  10476. return -EINVAL;
  10477. }
  10478. dai_data->rate = params_rate(params);
  10479. dai_data->channels = params_channels(params);
  10480. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  10481. AFE_API_VERSION_CODEC_DMA_CONFIG;
  10482. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  10483. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  10484. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  10485. "num_channel %hu sample_rate %d\n", __func__,
  10486. dai_data->port_config.cdc_dma.bit_width,
  10487. dai_data->port_config.cdc_dma.data_format,
  10488. dai_data->port_config.cdc_dma.num_channels,
  10489. dai_data->rate);
  10490. return 0;
  10491. }
  10492. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  10493. struct snd_soc_dai *dai)
  10494. {
  10495. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  10496. dev_get_drvdata(dai->dev);
  10497. int rc = 0;
  10498. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  10499. if ((dai->id == AFE_PORT_ID_WSA_CODEC_DMA_TX_0) &&
  10500. (dai_data->port_config.cdc_dma.data_format == 1))
  10501. dai_data->port_config.cdc_dma.data_format =
  10502. AFE_LINEAR_PCM_DATA_PACKED_16BIT;
  10503. rc = afe_port_start(dai->id, &dai_data->port_config,
  10504. dai_data->rate);
  10505. if (rc < 0)
  10506. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  10507. dai->id);
  10508. else
  10509. set_bit(STATUS_PORT_STARTED,
  10510. dai_data->status_mask);
  10511. }
  10512. return rc;
  10513. }
  10514. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  10515. struct snd_soc_dai *dai)
  10516. {
  10517. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  10518. int rc = 0;
  10519. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  10520. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  10521. dai->id);
  10522. rc = afe_close(dai->id); /* can block */
  10523. if (rc < 0)
  10524. dev_err(dai->dev, "fail to close AFE port\n");
  10525. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  10526. *dai_data->status_mask);
  10527. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  10528. }
  10529. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  10530. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  10531. }
  10532. /* all ports with same WSA requirement can use this digital mute API */
  10533. static int msm_dai_q6_spk_digital_mute(struct snd_soc_dai *dai,
  10534. int mute)
  10535. {
  10536. int port_id = dai->id;
  10537. if (mute)
  10538. afe_get_sp_xt_logging_data(port_id);
  10539. return 0;
  10540. }
  10541. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  10542. .prepare = msm_dai_q6_cdc_dma_prepare,
  10543. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  10544. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  10545. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  10546. };
  10547. static struct snd_soc_dai_ops msm_dai_q6_cdc_wsa_dma_ops = {
  10548. .prepare = msm_dai_q6_cdc_dma_prepare,
  10549. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  10550. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  10551. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  10552. .digital_mute = msm_dai_q6_spk_digital_mute,
  10553. };
  10554. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  10555. {
  10556. .playback = {
  10557. .stream_name = "WSA CDC DMA0 Playback",
  10558. .aif_name = "WSA_CDC_DMA_RX_0",
  10559. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10560. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10561. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10562. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10563. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10564. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10565. SNDRV_PCM_RATE_384000,
  10566. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10567. SNDRV_PCM_FMTBIT_S24_LE |
  10568. SNDRV_PCM_FMTBIT_S24_3LE |
  10569. SNDRV_PCM_FMTBIT_S32_LE,
  10570. .channels_min = 1,
  10571. .channels_max = 4,
  10572. .rate_min = 8000,
  10573. .rate_max = 384000,
  10574. },
  10575. .name = "WSA_CDC_DMA_RX_0",
  10576. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  10577. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  10578. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10579. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10580. },
  10581. {
  10582. .capture = {
  10583. .stream_name = "WSA CDC DMA0 Capture",
  10584. .aif_name = "WSA_CDC_DMA_TX_0",
  10585. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10586. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10587. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10588. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10589. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10590. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10591. SNDRV_PCM_RATE_384000,
  10592. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10593. SNDRV_PCM_FMTBIT_S24_LE |
  10594. SNDRV_PCM_FMTBIT_S24_3LE |
  10595. SNDRV_PCM_FMTBIT_S32_LE,
  10596. .channels_min = 1,
  10597. .channels_max = 4,
  10598. .rate_min = 8000,
  10599. .rate_max = 384000,
  10600. },
  10601. .name = "WSA_CDC_DMA_TX_0",
  10602. .ops = &msm_dai_q6_cdc_dma_ops,
  10603. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  10604. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10605. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10606. },
  10607. {
  10608. .playback = {
  10609. .stream_name = "WSA CDC DMA1 Playback",
  10610. .aif_name = "WSA_CDC_DMA_RX_1",
  10611. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10612. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10613. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10614. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10615. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10616. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10617. SNDRV_PCM_RATE_384000,
  10618. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10619. SNDRV_PCM_FMTBIT_S24_LE |
  10620. SNDRV_PCM_FMTBIT_S24_3LE |
  10621. SNDRV_PCM_FMTBIT_S32_LE,
  10622. .channels_min = 1,
  10623. .channels_max = 2,
  10624. .rate_min = 8000,
  10625. .rate_max = 384000,
  10626. },
  10627. .name = "WSA_CDC_DMA_RX_1",
  10628. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  10629. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  10630. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10631. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10632. },
  10633. {
  10634. .capture = {
  10635. .stream_name = "WSA CDC DMA1 Capture",
  10636. .aif_name = "WSA_CDC_DMA_TX_1",
  10637. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10638. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10639. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10640. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10641. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10642. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10643. SNDRV_PCM_RATE_384000,
  10644. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10645. SNDRV_PCM_FMTBIT_S24_LE |
  10646. SNDRV_PCM_FMTBIT_S24_3LE |
  10647. SNDRV_PCM_FMTBIT_S32_LE,
  10648. .channels_min = 1,
  10649. .channels_max = 2,
  10650. .rate_min = 8000,
  10651. .rate_max = 384000,
  10652. },
  10653. .name = "WSA_CDC_DMA_TX_1",
  10654. .ops = &msm_dai_q6_cdc_dma_ops,
  10655. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  10656. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10657. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10658. },
  10659. {
  10660. .capture = {
  10661. .stream_name = "WSA CDC DMA2 Capture",
  10662. .aif_name = "WSA_CDC_DMA_TX_2",
  10663. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10664. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10665. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10666. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10667. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10668. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10669. SNDRV_PCM_RATE_384000,
  10670. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10671. SNDRV_PCM_FMTBIT_S24_LE |
  10672. SNDRV_PCM_FMTBIT_S24_3LE |
  10673. SNDRV_PCM_FMTBIT_S32_LE,
  10674. .channels_min = 1,
  10675. .channels_max = 1,
  10676. .rate_min = 8000,
  10677. .rate_max = 384000,
  10678. },
  10679. .name = "WSA_CDC_DMA_TX_2",
  10680. .ops = &msm_dai_q6_cdc_dma_ops,
  10681. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  10682. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10683. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10684. },
  10685. {
  10686. .capture = {
  10687. .stream_name = "VA CDC DMA0 Capture",
  10688. .aif_name = "VA_CDC_DMA_TX_0",
  10689. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10690. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10691. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10692. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10693. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10694. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10695. SNDRV_PCM_RATE_384000,
  10696. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10697. SNDRV_PCM_FMTBIT_S24_LE |
  10698. SNDRV_PCM_FMTBIT_S24_3LE,
  10699. .channels_min = 1,
  10700. .channels_max = 8,
  10701. .rate_min = 8000,
  10702. .rate_max = 384000,
  10703. },
  10704. .name = "VA_CDC_DMA_TX_0",
  10705. .ops = &msm_dai_q6_cdc_dma_ops,
  10706. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  10707. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10708. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10709. },
  10710. {
  10711. .capture = {
  10712. .stream_name = "VA CDC DMA1 Capture",
  10713. .aif_name = "VA_CDC_DMA_TX_1",
  10714. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10715. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10716. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10717. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10718. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10719. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10720. SNDRV_PCM_RATE_384000,
  10721. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10722. SNDRV_PCM_FMTBIT_S24_LE |
  10723. SNDRV_PCM_FMTBIT_S24_3LE,
  10724. .channels_min = 1,
  10725. .channels_max = 8,
  10726. .rate_min = 8000,
  10727. .rate_max = 384000,
  10728. },
  10729. .name = "VA_CDC_DMA_TX_1",
  10730. .ops = &msm_dai_q6_cdc_dma_ops,
  10731. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  10732. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10733. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10734. },
  10735. {
  10736. .capture = {
  10737. .stream_name = "VA CDC DMA2 Capture",
  10738. .aif_name = "VA_CDC_DMA_TX_2",
  10739. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10740. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10741. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10742. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10743. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10744. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10745. SNDRV_PCM_RATE_384000,
  10746. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10747. SNDRV_PCM_FMTBIT_S24_LE |
  10748. SNDRV_PCM_FMTBIT_S24_3LE,
  10749. .channels_min = 1,
  10750. .channels_max = 8,
  10751. .rate_min = 8000,
  10752. .rate_max = 384000,
  10753. },
  10754. .name = "VA_CDC_DMA_TX_2",
  10755. .ops = &msm_dai_q6_cdc_dma_ops,
  10756. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  10757. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10758. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10759. },
  10760. {
  10761. .playback = {
  10762. .stream_name = "RX CDC DMA0 Playback",
  10763. .aif_name = "RX_CDC_DMA_RX_0",
  10764. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10765. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10766. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10767. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10768. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10769. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10770. SNDRV_PCM_RATE_384000,
  10771. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10772. SNDRV_PCM_FMTBIT_S24_LE |
  10773. SNDRV_PCM_FMTBIT_S24_3LE |
  10774. SNDRV_PCM_FMTBIT_S32_LE,
  10775. .channels_min = 1,
  10776. .channels_max = 2,
  10777. .rate_min = 8000,
  10778. .rate_max = 384000,
  10779. },
  10780. .ops = &msm_dai_q6_cdc_dma_ops,
  10781. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  10782. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10783. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10784. },
  10785. {
  10786. .capture = {
  10787. .stream_name = "TX CDC DMA0 Capture",
  10788. .aif_name = "TX_CDC_DMA_TX_0",
  10789. .rates = SNDRV_PCM_RATE_8000 |
  10790. SNDRV_PCM_RATE_16000 |
  10791. SNDRV_PCM_RATE_32000 |
  10792. SNDRV_PCM_RATE_48000 |
  10793. SNDRV_PCM_RATE_96000 |
  10794. SNDRV_PCM_RATE_192000 |
  10795. SNDRV_PCM_RATE_384000,
  10796. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10797. SNDRV_PCM_FMTBIT_S24_LE |
  10798. SNDRV_PCM_FMTBIT_S24_3LE |
  10799. SNDRV_PCM_FMTBIT_S32_LE,
  10800. .channels_min = 1,
  10801. .channels_max = 3,
  10802. .rate_min = 8000,
  10803. .rate_max = 384000,
  10804. },
  10805. .ops = &msm_dai_q6_cdc_dma_ops,
  10806. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  10807. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10808. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10809. },
  10810. {
  10811. .playback = {
  10812. .stream_name = "RX CDC DMA1 Playback",
  10813. .aif_name = "RX_CDC_DMA_RX_1",
  10814. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10815. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10816. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10817. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10818. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10819. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10820. SNDRV_PCM_RATE_384000,
  10821. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10822. SNDRV_PCM_FMTBIT_S24_LE |
  10823. SNDRV_PCM_FMTBIT_S24_3LE |
  10824. SNDRV_PCM_FMTBIT_S32_LE,
  10825. .channels_min = 1,
  10826. .channels_max = 2,
  10827. .rate_min = 8000,
  10828. .rate_max = 384000,
  10829. },
  10830. .ops = &msm_dai_q6_cdc_dma_ops,
  10831. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  10832. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10833. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10834. },
  10835. {
  10836. .capture = {
  10837. .stream_name = "TX CDC DMA1 Capture",
  10838. .aif_name = "TX_CDC_DMA_TX_1",
  10839. .rates = SNDRV_PCM_RATE_8000 |
  10840. SNDRV_PCM_RATE_16000 |
  10841. SNDRV_PCM_RATE_32000 |
  10842. SNDRV_PCM_RATE_48000 |
  10843. SNDRV_PCM_RATE_96000 |
  10844. SNDRV_PCM_RATE_192000 |
  10845. SNDRV_PCM_RATE_384000,
  10846. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10847. SNDRV_PCM_FMTBIT_S24_LE |
  10848. SNDRV_PCM_FMTBIT_S24_3LE |
  10849. SNDRV_PCM_FMTBIT_S32_LE,
  10850. .channels_min = 1,
  10851. .channels_max = 3,
  10852. .rate_min = 8000,
  10853. .rate_max = 384000,
  10854. },
  10855. .ops = &msm_dai_q6_cdc_dma_ops,
  10856. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  10857. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10858. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10859. },
  10860. {
  10861. .playback = {
  10862. .stream_name = "RX CDC DMA2 Playback",
  10863. .aif_name = "RX_CDC_DMA_RX_2",
  10864. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10865. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10866. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10867. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10868. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10869. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10870. SNDRV_PCM_RATE_384000,
  10871. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10872. SNDRV_PCM_FMTBIT_S24_LE |
  10873. SNDRV_PCM_FMTBIT_S24_3LE |
  10874. SNDRV_PCM_FMTBIT_S32_LE,
  10875. .channels_min = 1,
  10876. .channels_max = 1,
  10877. .rate_min = 8000,
  10878. .rate_max = 384000,
  10879. },
  10880. .ops = &msm_dai_q6_cdc_dma_ops,
  10881. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  10882. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10883. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10884. },
  10885. {
  10886. .capture = {
  10887. .stream_name = "TX CDC DMA2 Capture",
  10888. .aif_name = "TX_CDC_DMA_TX_2",
  10889. .rates = SNDRV_PCM_RATE_8000 |
  10890. SNDRV_PCM_RATE_16000 |
  10891. SNDRV_PCM_RATE_32000 |
  10892. SNDRV_PCM_RATE_48000 |
  10893. SNDRV_PCM_RATE_96000 |
  10894. SNDRV_PCM_RATE_192000 |
  10895. SNDRV_PCM_RATE_384000,
  10896. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10897. SNDRV_PCM_FMTBIT_S24_LE |
  10898. SNDRV_PCM_FMTBIT_S24_3LE |
  10899. SNDRV_PCM_FMTBIT_S32_LE,
  10900. .channels_min = 1,
  10901. .channels_max = 4,
  10902. .rate_min = 8000,
  10903. .rate_max = 384000,
  10904. },
  10905. .ops = &msm_dai_q6_cdc_dma_ops,
  10906. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  10907. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10908. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10909. }, {
  10910. .playback = {
  10911. .stream_name = "RX CDC DMA3 Playback",
  10912. .aif_name = "RX_CDC_DMA_RX_3",
  10913. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10914. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10915. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10916. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10917. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10918. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10919. SNDRV_PCM_RATE_384000,
  10920. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10921. SNDRV_PCM_FMTBIT_S24_LE |
  10922. SNDRV_PCM_FMTBIT_S24_3LE |
  10923. SNDRV_PCM_FMTBIT_S32_LE,
  10924. .channels_min = 1,
  10925. .channels_max = 1,
  10926. .rate_min = 8000,
  10927. .rate_max = 384000,
  10928. },
  10929. .ops = &msm_dai_q6_cdc_dma_ops,
  10930. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  10931. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10932. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10933. },
  10934. {
  10935. .capture = {
  10936. .stream_name = "TX CDC DMA3 Capture",
  10937. .aif_name = "TX_CDC_DMA_TX_3",
  10938. .rates = SNDRV_PCM_RATE_8000 |
  10939. SNDRV_PCM_RATE_16000 |
  10940. SNDRV_PCM_RATE_32000 |
  10941. SNDRV_PCM_RATE_48000 |
  10942. SNDRV_PCM_RATE_96000 |
  10943. SNDRV_PCM_RATE_192000 |
  10944. SNDRV_PCM_RATE_384000,
  10945. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10946. SNDRV_PCM_FMTBIT_S24_LE |
  10947. SNDRV_PCM_FMTBIT_S24_3LE |
  10948. SNDRV_PCM_FMTBIT_S32_LE,
  10949. .channels_min = 1,
  10950. .channels_max = 8,
  10951. .rate_min = 8000,
  10952. .rate_max = 384000,
  10953. },
  10954. .ops = &msm_dai_q6_cdc_dma_ops,
  10955. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  10956. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10957. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10958. },
  10959. {
  10960. .playback = {
  10961. .stream_name = "RX CDC DMA4 Playback",
  10962. .aif_name = "RX_CDC_DMA_RX_4",
  10963. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  10964. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  10965. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  10966. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  10967. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  10968. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  10969. SNDRV_PCM_RATE_384000,
  10970. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10971. SNDRV_PCM_FMTBIT_S24_LE |
  10972. SNDRV_PCM_FMTBIT_S24_3LE |
  10973. SNDRV_PCM_FMTBIT_S32_LE,
  10974. .channels_min = 1,
  10975. .channels_max = 6,
  10976. .rate_min = 8000,
  10977. .rate_max = 384000,
  10978. },
  10979. .ops = &msm_dai_q6_cdc_dma_ops,
  10980. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  10981. .probe = msm_dai_q6_dai_cdc_dma_probe,
  10982. .remove = msm_dai_q6_dai_cdc_dma_remove,
  10983. },
  10984. {
  10985. .capture = {
  10986. .stream_name = "TX CDC DMA4 Capture",
  10987. .aif_name = "TX_CDC_DMA_TX_4",
  10988. .rates = SNDRV_PCM_RATE_8000 |
  10989. SNDRV_PCM_RATE_16000 |
  10990. SNDRV_PCM_RATE_32000 |
  10991. SNDRV_PCM_RATE_48000 |
  10992. SNDRV_PCM_RATE_96000 |
  10993. SNDRV_PCM_RATE_192000 |
  10994. SNDRV_PCM_RATE_384000,
  10995. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10996. SNDRV_PCM_FMTBIT_S24_LE |
  10997. SNDRV_PCM_FMTBIT_S24_3LE |
  10998. SNDRV_PCM_FMTBIT_S32_LE,
  10999. .channels_min = 1,
  11000. .channels_max = 8,
  11001. .rate_min = 8000,
  11002. .rate_max = 384000,
  11003. },
  11004. .ops = &msm_dai_q6_cdc_dma_ops,
  11005. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  11006. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11007. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11008. },
  11009. {
  11010. .playback = {
  11011. .stream_name = "RX CDC DMA5 Playback",
  11012. .aif_name = "RX_CDC_DMA_RX_5",
  11013. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11014. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11015. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11016. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11017. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11018. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11019. SNDRV_PCM_RATE_384000,
  11020. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11021. SNDRV_PCM_FMTBIT_S24_LE |
  11022. SNDRV_PCM_FMTBIT_S24_3LE |
  11023. SNDRV_PCM_FMTBIT_S32_LE,
  11024. .channels_min = 1,
  11025. .channels_max = 1,
  11026. .rate_min = 8000,
  11027. .rate_max = 384000,
  11028. },
  11029. .ops = &msm_dai_q6_cdc_dma_ops,
  11030. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  11031. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11032. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11033. },
  11034. {
  11035. .capture = {
  11036. .stream_name = "TX CDC DMA5 Capture",
  11037. .aif_name = "TX_CDC_DMA_TX_5",
  11038. .rates = SNDRV_PCM_RATE_8000 |
  11039. SNDRV_PCM_RATE_16000 |
  11040. SNDRV_PCM_RATE_32000 |
  11041. SNDRV_PCM_RATE_48000 |
  11042. SNDRV_PCM_RATE_96000 |
  11043. SNDRV_PCM_RATE_192000 |
  11044. SNDRV_PCM_RATE_384000,
  11045. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11046. SNDRV_PCM_FMTBIT_S24_LE |
  11047. SNDRV_PCM_FMTBIT_S24_3LE |
  11048. SNDRV_PCM_FMTBIT_S32_LE,
  11049. .channels_min = 1,
  11050. .channels_max = 4,
  11051. .rate_min = 8000,
  11052. .rate_max = 384000,
  11053. },
  11054. .ops = &msm_dai_q6_cdc_dma_ops,
  11055. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  11056. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11057. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11058. },
  11059. {
  11060. .playback = {
  11061. .stream_name = "RX CDC DMA6 Playback",
  11062. .aif_name = "RX_CDC_DMA_RX_6",
  11063. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11064. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11065. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11066. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11067. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11068. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11069. SNDRV_PCM_RATE_384000,
  11070. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11071. SNDRV_PCM_FMTBIT_S24_LE |
  11072. SNDRV_PCM_FMTBIT_S24_3LE |
  11073. SNDRV_PCM_FMTBIT_S32_LE,
  11074. .channels_min = 1,
  11075. .channels_max = 4,
  11076. .rate_min = 8000,
  11077. .rate_max = 384000,
  11078. },
  11079. .ops = &msm_dai_q6_cdc_dma_ops,
  11080. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  11081. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11082. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11083. },
  11084. {
  11085. .playback = {
  11086. .stream_name = "RX CDC DMA7 Playback",
  11087. .aif_name = "RX_CDC_DMA_RX_7",
  11088. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11089. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11090. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11091. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11092. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11093. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11094. SNDRV_PCM_RATE_384000,
  11095. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11096. SNDRV_PCM_FMTBIT_S24_LE |
  11097. SNDRV_PCM_FMTBIT_S24_3LE |
  11098. SNDRV_PCM_FMTBIT_S32_LE,
  11099. .channels_min = 1,
  11100. .channels_max = 2,
  11101. .rate_min = 8000,
  11102. .rate_max = 384000,
  11103. },
  11104. .ops = &msm_dai_q6_cdc_dma_ops,
  11105. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  11106. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11107. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11108. },
  11109. };
  11110. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  11111. .name = "msm-dai-cdc-dma-dev",
  11112. };
  11113. /* DT related probe for each codec DMA interface device */
  11114. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  11115. {
  11116. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  11117. u32 cdc_dma_id = 0;
  11118. int i;
  11119. int rc = 0;
  11120. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  11121. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  11122. &cdc_dma_id);
  11123. if (rc) {
  11124. dev_err(&pdev->dev,
  11125. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  11126. return rc;
  11127. }
  11128. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  11129. dev_name(&pdev->dev), cdc_dma_id);
  11130. pdev->id = cdc_dma_id;
  11131. dai_data = devm_kzalloc(&pdev->dev,
  11132. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  11133. GFP_KERNEL);
  11134. if (!dai_data)
  11135. return -ENOMEM;
  11136. rc = of_property_read_u32(pdev->dev.of_node,
  11137. "qcom,msm-dai-is-island-supported",
  11138. &dai_data->is_island_dai);
  11139. if (rc)
  11140. dev_dbg(&pdev->dev, "island supported entry not found\n");
  11141. dev_set_drvdata(&pdev->dev, dai_data);
  11142. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  11143. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  11144. return snd_soc_register_component(&pdev->dev,
  11145. &msm_q6_cdc_dma_dai_component,
  11146. &msm_dai_q6_cdc_dma_dai[i], 1);
  11147. }
  11148. }
  11149. return -ENODEV;
  11150. }
  11151. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  11152. {
  11153. snd_soc_unregister_component(&pdev->dev);
  11154. return 0;
  11155. }
  11156. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  11157. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  11158. { }
  11159. };
  11160. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  11161. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  11162. .probe = msm_dai_q6_cdc_dma_dev_probe,
  11163. .remove = msm_dai_q6_cdc_dma_dev_remove,
  11164. .driver = {
  11165. .name = "msm-dai-cdc-dma-dev",
  11166. .owner = THIS_MODULE,
  11167. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  11168. .suppress_bind_attrs = true,
  11169. },
  11170. };
  11171. /* DT related probe for codec DMA interface device group */
  11172. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  11173. {
  11174. int rc;
  11175. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  11176. if (rc) {
  11177. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  11178. __func__, rc);
  11179. } else
  11180. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  11181. return rc;
  11182. }
  11183. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  11184. {
  11185. of_platform_depopulate(&pdev->dev);
  11186. return 0;
  11187. }
  11188. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  11189. { .compatible = "qcom,msm-dai-cdc-dma", },
  11190. { }
  11191. };
  11192. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  11193. static struct platform_driver msm_dai_cdc_dma_q6 = {
  11194. .probe = msm_dai_cdc_dma_q6_probe,
  11195. .remove = msm_dai_cdc_dma_q6_remove,
  11196. .driver = {
  11197. .name = "msm-dai-cdc-dma",
  11198. .owner = THIS_MODULE,
  11199. .of_match_table = msm_dai_cdc_dma_dt_match,
  11200. .suppress_bind_attrs = true,
  11201. },
  11202. };
  11203. int __init msm_dai_q6_init(void)
  11204. {
  11205. int rc;
  11206. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  11207. if (rc) {
  11208. pr_err("%s: fail to register auxpcm dev driver", __func__);
  11209. goto fail;
  11210. }
  11211. rc = platform_driver_register(&msm_dai_q6);
  11212. if (rc) {
  11213. pr_err("%s: fail to register dai q6 driver", __func__);
  11214. goto dai_q6_fail;
  11215. }
  11216. rc = platform_driver_register(&msm_dai_q6_dev);
  11217. if (rc) {
  11218. pr_err("%s: fail to register dai q6 dev driver", __func__);
  11219. goto dai_q6_dev_fail;
  11220. }
  11221. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  11222. if (rc) {
  11223. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  11224. goto dai_q6_mi2s_drv_fail;
  11225. }
  11226. rc = platform_driver_register(&msm_dai_mi2s_q6);
  11227. if (rc) {
  11228. pr_err("%s: fail to register dai MI2S\n", __func__);
  11229. goto dai_mi2s_q6_fail;
  11230. }
  11231. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  11232. if (rc) {
  11233. pr_err("%s: fail to register dai SPDIF\n", __func__);
  11234. goto dai_spdif_q6_fail;
  11235. }
  11236. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  11237. if (rc) {
  11238. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  11239. goto dai_q6_tdm_drv_fail;
  11240. }
  11241. rc = platform_driver_register(&msm_dai_tdm_q6);
  11242. if (rc) {
  11243. pr_err("%s: fail to register dai TDM\n", __func__);
  11244. goto dai_tdm_q6_fail;
  11245. }
  11246. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  11247. if (rc) {
  11248. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  11249. goto dai_cdc_dma_q6_dev_fail;
  11250. }
  11251. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  11252. if (rc) {
  11253. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  11254. goto dai_cdc_dma_q6_fail;
  11255. }
  11256. return rc;
  11257. dai_cdc_dma_q6_fail:
  11258. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  11259. dai_cdc_dma_q6_dev_fail:
  11260. platform_driver_unregister(&msm_dai_tdm_q6);
  11261. dai_tdm_q6_fail:
  11262. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  11263. dai_q6_tdm_drv_fail:
  11264. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  11265. dai_spdif_q6_fail:
  11266. platform_driver_unregister(&msm_dai_mi2s_q6);
  11267. dai_mi2s_q6_fail:
  11268. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  11269. dai_q6_mi2s_drv_fail:
  11270. platform_driver_unregister(&msm_dai_q6_dev);
  11271. dai_q6_dev_fail:
  11272. platform_driver_unregister(&msm_dai_q6);
  11273. dai_q6_fail:
  11274. platform_driver_unregister(&msm_auxpcm_dev_driver);
  11275. fail:
  11276. return rc;
  11277. }
  11278. void msm_dai_q6_exit(void)
  11279. {
  11280. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  11281. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  11282. platform_driver_unregister(&msm_dai_tdm_q6);
  11283. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  11284. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  11285. platform_driver_unregister(&msm_dai_mi2s_q6);
  11286. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  11287. platform_driver_unregister(&msm_dai_q6_dev);
  11288. platform_driver_unregister(&msm_dai_q6);
  11289. platform_driver_unregister(&msm_auxpcm_dev_driver);
  11290. }
  11291. /* Module information */
  11292. MODULE_DESCRIPTION("MSM DSP DAI driver");
  11293. MODULE_LICENSE("GPL v2");