msm-dai-q6-v2.c 289 KB

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