msm-dai-q6-v2.c 328 KB

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