msm-dai-q6-v2.c 393 KB

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