msm-dai-q6-v2.c 323 KB

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