msm-dai-q6-v2.c 309 KB

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