msm-dai-q6-v2.c 390 KB

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