kona.c 171 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/delay.h>
  7. #include <linux/gpio.h>
  8. #include <linux/of_gpio.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. #include <linux/io.h>
  12. #include <linux/module.h>
  13. #include <linux/input.h>
  14. #include <linux/of_device.h>
  15. #include <linux/soc/qcom/fsa4480-i2c.h>
  16. #include <sound/core.h>
  17. #include <sound/soc.h>
  18. #include <sound/soc-dapm.h>
  19. #include <sound/pcm.h>
  20. #include <sound/pcm_params.h>
  21. #include <sound/info.h>
  22. #include <soc/snd_event.h>
  23. #include <dsp/audio_notifier.h>
  24. #include <soc/swr-common.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include <dsp/q6core.h>
  27. #include "device_event.h"
  28. #include "msm-pcm-routing-v2.h"
  29. #include "asoc/msm-cdc-pinctrl.h"
  30. #include "asoc/wcd-mbhc-v2.h"
  31. #include "codecs/wcd938x/wcd938x-mbhc.h"
  32. #include "codecs/wsa881x.h"
  33. #include "codecs/wcd938x/wcd938x.h"
  34. #include "codecs/bolero/bolero-cdc.h"
  35. #include <dt-bindings/sound/audio-codec-port-types.h>
  36. #include "codecs/bolero/wsa-macro.h"
  37. #include "sm8250-port-config.h"
  38. #define DRV_NAME "kona-asoc-snd"
  39. #define __CHIPSET__ "KONA "
  40. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  41. #define SAMPLING_RATE_8KHZ 8000
  42. #define SAMPLING_RATE_11P025KHZ 11025
  43. #define SAMPLING_RATE_16KHZ 16000
  44. #define SAMPLING_RATE_22P05KHZ 22050
  45. #define SAMPLING_RATE_32KHZ 32000
  46. #define SAMPLING_RATE_44P1KHZ 44100
  47. #define SAMPLING_RATE_48KHZ 48000
  48. #define SAMPLING_RATE_88P2KHZ 88200
  49. #define SAMPLING_RATE_96KHZ 96000
  50. #define SAMPLING_RATE_176P4KHZ 176400
  51. #define SAMPLING_RATE_192KHZ 192000
  52. #define SAMPLING_RATE_352P8KHZ 352800
  53. #define SAMPLING_RATE_384KHZ 384000
  54. #define WCD9XXX_MBHC_DEF_RLOADS 5
  55. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  56. #define CODEC_EXT_CLK_RATE 9600000
  57. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  58. #define DEV_NAME_STR_LEN 32
  59. #define WCD_MBHC_HS_V_MAX 1600
  60. #define TDM_CHANNEL_MAX 8
  61. #define DEV_NAME_STR_LEN 32
  62. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  63. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  64. #define WSA8810_NAME_1 "wsa881x.20170211"
  65. #define WSA8810_NAME_2 "wsa881x.20170212"
  66. #define WCN_CDC_SLIM_RX_CH_MAX 2
  67. #define WCN_CDC_SLIM_TX_CH_MAX 2
  68. enum {
  69. TDM_0 = 0,
  70. TDM_1,
  71. TDM_2,
  72. TDM_3,
  73. TDM_4,
  74. TDM_5,
  75. TDM_6,
  76. TDM_7,
  77. TDM_PORT_MAX,
  78. };
  79. enum {
  80. TDM_PRI = 0,
  81. TDM_SEC,
  82. TDM_TERT,
  83. TDM_INTERFACE_MAX,
  84. };
  85. enum {
  86. PRIM_AUX_PCM = 0,
  87. SEC_AUX_PCM,
  88. TERT_AUX_PCM,
  89. AUX_PCM_MAX,
  90. };
  91. enum {
  92. PRIM_MI2S = 0,
  93. SEC_MI2S,
  94. TERT_MI2S,
  95. MI2S_MAX,
  96. };
  97. enum {
  98. WSA_CDC_DMA_RX_0 = 0,
  99. WSA_CDC_DMA_RX_1,
  100. RX_CDC_DMA_RX_0,
  101. RX_CDC_DMA_RX_1,
  102. RX_CDC_DMA_RX_2,
  103. RX_CDC_DMA_RX_3,
  104. RX_CDC_DMA_RX_5,
  105. CDC_DMA_RX_MAX,
  106. };
  107. enum {
  108. WSA_CDC_DMA_TX_0 = 0,
  109. WSA_CDC_DMA_TX_1,
  110. WSA_CDC_DMA_TX_2,
  111. TX_CDC_DMA_TX_0,
  112. TX_CDC_DMA_TX_3,
  113. TX_CDC_DMA_TX_4,
  114. VA_CDC_DMA_TX_0,
  115. VA_CDC_DMA_TX_1,
  116. VA_CDC_DMA_TX_2,
  117. CDC_DMA_TX_MAX,
  118. };
  119. struct msm_asoc_mach_data {
  120. struct snd_info_entry *codec_root;
  121. int usbc_en2_gpio; /* used by gpio driver API */
  122. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  123. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  124. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  125. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  126. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  127. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  128. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  129. bool is_afe_config_done;
  130. struct device_node *fsa_handle;
  131. };
  132. struct tdm_port {
  133. u32 mode;
  134. u32 channel;
  135. };
  136. enum {
  137. EXT_DISP_RX_IDX_DP = 0,
  138. EXT_DISP_RX_IDX_MAX,
  139. };
  140. struct msm_wsa881x_dev_info {
  141. struct device_node *of_node;
  142. u32 index;
  143. };
  144. struct aux_codec_dev_info {
  145. struct device_node *of_node;
  146. u32 index;
  147. };
  148. struct dev_config {
  149. u32 sample_rate;
  150. u32 bit_format;
  151. u32 channels;
  152. };
  153. /* Default configuration of external display BE */
  154. static struct dev_config ext_disp_rx_cfg[] = {
  155. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  156. };
  157. static struct dev_config usb_rx_cfg = {
  158. .sample_rate = SAMPLING_RATE_48KHZ,
  159. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  160. .channels = 2,
  161. };
  162. static struct dev_config usb_tx_cfg = {
  163. .sample_rate = SAMPLING_RATE_48KHZ,
  164. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  165. .channels = 1,
  166. };
  167. static struct dev_config proxy_rx_cfg = {
  168. .sample_rate = SAMPLING_RATE_48KHZ,
  169. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  170. .channels = 2,
  171. };
  172. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  173. {
  174. AFE_API_VERSION_I2S_CONFIG,
  175. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  176. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  177. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  178. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  179. 0,
  180. },
  181. {
  182. AFE_API_VERSION_I2S_CONFIG,
  183. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  184. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  185. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  186. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  187. 0,
  188. },
  189. {
  190. AFE_API_VERSION_I2S_CONFIG,
  191. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  192. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  193. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  194. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  195. 0,
  196. },
  197. };
  198. struct mi2s_conf {
  199. struct mutex lock;
  200. u32 ref_cnt;
  201. u32 msm_is_mi2s_master;
  202. };
  203. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  204. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  205. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  206. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  207. };
  208. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  209. /* Default configuration of TDM channels */
  210. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  211. { /* PRI TDM */
  212. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  213. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  214. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  215. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  216. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  217. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  218. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  219. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  220. },
  221. { /* SEC TDM */
  222. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  223. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  224. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  225. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  226. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  227. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  228. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  229. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  230. },
  231. { /* TERT TDM */
  232. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  233. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  234. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  235. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  236. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  237. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  238. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  239. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  240. },
  241. };
  242. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  243. { /* PRI TDM */
  244. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  245. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  246. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  247. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  248. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  249. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  250. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  251. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  252. },
  253. { /* SEC TDM */
  254. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  255. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  256. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  257. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  258. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  259. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  260. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  261. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  262. },
  263. { /* TERT TDM */
  264. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  265. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  266. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  272. },
  273. };
  274. /* Default configuration of AUX PCM channels */
  275. static struct dev_config aux_pcm_rx_cfg[] = {
  276. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  277. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  278. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  279. };
  280. static struct dev_config aux_pcm_tx_cfg[] = {
  281. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  282. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  283. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  284. };
  285. /* Default configuration of MI2S channels */
  286. static struct dev_config mi2s_rx_cfg[] = {
  287. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  288. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  289. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  290. };
  291. static struct dev_config mi2s_tx_cfg[] = {
  292. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  293. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  294. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  295. };
  296. /* Default configuration of Codec DMA Interface RX */
  297. static struct dev_config cdc_dma_rx_cfg[] = {
  298. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  299. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  300. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  301. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  302. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  303. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  304. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  305. };
  306. /* Default configuration of Codec DMA Interface TX */
  307. static struct dev_config cdc_dma_tx_cfg[] = {
  308. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  309. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  310. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  311. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  312. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  313. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  314. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  315. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  316. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  317. };
  318. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  319. "S32_LE"};
  320. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  321. "Six", "Seven", "Eight"};
  322. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  323. "KHZ_16", "KHZ_22P05",
  324. "KHZ_32", "KHZ_44P1", "KHZ_48",
  325. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  326. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  327. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  328. "Five", "Six", "Seven",
  329. "Eight"};
  330. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  331. "KHZ_48", "KHZ_176P4",
  332. "KHZ_352P8"};
  333. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  334. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  335. "Five", "Six", "Seven", "Eight"};
  336. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  337. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  338. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  339. "KHZ_48", "KHZ_96", "KHZ_192"};
  340. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  341. "Five", "Six", "Seven",
  342. "Eight"};
  343. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  344. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  345. "Five", "Six", "Seven",
  346. "Eight"};
  347. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  348. "KHZ_16", "KHZ_22P05",
  349. "KHZ_32", "KHZ_44P1", "KHZ_48",
  350. "KHZ_88P2", "KHZ_96",
  351. "KHZ_176P4", "KHZ_192",
  352. "KHZ_352P8", "KHZ_384"};
  353. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  354. "S24_3LE"};
  355. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  356. "KHZ_192", "KHZ_32", "KHZ_44P1",
  357. "KHZ_88P2", "KHZ_176P4"};
  358. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  359. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  360. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  361. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  362. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  363. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  364. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  365. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  366. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  367. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  368. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  369. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  370. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  371. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  372. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  373. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  374. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  375. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  376. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  377. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  378. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  379. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  380. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  381. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  382. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  383. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  384. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  385. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  386. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  387. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  388. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  389. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  390. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  391. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  392. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  393. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  394. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  395. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  396. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  397. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  398. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  399. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  400. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  401. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  402. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  403. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  404. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  405. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  406. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  407. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  408. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  409. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  410. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  411. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_format, bit_format_text);
  412. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_format, bit_format_text);
  413. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_format, bit_format_text);
  414. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_format, bit_format_text);
  415. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_format, bit_format_text);
  416. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  417. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  418. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  419. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  420. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  421. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  422. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  423. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  424. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  425. cdc_dma_sample_rate_text);
  426. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  427. cdc_dma_sample_rate_text);
  428. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_sample_rate,
  429. cdc_dma_sample_rate_text);
  430. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_sample_rate,
  431. cdc_dma_sample_rate_text);
  432. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_sample_rate,
  433. cdc_dma_sample_rate_text);
  434. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_sample_rate,
  435. cdc_dma_sample_rate_text);
  436. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_sample_rate,
  437. cdc_dma_sample_rate_text);
  438. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  439. cdc_dma_sample_rate_text);
  440. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  441. cdc_dma_sample_rate_text);
  442. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  443. cdc_dma_sample_rate_text);
  444. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  445. cdc_dma_sample_rate_text);
  446. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  447. cdc_dma_sample_rate_text);
  448. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  449. cdc_dma_sample_rate_text);
  450. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  451. cdc_dma_sample_rate_text);
  452. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  453. cdc_dma_sample_rate_text);
  454. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  455. cdc_dma_sample_rate_text);
  456. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  457. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  458. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  459. ext_disp_sample_rate_text);
  460. static bool is_initial_boot;
  461. static bool codec_reg_done;
  462. static struct snd_soc_aux_dev *msm_aux_dev;
  463. static struct snd_soc_codec_conf *msm_codec_conf;
  464. static struct snd_soc_card snd_soc_card_kona_msm;
  465. static int dmic_0_1_gpio_cnt;
  466. static int dmic_2_3_gpio_cnt;
  467. static int dmic_4_5_gpio_cnt;
  468. static int msm_vi_feed_tx_ch = 2;
  469. static void *def_wcd_mbhc_cal(void);
  470. /*
  471. * Need to report LINEIN
  472. * if R/L channel impedance is larger than 5K ohm
  473. */
  474. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  475. .read_fw_bin = false,
  476. .calibration = NULL,
  477. .detect_extn_cable = true,
  478. .mono_stero_detection = false,
  479. .swap_gnd_mic = NULL,
  480. .hs_ext_micbias = true,
  481. .key_code[0] = KEY_MEDIA,
  482. .key_code[1] = KEY_VOICECOMMAND,
  483. .key_code[2] = KEY_VOLUMEUP,
  484. .key_code[3] = KEY_VOLUMEDOWN,
  485. .key_code[4] = 0,
  486. .key_code[5] = 0,
  487. .key_code[6] = 0,
  488. .key_code[7] = 0,
  489. .linein_th = 5000,
  490. .moisture_en = true,
  491. .mbhc_micbias = MIC_BIAS_2,
  492. .anc_micbias = MIC_BIAS_2,
  493. .enable_anc_mic_detect = false,
  494. };
  495. static inline int param_is_mask(int p)
  496. {
  497. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  498. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  499. }
  500. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  501. int n)
  502. {
  503. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  504. }
  505. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  506. unsigned int bit)
  507. {
  508. if (bit >= SNDRV_MASK_MAX)
  509. return;
  510. if (param_is_mask(n)) {
  511. struct snd_mask *m = param_to_mask(p, n);
  512. m->bits[0] = 0;
  513. m->bits[1] = 0;
  514. m->bits[bit >> 5] |= (1 << (bit & 31));
  515. }
  516. }
  517. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  518. struct snd_ctl_elem_value *ucontrol)
  519. {
  520. int sample_rate_val = 0;
  521. switch (usb_rx_cfg.sample_rate) {
  522. case SAMPLING_RATE_384KHZ:
  523. sample_rate_val = 12;
  524. break;
  525. case SAMPLING_RATE_352P8KHZ:
  526. sample_rate_val = 11;
  527. break;
  528. case SAMPLING_RATE_192KHZ:
  529. sample_rate_val = 10;
  530. break;
  531. case SAMPLING_RATE_176P4KHZ:
  532. sample_rate_val = 9;
  533. break;
  534. case SAMPLING_RATE_96KHZ:
  535. sample_rate_val = 8;
  536. break;
  537. case SAMPLING_RATE_88P2KHZ:
  538. sample_rate_val = 7;
  539. break;
  540. case SAMPLING_RATE_48KHZ:
  541. sample_rate_val = 6;
  542. break;
  543. case SAMPLING_RATE_44P1KHZ:
  544. sample_rate_val = 5;
  545. break;
  546. case SAMPLING_RATE_32KHZ:
  547. sample_rate_val = 4;
  548. break;
  549. case SAMPLING_RATE_22P05KHZ:
  550. sample_rate_val = 3;
  551. break;
  552. case SAMPLING_RATE_16KHZ:
  553. sample_rate_val = 2;
  554. break;
  555. case SAMPLING_RATE_11P025KHZ:
  556. sample_rate_val = 1;
  557. break;
  558. case SAMPLING_RATE_8KHZ:
  559. default:
  560. sample_rate_val = 0;
  561. break;
  562. }
  563. ucontrol->value.integer.value[0] = sample_rate_val;
  564. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  565. usb_rx_cfg.sample_rate);
  566. return 0;
  567. }
  568. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  569. struct snd_ctl_elem_value *ucontrol)
  570. {
  571. switch (ucontrol->value.integer.value[0]) {
  572. case 12:
  573. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  574. break;
  575. case 11:
  576. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  577. break;
  578. case 10:
  579. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  580. break;
  581. case 9:
  582. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  583. break;
  584. case 8:
  585. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  586. break;
  587. case 7:
  588. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  589. break;
  590. case 6:
  591. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  592. break;
  593. case 5:
  594. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  595. break;
  596. case 4:
  597. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  598. break;
  599. case 3:
  600. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  601. break;
  602. case 2:
  603. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  604. break;
  605. case 1:
  606. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  607. break;
  608. case 0:
  609. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  610. break;
  611. default:
  612. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  613. break;
  614. }
  615. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  616. __func__, ucontrol->value.integer.value[0],
  617. usb_rx_cfg.sample_rate);
  618. return 0;
  619. }
  620. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  621. struct snd_ctl_elem_value *ucontrol)
  622. {
  623. int sample_rate_val = 0;
  624. switch (usb_tx_cfg.sample_rate) {
  625. case SAMPLING_RATE_384KHZ:
  626. sample_rate_val = 12;
  627. break;
  628. case SAMPLING_RATE_352P8KHZ:
  629. sample_rate_val = 11;
  630. break;
  631. case SAMPLING_RATE_192KHZ:
  632. sample_rate_val = 10;
  633. break;
  634. case SAMPLING_RATE_176P4KHZ:
  635. sample_rate_val = 9;
  636. break;
  637. case SAMPLING_RATE_96KHZ:
  638. sample_rate_val = 8;
  639. break;
  640. case SAMPLING_RATE_88P2KHZ:
  641. sample_rate_val = 7;
  642. break;
  643. case SAMPLING_RATE_48KHZ:
  644. sample_rate_val = 6;
  645. break;
  646. case SAMPLING_RATE_44P1KHZ:
  647. sample_rate_val = 5;
  648. break;
  649. case SAMPLING_RATE_32KHZ:
  650. sample_rate_val = 4;
  651. break;
  652. case SAMPLING_RATE_22P05KHZ:
  653. sample_rate_val = 3;
  654. break;
  655. case SAMPLING_RATE_16KHZ:
  656. sample_rate_val = 2;
  657. break;
  658. case SAMPLING_RATE_11P025KHZ:
  659. sample_rate_val = 1;
  660. break;
  661. case SAMPLING_RATE_8KHZ:
  662. sample_rate_val = 0;
  663. break;
  664. default:
  665. sample_rate_val = 6;
  666. break;
  667. }
  668. ucontrol->value.integer.value[0] = sample_rate_val;
  669. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  670. usb_tx_cfg.sample_rate);
  671. return 0;
  672. }
  673. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  674. struct snd_ctl_elem_value *ucontrol)
  675. {
  676. switch (ucontrol->value.integer.value[0]) {
  677. case 12:
  678. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  679. break;
  680. case 11:
  681. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  682. break;
  683. case 10:
  684. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  685. break;
  686. case 9:
  687. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  688. break;
  689. case 8:
  690. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  691. break;
  692. case 7:
  693. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  694. break;
  695. case 6:
  696. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  697. break;
  698. case 5:
  699. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  700. break;
  701. case 4:
  702. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  703. break;
  704. case 3:
  705. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  706. break;
  707. case 2:
  708. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  709. break;
  710. case 1:
  711. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  712. break;
  713. case 0:
  714. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  715. break;
  716. default:
  717. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  718. break;
  719. }
  720. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  721. __func__, ucontrol->value.integer.value[0],
  722. usb_tx_cfg.sample_rate);
  723. return 0;
  724. }
  725. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  726. struct snd_ctl_elem_value *ucontrol)
  727. {
  728. switch (usb_rx_cfg.bit_format) {
  729. case SNDRV_PCM_FORMAT_S32_LE:
  730. ucontrol->value.integer.value[0] = 3;
  731. break;
  732. case SNDRV_PCM_FORMAT_S24_3LE:
  733. ucontrol->value.integer.value[0] = 2;
  734. break;
  735. case SNDRV_PCM_FORMAT_S24_LE:
  736. ucontrol->value.integer.value[0] = 1;
  737. break;
  738. case SNDRV_PCM_FORMAT_S16_LE:
  739. default:
  740. ucontrol->value.integer.value[0] = 0;
  741. break;
  742. }
  743. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  744. __func__, usb_rx_cfg.bit_format,
  745. ucontrol->value.integer.value[0]);
  746. return 0;
  747. }
  748. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  749. struct snd_ctl_elem_value *ucontrol)
  750. {
  751. int rc = 0;
  752. switch (ucontrol->value.integer.value[0]) {
  753. case 3:
  754. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  755. break;
  756. case 2:
  757. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  758. break;
  759. case 1:
  760. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  761. break;
  762. case 0:
  763. default:
  764. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  765. break;
  766. }
  767. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  768. __func__, usb_rx_cfg.bit_format,
  769. ucontrol->value.integer.value[0]);
  770. return rc;
  771. }
  772. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  773. struct snd_ctl_elem_value *ucontrol)
  774. {
  775. switch (usb_tx_cfg.bit_format) {
  776. case SNDRV_PCM_FORMAT_S32_LE:
  777. ucontrol->value.integer.value[0] = 3;
  778. break;
  779. case SNDRV_PCM_FORMAT_S24_3LE:
  780. ucontrol->value.integer.value[0] = 2;
  781. break;
  782. case SNDRV_PCM_FORMAT_S24_LE:
  783. ucontrol->value.integer.value[0] = 1;
  784. break;
  785. case SNDRV_PCM_FORMAT_S16_LE:
  786. default:
  787. ucontrol->value.integer.value[0] = 0;
  788. break;
  789. }
  790. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  791. __func__, usb_tx_cfg.bit_format,
  792. ucontrol->value.integer.value[0]);
  793. return 0;
  794. }
  795. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  796. struct snd_ctl_elem_value *ucontrol)
  797. {
  798. int rc = 0;
  799. switch (ucontrol->value.integer.value[0]) {
  800. case 3:
  801. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  802. break;
  803. case 2:
  804. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  805. break;
  806. case 1:
  807. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  808. break;
  809. case 0:
  810. default:
  811. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  812. break;
  813. }
  814. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  815. __func__, usb_tx_cfg.bit_format,
  816. ucontrol->value.integer.value[0]);
  817. return rc;
  818. }
  819. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  820. struct snd_ctl_elem_value *ucontrol)
  821. {
  822. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  823. usb_rx_cfg.channels);
  824. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  825. return 0;
  826. }
  827. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  828. struct snd_ctl_elem_value *ucontrol)
  829. {
  830. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  831. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  832. return 1;
  833. }
  834. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  835. struct snd_ctl_elem_value *ucontrol)
  836. {
  837. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  838. usb_tx_cfg.channels);
  839. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  840. return 0;
  841. }
  842. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  843. struct snd_ctl_elem_value *ucontrol)
  844. {
  845. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  846. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  847. return 1;
  848. }
  849. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  850. {
  851. int idx = 0;
  852. if (strnstr(kcontrol->id.name, "Display Port RX",
  853. sizeof("Display Port RX"))) {
  854. idx = EXT_DISP_RX_IDX_DP;
  855. } else {
  856. pr_err("%s: unsupported BE: %s\n",
  857. __func__, kcontrol->id.name);
  858. idx = -EINVAL;
  859. }
  860. return idx;
  861. }
  862. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  863. struct snd_ctl_elem_value *ucontrol)
  864. {
  865. int idx = ext_disp_get_port_idx(kcontrol);
  866. if (idx < 0)
  867. return idx;
  868. switch (ext_disp_rx_cfg[idx].bit_format) {
  869. case SNDRV_PCM_FORMAT_S24_3LE:
  870. ucontrol->value.integer.value[0] = 2;
  871. break;
  872. case SNDRV_PCM_FORMAT_S24_LE:
  873. ucontrol->value.integer.value[0] = 1;
  874. break;
  875. case SNDRV_PCM_FORMAT_S16_LE:
  876. default:
  877. ucontrol->value.integer.value[0] = 0;
  878. break;
  879. }
  880. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  881. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  882. ucontrol->value.integer.value[0]);
  883. return 0;
  884. }
  885. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  886. struct snd_ctl_elem_value *ucontrol)
  887. {
  888. int idx = ext_disp_get_port_idx(kcontrol);
  889. if (idx < 0)
  890. return idx;
  891. switch (ucontrol->value.integer.value[0]) {
  892. case 2:
  893. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  894. break;
  895. case 1:
  896. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  897. break;
  898. case 0:
  899. default:
  900. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  901. break;
  902. }
  903. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  904. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  905. ucontrol->value.integer.value[0]);
  906. return 0;
  907. }
  908. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  909. struct snd_ctl_elem_value *ucontrol)
  910. {
  911. int idx = ext_disp_get_port_idx(kcontrol);
  912. if (idx < 0)
  913. return idx;
  914. ucontrol->value.integer.value[0] =
  915. ext_disp_rx_cfg[idx].channels - 2;
  916. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  917. idx, ext_disp_rx_cfg[idx].channels);
  918. return 0;
  919. }
  920. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  921. struct snd_ctl_elem_value *ucontrol)
  922. {
  923. int idx = ext_disp_get_port_idx(kcontrol);
  924. if (idx < 0)
  925. return idx;
  926. ext_disp_rx_cfg[idx].channels =
  927. ucontrol->value.integer.value[0] + 2;
  928. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  929. idx, ext_disp_rx_cfg[idx].channels);
  930. return 1;
  931. }
  932. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  933. struct snd_ctl_elem_value *ucontrol)
  934. {
  935. int sample_rate_val;
  936. int idx = ext_disp_get_port_idx(kcontrol);
  937. if (idx < 0)
  938. return idx;
  939. switch (ext_disp_rx_cfg[idx].sample_rate) {
  940. case SAMPLING_RATE_176P4KHZ:
  941. sample_rate_val = 6;
  942. break;
  943. case SAMPLING_RATE_88P2KHZ:
  944. sample_rate_val = 5;
  945. break;
  946. case SAMPLING_RATE_44P1KHZ:
  947. sample_rate_val = 4;
  948. break;
  949. case SAMPLING_RATE_32KHZ:
  950. sample_rate_val = 3;
  951. break;
  952. case SAMPLING_RATE_192KHZ:
  953. sample_rate_val = 2;
  954. break;
  955. case SAMPLING_RATE_96KHZ:
  956. sample_rate_val = 1;
  957. break;
  958. case SAMPLING_RATE_48KHZ:
  959. default:
  960. sample_rate_val = 0;
  961. break;
  962. }
  963. ucontrol->value.integer.value[0] = sample_rate_val;
  964. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  965. idx, ext_disp_rx_cfg[idx].sample_rate);
  966. return 0;
  967. }
  968. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  969. struct snd_ctl_elem_value *ucontrol)
  970. {
  971. int idx = ext_disp_get_port_idx(kcontrol);
  972. if (idx < 0)
  973. return idx;
  974. switch (ucontrol->value.integer.value[0]) {
  975. case 6:
  976. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  977. break;
  978. case 5:
  979. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  980. break;
  981. case 4:
  982. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  983. break;
  984. case 3:
  985. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  986. break;
  987. case 2:
  988. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  989. break;
  990. case 1:
  991. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  992. break;
  993. case 0:
  994. default:
  995. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  996. break;
  997. }
  998. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  999. __func__, ucontrol->value.integer.value[0], idx,
  1000. ext_disp_rx_cfg[idx].sample_rate);
  1001. return 0;
  1002. }
  1003. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1004. struct snd_ctl_elem_value *ucontrol)
  1005. {
  1006. pr_debug("%s: proxy_rx channels = %d\n",
  1007. __func__, proxy_rx_cfg.channels);
  1008. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1009. return 0;
  1010. }
  1011. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1012. struct snd_ctl_elem_value *ucontrol)
  1013. {
  1014. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1015. pr_debug("%s: proxy_rx channels = %d\n",
  1016. __func__, proxy_rx_cfg.channels);
  1017. return 1;
  1018. }
  1019. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1020. struct tdm_port *port)
  1021. {
  1022. if (port) {
  1023. if (strnstr(kcontrol->id.name, "PRI",
  1024. sizeof(kcontrol->id.name))) {
  1025. port->mode = TDM_PRI;
  1026. } else if (strnstr(kcontrol->id.name, "SEC",
  1027. sizeof(kcontrol->id.name))) {
  1028. port->mode = TDM_SEC;
  1029. } else if (strnstr(kcontrol->id.name, "TERT",
  1030. sizeof(kcontrol->id.name))) {
  1031. port->mode = TDM_TERT;
  1032. } else {
  1033. pr_err("%s: unsupported mode in: %s\n",
  1034. __func__, kcontrol->id.name);
  1035. return -EINVAL;
  1036. }
  1037. if (strnstr(kcontrol->id.name, "RX_0",
  1038. sizeof(kcontrol->id.name)) ||
  1039. strnstr(kcontrol->id.name, "TX_0",
  1040. sizeof(kcontrol->id.name))) {
  1041. port->channel = TDM_0;
  1042. } else if (strnstr(kcontrol->id.name, "RX_1",
  1043. sizeof(kcontrol->id.name)) ||
  1044. strnstr(kcontrol->id.name, "TX_1",
  1045. sizeof(kcontrol->id.name))) {
  1046. port->channel = TDM_1;
  1047. } else if (strnstr(kcontrol->id.name, "RX_2",
  1048. sizeof(kcontrol->id.name)) ||
  1049. strnstr(kcontrol->id.name, "TX_2",
  1050. sizeof(kcontrol->id.name))) {
  1051. port->channel = TDM_2;
  1052. } else if (strnstr(kcontrol->id.name, "RX_3",
  1053. sizeof(kcontrol->id.name)) ||
  1054. strnstr(kcontrol->id.name, "TX_3",
  1055. sizeof(kcontrol->id.name))) {
  1056. port->channel = TDM_3;
  1057. } else if (strnstr(kcontrol->id.name, "RX_4",
  1058. sizeof(kcontrol->id.name)) ||
  1059. strnstr(kcontrol->id.name, "TX_4",
  1060. sizeof(kcontrol->id.name))) {
  1061. port->channel = TDM_4;
  1062. } else if (strnstr(kcontrol->id.name, "RX_5",
  1063. sizeof(kcontrol->id.name)) ||
  1064. strnstr(kcontrol->id.name, "TX_5",
  1065. sizeof(kcontrol->id.name))) {
  1066. port->channel = TDM_5;
  1067. } else if (strnstr(kcontrol->id.name, "RX_6",
  1068. sizeof(kcontrol->id.name)) ||
  1069. strnstr(kcontrol->id.name, "TX_6",
  1070. sizeof(kcontrol->id.name))) {
  1071. port->channel = TDM_6;
  1072. } else if (strnstr(kcontrol->id.name, "RX_7",
  1073. sizeof(kcontrol->id.name)) ||
  1074. strnstr(kcontrol->id.name, "TX_7",
  1075. sizeof(kcontrol->id.name))) {
  1076. port->channel = TDM_7;
  1077. } else {
  1078. pr_err("%s: unsupported channel in: %s\n",
  1079. __func__, kcontrol->id.name);
  1080. return -EINVAL;
  1081. }
  1082. } else {
  1083. return -EINVAL;
  1084. }
  1085. return 0;
  1086. }
  1087. static int tdm_get_sample_rate(int value)
  1088. {
  1089. int sample_rate = 0;
  1090. switch (value) {
  1091. case 0:
  1092. sample_rate = SAMPLING_RATE_8KHZ;
  1093. break;
  1094. case 1:
  1095. sample_rate = SAMPLING_RATE_16KHZ;
  1096. break;
  1097. case 2:
  1098. sample_rate = SAMPLING_RATE_32KHZ;
  1099. break;
  1100. case 3:
  1101. sample_rate = SAMPLING_RATE_48KHZ;
  1102. break;
  1103. case 4:
  1104. sample_rate = SAMPLING_RATE_176P4KHZ;
  1105. break;
  1106. case 5:
  1107. sample_rate = SAMPLING_RATE_352P8KHZ;
  1108. break;
  1109. default:
  1110. sample_rate = SAMPLING_RATE_48KHZ;
  1111. break;
  1112. }
  1113. return sample_rate;
  1114. }
  1115. static int tdm_get_sample_rate_val(int sample_rate)
  1116. {
  1117. int sample_rate_val = 0;
  1118. switch (sample_rate) {
  1119. case SAMPLING_RATE_8KHZ:
  1120. sample_rate_val = 0;
  1121. break;
  1122. case SAMPLING_RATE_16KHZ:
  1123. sample_rate_val = 1;
  1124. break;
  1125. case SAMPLING_RATE_32KHZ:
  1126. sample_rate_val = 2;
  1127. break;
  1128. case SAMPLING_RATE_48KHZ:
  1129. sample_rate_val = 3;
  1130. break;
  1131. case SAMPLING_RATE_176P4KHZ:
  1132. sample_rate_val = 4;
  1133. break;
  1134. case SAMPLING_RATE_352P8KHZ:
  1135. sample_rate_val = 5;
  1136. break;
  1137. default:
  1138. sample_rate_val = 3;
  1139. break;
  1140. }
  1141. return sample_rate_val;
  1142. }
  1143. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1144. struct snd_ctl_elem_value *ucontrol)
  1145. {
  1146. struct tdm_port port;
  1147. int ret = tdm_get_port_idx(kcontrol, &port);
  1148. if (ret) {
  1149. pr_err("%s: unsupported control: %s\n",
  1150. __func__, kcontrol->id.name);
  1151. } else {
  1152. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1153. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1154. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1155. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1156. ucontrol->value.enumerated.item[0]);
  1157. }
  1158. return ret;
  1159. }
  1160. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1161. struct snd_ctl_elem_value *ucontrol)
  1162. {
  1163. struct tdm_port port;
  1164. int ret = tdm_get_port_idx(kcontrol, &port);
  1165. if (ret) {
  1166. pr_err("%s: unsupported control: %s\n",
  1167. __func__, kcontrol->id.name);
  1168. } else {
  1169. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1170. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1171. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1172. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1173. ucontrol->value.enumerated.item[0]);
  1174. }
  1175. return ret;
  1176. }
  1177. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1178. struct snd_ctl_elem_value *ucontrol)
  1179. {
  1180. struct tdm_port port;
  1181. int ret = tdm_get_port_idx(kcontrol, &port);
  1182. if (ret) {
  1183. pr_err("%s: unsupported control: %s\n",
  1184. __func__, kcontrol->id.name);
  1185. } else {
  1186. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1187. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1188. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1189. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1190. ucontrol->value.enumerated.item[0]);
  1191. }
  1192. return ret;
  1193. }
  1194. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1195. struct snd_ctl_elem_value *ucontrol)
  1196. {
  1197. struct tdm_port port;
  1198. int ret = tdm_get_port_idx(kcontrol, &port);
  1199. if (ret) {
  1200. pr_err("%s: unsupported control: %s\n",
  1201. __func__, kcontrol->id.name);
  1202. } else {
  1203. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1204. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1205. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1206. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1207. ucontrol->value.enumerated.item[0]);
  1208. }
  1209. return ret;
  1210. }
  1211. static int tdm_get_format(int value)
  1212. {
  1213. int format = 0;
  1214. switch (value) {
  1215. case 0:
  1216. format = SNDRV_PCM_FORMAT_S16_LE;
  1217. break;
  1218. case 1:
  1219. format = SNDRV_PCM_FORMAT_S24_LE;
  1220. break;
  1221. case 2:
  1222. format = SNDRV_PCM_FORMAT_S32_LE;
  1223. break;
  1224. default:
  1225. format = SNDRV_PCM_FORMAT_S16_LE;
  1226. break;
  1227. }
  1228. return format;
  1229. }
  1230. static int tdm_get_format_val(int format)
  1231. {
  1232. int value = 0;
  1233. switch (format) {
  1234. case SNDRV_PCM_FORMAT_S16_LE:
  1235. value = 0;
  1236. break;
  1237. case SNDRV_PCM_FORMAT_S24_LE:
  1238. value = 1;
  1239. break;
  1240. case SNDRV_PCM_FORMAT_S32_LE:
  1241. value = 2;
  1242. break;
  1243. default:
  1244. value = 0;
  1245. break;
  1246. }
  1247. return value;
  1248. }
  1249. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1250. struct snd_ctl_elem_value *ucontrol)
  1251. {
  1252. struct tdm_port port;
  1253. int ret = tdm_get_port_idx(kcontrol, &port);
  1254. if (ret) {
  1255. pr_err("%s: unsupported control: %s\n",
  1256. __func__, kcontrol->id.name);
  1257. } else {
  1258. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1259. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1260. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1261. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1262. ucontrol->value.enumerated.item[0]);
  1263. }
  1264. return ret;
  1265. }
  1266. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1267. struct snd_ctl_elem_value *ucontrol)
  1268. {
  1269. struct tdm_port port;
  1270. int ret = tdm_get_port_idx(kcontrol, &port);
  1271. if (ret) {
  1272. pr_err("%s: unsupported control: %s\n",
  1273. __func__, kcontrol->id.name);
  1274. } else {
  1275. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1276. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1277. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1278. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1279. ucontrol->value.enumerated.item[0]);
  1280. }
  1281. return ret;
  1282. }
  1283. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1284. struct snd_ctl_elem_value *ucontrol)
  1285. {
  1286. struct tdm_port port;
  1287. int ret = tdm_get_port_idx(kcontrol, &port);
  1288. if (ret) {
  1289. pr_err("%s: unsupported control: %s\n",
  1290. __func__, kcontrol->id.name);
  1291. } else {
  1292. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1293. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1294. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1295. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1296. ucontrol->value.enumerated.item[0]);
  1297. }
  1298. return ret;
  1299. }
  1300. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1301. struct snd_ctl_elem_value *ucontrol)
  1302. {
  1303. struct tdm_port port;
  1304. int ret = tdm_get_port_idx(kcontrol, &port);
  1305. if (ret) {
  1306. pr_err("%s: unsupported control: %s\n",
  1307. __func__, kcontrol->id.name);
  1308. } else {
  1309. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1310. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1311. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1312. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1313. ucontrol->value.enumerated.item[0]);
  1314. }
  1315. return ret;
  1316. }
  1317. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1318. struct snd_ctl_elem_value *ucontrol)
  1319. {
  1320. struct tdm_port port;
  1321. int ret = tdm_get_port_idx(kcontrol, &port);
  1322. if (ret) {
  1323. pr_err("%s: unsupported control: %s\n",
  1324. __func__, kcontrol->id.name);
  1325. } else {
  1326. ucontrol->value.enumerated.item[0] =
  1327. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1328. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1329. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1330. ucontrol->value.enumerated.item[0]);
  1331. }
  1332. return ret;
  1333. }
  1334. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1335. struct snd_ctl_elem_value *ucontrol)
  1336. {
  1337. struct tdm_port port;
  1338. int ret = tdm_get_port_idx(kcontrol, &port);
  1339. if (ret) {
  1340. pr_err("%s: unsupported control: %s\n",
  1341. __func__, kcontrol->id.name);
  1342. } else {
  1343. tdm_rx_cfg[port.mode][port.channel].channels =
  1344. ucontrol->value.enumerated.item[0] + 1;
  1345. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1346. tdm_rx_cfg[port.mode][port.channel].channels,
  1347. ucontrol->value.enumerated.item[0] + 1);
  1348. }
  1349. return ret;
  1350. }
  1351. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1352. struct snd_ctl_elem_value *ucontrol)
  1353. {
  1354. struct tdm_port port;
  1355. int ret = tdm_get_port_idx(kcontrol, &port);
  1356. if (ret) {
  1357. pr_err("%s: unsupported control: %s\n",
  1358. __func__, kcontrol->id.name);
  1359. } else {
  1360. ucontrol->value.enumerated.item[0] =
  1361. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1362. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1363. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1364. ucontrol->value.enumerated.item[0]);
  1365. }
  1366. return ret;
  1367. }
  1368. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1369. struct snd_ctl_elem_value *ucontrol)
  1370. {
  1371. struct tdm_port port;
  1372. int ret = tdm_get_port_idx(kcontrol, &port);
  1373. if (ret) {
  1374. pr_err("%s: unsupported control: %s\n",
  1375. __func__, kcontrol->id.name);
  1376. } else {
  1377. tdm_tx_cfg[port.mode][port.channel].channels =
  1378. ucontrol->value.enumerated.item[0] + 1;
  1379. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1380. tdm_tx_cfg[port.mode][port.channel].channels,
  1381. ucontrol->value.enumerated.item[0] + 1);
  1382. }
  1383. return ret;
  1384. }
  1385. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1386. {
  1387. int idx = 0;
  1388. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1389. sizeof("PRIM_AUX_PCM"))) {
  1390. idx = PRIM_AUX_PCM;
  1391. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1392. sizeof("SEC_AUX_PCM"))) {
  1393. idx = SEC_AUX_PCM;
  1394. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1395. sizeof("TERT_AUX_PCM"))) {
  1396. idx = TERT_AUX_PCM;
  1397. } else {
  1398. pr_err("%s: unsupported port: %s\n",
  1399. __func__, kcontrol->id.name);
  1400. idx = -EINVAL;
  1401. }
  1402. return idx;
  1403. }
  1404. static int aux_pcm_get_sample_rate(int value)
  1405. {
  1406. int sample_rate = 0;
  1407. switch (value) {
  1408. case 1:
  1409. sample_rate = SAMPLING_RATE_16KHZ;
  1410. break;
  1411. case 0:
  1412. default:
  1413. sample_rate = SAMPLING_RATE_8KHZ;
  1414. break;
  1415. }
  1416. return sample_rate;
  1417. }
  1418. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1419. {
  1420. int sample_rate_val = 0;
  1421. switch (sample_rate) {
  1422. case SAMPLING_RATE_16KHZ:
  1423. sample_rate_val = 1;
  1424. break;
  1425. case SAMPLING_RATE_8KHZ:
  1426. default:
  1427. sample_rate_val = 0;
  1428. break;
  1429. }
  1430. return sample_rate_val;
  1431. }
  1432. static int mi2s_auxpcm_get_format(int value)
  1433. {
  1434. int format = 0;
  1435. switch (value) {
  1436. case 0:
  1437. format = SNDRV_PCM_FORMAT_S16_LE;
  1438. break;
  1439. case 1:
  1440. format = SNDRV_PCM_FORMAT_S24_LE;
  1441. break;
  1442. case 2:
  1443. format = SNDRV_PCM_FORMAT_S24_3LE;
  1444. break;
  1445. case 3:
  1446. format = SNDRV_PCM_FORMAT_S32_LE;
  1447. break;
  1448. default:
  1449. format = SNDRV_PCM_FORMAT_S16_LE;
  1450. break;
  1451. }
  1452. return format;
  1453. }
  1454. static int mi2s_auxpcm_get_format_value(int format)
  1455. {
  1456. int value = 0;
  1457. switch (format) {
  1458. case SNDRV_PCM_FORMAT_S16_LE:
  1459. value = 0;
  1460. break;
  1461. case SNDRV_PCM_FORMAT_S24_LE:
  1462. value = 1;
  1463. break;
  1464. case SNDRV_PCM_FORMAT_S24_3LE:
  1465. value = 2;
  1466. break;
  1467. case SNDRV_PCM_FORMAT_S32_LE:
  1468. value = 3;
  1469. break;
  1470. default:
  1471. value = 0;
  1472. break;
  1473. }
  1474. return value;
  1475. }
  1476. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1477. struct snd_ctl_elem_value *ucontrol)
  1478. {
  1479. int idx = aux_pcm_get_port_idx(kcontrol);
  1480. if (idx < 0)
  1481. return idx;
  1482. ucontrol->value.enumerated.item[0] =
  1483. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1484. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1485. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1486. ucontrol->value.enumerated.item[0]);
  1487. return 0;
  1488. }
  1489. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1490. struct snd_ctl_elem_value *ucontrol)
  1491. {
  1492. int idx = aux_pcm_get_port_idx(kcontrol);
  1493. if (idx < 0)
  1494. return idx;
  1495. aux_pcm_rx_cfg[idx].sample_rate =
  1496. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1497. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1498. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1499. ucontrol->value.enumerated.item[0]);
  1500. return 0;
  1501. }
  1502. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1503. struct snd_ctl_elem_value *ucontrol)
  1504. {
  1505. int idx = aux_pcm_get_port_idx(kcontrol);
  1506. if (idx < 0)
  1507. return idx;
  1508. ucontrol->value.enumerated.item[0] =
  1509. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  1510. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1511. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1512. ucontrol->value.enumerated.item[0]);
  1513. return 0;
  1514. }
  1515. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1516. struct snd_ctl_elem_value *ucontrol)
  1517. {
  1518. int idx = aux_pcm_get_port_idx(kcontrol);
  1519. if (idx < 0)
  1520. return idx;
  1521. aux_pcm_tx_cfg[idx].sample_rate =
  1522. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1523. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1524. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1525. ucontrol->value.enumerated.item[0]);
  1526. return 0;
  1527. }
  1528. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  1529. struct snd_ctl_elem_value *ucontrol)
  1530. {
  1531. int idx = aux_pcm_get_port_idx(kcontrol);
  1532. if (idx < 0)
  1533. return idx;
  1534. ucontrol->value.enumerated.item[0] =
  1535. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  1536. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1537. idx, aux_pcm_rx_cfg[idx].bit_format,
  1538. ucontrol->value.enumerated.item[0]);
  1539. return 0;
  1540. }
  1541. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  1542. struct snd_ctl_elem_value *ucontrol)
  1543. {
  1544. int idx = aux_pcm_get_port_idx(kcontrol);
  1545. if (idx < 0)
  1546. return idx;
  1547. aux_pcm_rx_cfg[idx].bit_format =
  1548. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1549. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1550. idx, aux_pcm_rx_cfg[idx].bit_format,
  1551. ucontrol->value.enumerated.item[0]);
  1552. return 0;
  1553. }
  1554. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  1555. struct snd_ctl_elem_value *ucontrol)
  1556. {
  1557. int idx = aux_pcm_get_port_idx(kcontrol);
  1558. if (idx < 0)
  1559. return idx;
  1560. ucontrol->value.enumerated.item[0] =
  1561. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  1562. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1563. idx, aux_pcm_tx_cfg[idx].bit_format,
  1564. ucontrol->value.enumerated.item[0]);
  1565. return 0;
  1566. }
  1567. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  1568. struct snd_ctl_elem_value *ucontrol)
  1569. {
  1570. int idx = aux_pcm_get_port_idx(kcontrol);
  1571. if (idx < 0)
  1572. return idx;
  1573. aux_pcm_tx_cfg[idx].bit_format =
  1574. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1575. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1576. idx, aux_pcm_tx_cfg[idx].bit_format,
  1577. ucontrol->value.enumerated.item[0]);
  1578. return 0;
  1579. }
  1580. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  1581. {
  1582. int idx = 0;
  1583. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  1584. sizeof("PRIM_MI2S_RX"))) {
  1585. idx = PRIM_MI2S;
  1586. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  1587. sizeof("SEC_MI2S_RX"))) {
  1588. idx = SEC_MI2S;
  1589. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  1590. sizeof("TERT_MI2S_RX"))) {
  1591. idx = TERT_MI2S;
  1592. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  1593. sizeof("PRIM_MI2S_TX"))) {
  1594. idx = PRIM_MI2S;
  1595. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  1596. sizeof("SEC_MI2S_TX"))) {
  1597. idx = SEC_MI2S;
  1598. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  1599. sizeof("TERT_MI2S_TX"))) {
  1600. idx = TERT_MI2S;
  1601. } else {
  1602. pr_err("%s: unsupported channel: %s\n",
  1603. __func__, kcontrol->id.name);
  1604. idx = -EINVAL;
  1605. }
  1606. return idx;
  1607. }
  1608. static int mi2s_get_sample_rate(int value)
  1609. {
  1610. int sample_rate = 0;
  1611. switch (value) {
  1612. case 0:
  1613. sample_rate = SAMPLING_RATE_8KHZ;
  1614. break;
  1615. case 1:
  1616. sample_rate = SAMPLING_RATE_11P025KHZ;
  1617. break;
  1618. case 2:
  1619. sample_rate = SAMPLING_RATE_16KHZ;
  1620. break;
  1621. case 3:
  1622. sample_rate = SAMPLING_RATE_22P05KHZ;
  1623. break;
  1624. case 4:
  1625. sample_rate = SAMPLING_RATE_32KHZ;
  1626. break;
  1627. case 5:
  1628. sample_rate = SAMPLING_RATE_44P1KHZ;
  1629. break;
  1630. case 6:
  1631. sample_rate = SAMPLING_RATE_48KHZ;
  1632. break;
  1633. case 7:
  1634. sample_rate = SAMPLING_RATE_96KHZ;
  1635. break;
  1636. case 8:
  1637. sample_rate = SAMPLING_RATE_192KHZ;
  1638. break;
  1639. default:
  1640. sample_rate = SAMPLING_RATE_48KHZ;
  1641. break;
  1642. }
  1643. return sample_rate;
  1644. }
  1645. static int mi2s_get_sample_rate_val(int sample_rate)
  1646. {
  1647. int sample_rate_val = 0;
  1648. switch (sample_rate) {
  1649. case SAMPLING_RATE_8KHZ:
  1650. sample_rate_val = 0;
  1651. break;
  1652. case SAMPLING_RATE_11P025KHZ:
  1653. sample_rate_val = 1;
  1654. break;
  1655. case SAMPLING_RATE_16KHZ:
  1656. sample_rate_val = 2;
  1657. break;
  1658. case SAMPLING_RATE_22P05KHZ:
  1659. sample_rate_val = 3;
  1660. break;
  1661. case SAMPLING_RATE_32KHZ:
  1662. sample_rate_val = 4;
  1663. break;
  1664. case SAMPLING_RATE_44P1KHZ:
  1665. sample_rate_val = 5;
  1666. break;
  1667. case SAMPLING_RATE_48KHZ:
  1668. sample_rate_val = 6;
  1669. break;
  1670. case SAMPLING_RATE_96KHZ:
  1671. sample_rate_val = 7;
  1672. break;
  1673. case SAMPLING_RATE_192KHZ:
  1674. sample_rate_val = 8;
  1675. break;
  1676. default:
  1677. sample_rate_val = 6;
  1678. break;
  1679. }
  1680. return sample_rate_val;
  1681. }
  1682. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1683. struct snd_ctl_elem_value *ucontrol)
  1684. {
  1685. int idx = mi2s_get_port_idx(kcontrol);
  1686. if (idx < 0)
  1687. return idx;
  1688. ucontrol->value.enumerated.item[0] =
  1689. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  1690. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1691. idx, mi2s_rx_cfg[idx].sample_rate,
  1692. ucontrol->value.enumerated.item[0]);
  1693. return 0;
  1694. }
  1695. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1696. struct snd_ctl_elem_value *ucontrol)
  1697. {
  1698. int idx = mi2s_get_port_idx(kcontrol);
  1699. if (idx < 0)
  1700. return idx;
  1701. mi2s_rx_cfg[idx].sample_rate =
  1702. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1703. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1704. idx, mi2s_rx_cfg[idx].sample_rate,
  1705. ucontrol->value.enumerated.item[0]);
  1706. return 0;
  1707. }
  1708. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1709. struct snd_ctl_elem_value *ucontrol)
  1710. {
  1711. int idx = mi2s_get_port_idx(kcontrol);
  1712. if (idx < 0)
  1713. return idx;
  1714. ucontrol->value.enumerated.item[0] =
  1715. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  1716. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1717. idx, mi2s_tx_cfg[idx].sample_rate,
  1718. ucontrol->value.enumerated.item[0]);
  1719. return 0;
  1720. }
  1721. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1722. struct snd_ctl_elem_value *ucontrol)
  1723. {
  1724. int idx = mi2s_get_port_idx(kcontrol);
  1725. if (idx < 0)
  1726. return idx;
  1727. mi2s_tx_cfg[idx].sample_rate =
  1728. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1729. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1730. idx, mi2s_tx_cfg[idx].sample_rate,
  1731. ucontrol->value.enumerated.item[0]);
  1732. return 0;
  1733. }
  1734. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  1735. struct snd_ctl_elem_value *ucontrol)
  1736. {
  1737. int idx = mi2s_get_port_idx(kcontrol);
  1738. if (idx < 0)
  1739. return idx;
  1740. ucontrol->value.enumerated.item[0] =
  1741. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  1742. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1743. idx, mi2s_rx_cfg[idx].bit_format,
  1744. ucontrol->value.enumerated.item[0]);
  1745. return 0;
  1746. }
  1747. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  1748. struct snd_ctl_elem_value *ucontrol)
  1749. {
  1750. int idx = mi2s_get_port_idx(kcontrol);
  1751. if (idx < 0)
  1752. return idx;
  1753. mi2s_rx_cfg[idx].bit_format =
  1754. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1755. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1756. idx, mi2s_rx_cfg[idx].bit_format,
  1757. ucontrol->value.enumerated.item[0]);
  1758. return 0;
  1759. }
  1760. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  1761. struct snd_ctl_elem_value *ucontrol)
  1762. {
  1763. int idx = mi2s_get_port_idx(kcontrol);
  1764. if (idx < 0)
  1765. return idx;
  1766. ucontrol->value.enumerated.item[0] =
  1767. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  1768. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1769. idx, mi2s_tx_cfg[idx].bit_format,
  1770. ucontrol->value.enumerated.item[0]);
  1771. return 0;
  1772. }
  1773. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  1774. struct snd_ctl_elem_value *ucontrol)
  1775. {
  1776. int idx = mi2s_get_port_idx(kcontrol);
  1777. if (idx < 0)
  1778. return idx;
  1779. mi2s_tx_cfg[idx].bit_format =
  1780. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1781. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1782. idx, mi2s_tx_cfg[idx].bit_format,
  1783. ucontrol->value.enumerated.item[0]);
  1784. return 0;
  1785. }
  1786. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  1787. struct snd_ctl_elem_value *ucontrol)
  1788. {
  1789. int idx = mi2s_get_port_idx(kcontrol);
  1790. if (idx < 0)
  1791. return idx;
  1792. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1793. idx, mi2s_rx_cfg[idx].channels);
  1794. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  1795. return 0;
  1796. }
  1797. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  1798. struct snd_ctl_elem_value *ucontrol)
  1799. {
  1800. int idx = mi2s_get_port_idx(kcontrol);
  1801. if (idx < 0)
  1802. return idx;
  1803. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1804. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1805. idx, mi2s_rx_cfg[idx].channels);
  1806. return 1;
  1807. }
  1808. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  1809. struct snd_ctl_elem_value *ucontrol)
  1810. {
  1811. int idx = mi2s_get_port_idx(kcontrol);
  1812. if (idx < 0)
  1813. return idx;
  1814. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1815. idx, mi2s_tx_cfg[idx].channels);
  1816. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  1817. return 0;
  1818. }
  1819. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  1820. struct snd_ctl_elem_value *ucontrol)
  1821. {
  1822. int idx = mi2s_get_port_idx(kcontrol);
  1823. if (idx < 0)
  1824. return idx;
  1825. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1826. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1827. idx, mi2s_tx_cfg[idx].channels);
  1828. return 1;
  1829. }
  1830. static int msm_get_port_id(int be_id)
  1831. {
  1832. int afe_port_id = 0;
  1833. switch (be_id) {
  1834. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  1835. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  1836. break;
  1837. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  1838. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  1839. break;
  1840. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  1841. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  1842. break;
  1843. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  1844. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  1845. break;
  1846. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  1847. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  1848. break;
  1849. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  1850. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  1851. break;
  1852. default:
  1853. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  1854. afe_port_id = -EINVAL;
  1855. }
  1856. return afe_port_id;
  1857. }
  1858. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  1859. {
  1860. u32 bit_per_sample = 0;
  1861. switch (bit_format) {
  1862. case SNDRV_PCM_FORMAT_S32_LE:
  1863. case SNDRV_PCM_FORMAT_S24_3LE:
  1864. case SNDRV_PCM_FORMAT_S24_LE:
  1865. bit_per_sample = 32;
  1866. break;
  1867. case SNDRV_PCM_FORMAT_S16_LE:
  1868. default:
  1869. bit_per_sample = 16;
  1870. break;
  1871. }
  1872. return bit_per_sample;
  1873. }
  1874. static void update_mi2s_clk_val(int dai_id, int stream)
  1875. {
  1876. u32 bit_per_sample = 0;
  1877. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1878. bit_per_sample =
  1879. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  1880. mi2s_clk[dai_id].clk_freq_in_hz =
  1881. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1882. } else {
  1883. bit_per_sample =
  1884. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  1885. mi2s_clk[dai_id].clk_freq_in_hz =
  1886. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1887. }
  1888. }
  1889. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  1890. {
  1891. int ret = 0;
  1892. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1893. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1894. int port_id = 0;
  1895. int index = cpu_dai->id;
  1896. port_id = msm_get_port_id(rtd->dai_link->id);
  1897. if (port_id < 0) {
  1898. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  1899. ret = port_id;
  1900. goto err;
  1901. }
  1902. if (enable) {
  1903. update_mi2s_clk_val(index, substream->stream);
  1904. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  1905. mi2s_clk[index].clk_freq_in_hz);
  1906. }
  1907. mi2s_clk[index].enable = enable;
  1908. ret = afe_set_lpass_clock_v2(port_id,
  1909. &mi2s_clk[index]);
  1910. if (ret < 0) {
  1911. dev_err(rtd->card->dev,
  1912. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  1913. __func__, port_id, ret);
  1914. goto err;
  1915. }
  1916. err:
  1917. return ret;
  1918. }
  1919. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  1920. {
  1921. int idx = 0;
  1922. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  1923. sizeof("WSA_CDC_DMA_RX_0")))
  1924. idx = WSA_CDC_DMA_RX_0;
  1925. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  1926. sizeof("WSA_CDC_DMA_RX_0")))
  1927. idx = WSA_CDC_DMA_RX_1;
  1928. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  1929. sizeof("RX_CDC_DMA_RX_0")))
  1930. idx = RX_CDC_DMA_RX_0;
  1931. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  1932. sizeof("RX_CDC_DMA_RX_1")))
  1933. idx = RX_CDC_DMA_RX_1;
  1934. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  1935. sizeof("RX_CDC_DMA_RX_2")))
  1936. idx = RX_CDC_DMA_RX_2;
  1937. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  1938. sizeof("RX_CDC_DMA_RX_3")))
  1939. idx = RX_CDC_DMA_RX_3;
  1940. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  1941. sizeof("RX_CDC_DMA_RX_5")))
  1942. idx = RX_CDC_DMA_RX_5;
  1943. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  1944. sizeof("WSA_CDC_DMA_TX_0")))
  1945. idx = WSA_CDC_DMA_TX_0;
  1946. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  1947. sizeof("WSA_CDC_DMA_TX_1")))
  1948. idx = WSA_CDC_DMA_TX_1;
  1949. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  1950. sizeof("WSA_CDC_DMA_TX_2")))
  1951. idx = WSA_CDC_DMA_TX_2;
  1952. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  1953. sizeof("TX_CDC_DMA_TX_0")))
  1954. idx = TX_CDC_DMA_TX_0;
  1955. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  1956. sizeof("TX_CDC_DMA_TX_3")))
  1957. idx = TX_CDC_DMA_TX_3;
  1958. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  1959. sizeof("TX_CDC_DMA_TX_4")))
  1960. idx = TX_CDC_DMA_TX_4;
  1961. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  1962. sizeof("VA_CDC_DMA_TX_0")))
  1963. idx = VA_CDC_DMA_TX_0;
  1964. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  1965. sizeof("VA_CDC_DMA_TX_1")))
  1966. idx = VA_CDC_DMA_TX_1;
  1967. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  1968. sizeof("VA_CDC_DMA_TX_2")))
  1969. idx = VA_CDC_DMA_TX_2;
  1970. else {
  1971. pr_err("%s: unsupported channel: %s\n",
  1972. __func__, kcontrol->id.name);
  1973. return -EINVAL;
  1974. }
  1975. return idx;
  1976. }
  1977. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  1978. struct snd_ctl_elem_value *ucontrol)
  1979. {
  1980. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1981. if (ch_num < 0) {
  1982. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1983. return ch_num;
  1984. }
  1985. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1986. cdc_dma_rx_cfg[ch_num].channels - 1);
  1987. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  1988. return 0;
  1989. }
  1990. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  1991. struct snd_ctl_elem_value *ucontrol)
  1992. {
  1993. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1994. if (ch_num < 0) {
  1995. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1996. return ch_num;
  1997. }
  1998. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1999. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2000. cdc_dma_rx_cfg[ch_num].channels);
  2001. return 1;
  2002. }
  2003. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2004. struct snd_ctl_elem_value *ucontrol)
  2005. {
  2006. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2007. if (ch_num < 0) {
  2008. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2009. return ch_num;
  2010. }
  2011. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2012. case SNDRV_PCM_FORMAT_S32_LE:
  2013. ucontrol->value.integer.value[0] = 3;
  2014. break;
  2015. case SNDRV_PCM_FORMAT_S24_3LE:
  2016. ucontrol->value.integer.value[0] = 2;
  2017. break;
  2018. case SNDRV_PCM_FORMAT_S24_LE:
  2019. ucontrol->value.integer.value[0] = 1;
  2020. break;
  2021. case SNDRV_PCM_FORMAT_S16_LE:
  2022. default:
  2023. ucontrol->value.integer.value[0] = 0;
  2024. break;
  2025. }
  2026. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2027. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2028. ucontrol->value.integer.value[0]);
  2029. return 0;
  2030. }
  2031. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2032. struct snd_ctl_elem_value *ucontrol)
  2033. {
  2034. int rc = 0;
  2035. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2036. if (ch_num < 0) {
  2037. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2038. return ch_num;
  2039. }
  2040. switch (ucontrol->value.integer.value[0]) {
  2041. case 3:
  2042. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2043. break;
  2044. case 2:
  2045. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2046. break;
  2047. case 1:
  2048. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2049. break;
  2050. case 0:
  2051. default:
  2052. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2053. break;
  2054. }
  2055. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2056. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2057. ucontrol->value.integer.value[0]);
  2058. return rc;
  2059. }
  2060. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2061. {
  2062. int sample_rate_val = 0;
  2063. switch (sample_rate) {
  2064. case SAMPLING_RATE_8KHZ:
  2065. sample_rate_val = 0;
  2066. break;
  2067. case SAMPLING_RATE_11P025KHZ:
  2068. sample_rate_val = 1;
  2069. break;
  2070. case SAMPLING_RATE_16KHZ:
  2071. sample_rate_val = 2;
  2072. break;
  2073. case SAMPLING_RATE_22P05KHZ:
  2074. sample_rate_val = 3;
  2075. break;
  2076. case SAMPLING_RATE_32KHZ:
  2077. sample_rate_val = 4;
  2078. break;
  2079. case SAMPLING_RATE_44P1KHZ:
  2080. sample_rate_val = 5;
  2081. break;
  2082. case SAMPLING_RATE_48KHZ:
  2083. sample_rate_val = 6;
  2084. break;
  2085. case SAMPLING_RATE_88P2KHZ:
  2086. sample_rate_val = 7;
  2087. break;
  2088. case SAMPLING_RATE_96KHZ:
  2089. sample_rate_val = 8;
  2090. break;
  2091. case SAMPLING_RATE_176P4KHZ:
  2092. sample_rate_val = 9;
  2093. break;
  2094. case SAMPLING_RATE_192KHZ:
  2095. sample_rate_val = 10;
  2096. break;
  2097. case SAMPLING_RATE_352P8KHZ:
  2098. sample_rate_val = 11;
  2099. break;
  2100. case SAMPLING_RATE_384KHZ:
  2101. sample_rate_val = 12;
  2102. break;
  2103. default:
  2104. sample_rate_val = 6;
  2105. break;
  2106. }
  2107. return sample_rate_val;
  2108. }
  2109. static int cdc_dma_get_sample_rate(int value)
  2110. {
  2111. int sample_rate = 0;
  2112. switch (value) {
  2113. case 0:
  2114. sample_rate = SAMPLING_RATE_8KHZ;
  2115. break;
  2116. case 1:
  2117. sample_rate = SAMPLING_RATE_11P025KHZ;
  2118. break;
  2119. case 2:
  2120. sample_rate = SAMPLING_RATE_16KHZ;
  2121. break;
  2122. case 3:
  2123. sample_rate = SAMPLING_RATE_22P05KHZ;
  2124. break;
  2125. case 4:
  2126. sample_rate = SAMPLING_RATE_32KHZ;
  2127. break;
  2128. case 5:
  2129. sample_rate = SAMPLING_RATE_44P1KHZ;
  2130. break;
  2131. case 6:
  2132. sample_rate = SAMPLING_RATE_48KHZ;
  2133. break;
  2134. case 7:
  2135. sample_rate = SAMPLING_RATE_88P2KHZ;
  2136. break;
  2137. case 8:
  2138. sample_rate = SAMPLING_RATE_96KHZ;
  2139. break;
  2140. case 9:
  2141. sample_rate = SAMPLING_RATE_176P4KHZ;
  2142. break;
  2143. case 10:
  2144. sample_rate = SAMPLING_RATE_192KHZ;
  2145. break;
  2146. case 11:
  2147. sample_rate = SAMPLING_RATE_352P8KHZ;
  2148. break;
  2149. case 12:
  2150. sample_rate = SAMPLING_RATE_384KHZ;
  2151. break;
  2152. default:
  2153. sample_rate = SAMPLING_RATE_48KHZ;
  2154. break;
  2155. }
  2156. return sample_rate;
  2157. }
  2158. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2159. struct snd_ctl_elem_value *ucontrol)
  2160. {
  2161. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2162. if (ch_num < 0) {
  2163. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2164. return ch_num;
  2165. }
  2166. ucontrol->value.enumerated.item[0] =
  2167. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2168. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2169. cdc_dma_rx_cfg[ch_num].sample_rate);
  2170. return 0;
  2171. }
  2172. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2173. struct snd_ctl_elem_value *ucontrol)
  2174. {
  2175. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2176. if (ch_num < 0) {
  2177. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2178. return ch_num;
  2179. }
  2180. cdc_dma_rx_cfg[ch_num].sample_rate =
  2181. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2182. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2183. __func__, ucontrol->value.enumerated.item[0],
  2184. cdc_dma_rx_cfg[ch_num].sample_rate);
  2185. return 0;
  2186. }
  2187. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2188. struct snd_ctl_elem_value *ucontrol)
  2189. {
  2190. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2191. if (ch_num < 0) {
  2192. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2193. return ch_num;
  2194. }
  2195. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2196. cdc_dma_tx_cfg[ch_num].channels);
  2197. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2198. return 0;
  2199. }
  2200. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2201. struct snd_ctl_elem_value *ucontrol)
  2202. {
  2203. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2204. if (ch_num < 0) {
  2205. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2206. return ch_num;
  2207. }
  2208. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2209. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2210. cdc_dma_tx_cfg[ch_num].channels);
  2211. return 1;
  2212. }
  2213. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2214. struct snd_ctl_elem_value *ucontrol)
  2215. {
  2216. int sample_rate_val;
  2217. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2218. if (ch_num < 0) {
  2219. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2220. return ch_num;
  2221. }
  2222. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2223. case SAMPLING_RATE_384KHZ:
  2224. sample_rate_val = 12;
  2225. break;
  2226. case SAMPLING_RATE_352P8KHZ:
  2227. sample_rate_val = 11;
  2228. break;
  2229. case SAMPLING_RATE_192KHZ:
  2230. sample_rate_val = 10;
  2231. break;
  2232. case SAMPLING_RATE_176P4KHZ:
  2233. sample_rate_val = 9;
  2234. break;
  2235. case SAMPLING_RATE_96KHZ:
  2236. sample_rate_val = 8;
  2237. break;
  2238. case SAMPLING_RATE_88P2KHZ:
  2239. sample_rate_val = 7;
  2240. break;
  2241. case SAMPLING_RATE_48KHZ:
  2242. sample_rate_val = 6;
  2243. break;
  2244. case SAMPLING_RATE_44P1KHZ:
  2245. sample_rate_val = 5;
  2246. break;
  2247. case SAMPLING_RATE_32KHZ:
  2248. sample_rate_val = 4;
  2249. break;
  2250. case SAMPLING_RATE_22P05KHZ:
  2251. sample_rate_val = 3;
  2252. break;
  2253. case SAMPLING_RATE_16KHZ:
  2254. sample_rate_val = 2;
  2255. break;
  2256. case SAMPLING_RATE_11P025KHZ:
  2257. sample_rate_val = 1;
  2258. break;
  2259. case SAMPLING_RATE_8KHZ:
  2260. sample_rate_val = 0;
  2261. break;
  2262. default:
  2263. sample_rate_val = 6;
  2264. break;
  2265. }
  2266. ucontrol->value.integer.value[0] = sample_rate_val;
  2267. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2268. cdc_dma_tx_cfg[ch_num].sample_rate);
  2269. return 0;
  2270. }
  2271. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2272. struct snd_ctl_elem_value *ucontrol)
  2273. {
  2274. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2275. if (ch_num < 0) {
  2276. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2277. return ch_num;
  2278. }
  2279. switch (ucontrol->value.integer.value[0]) {
  2280. case 12:
  2281. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2282. break;
  2283. case 11:
  2284. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2285. break;
  2286. case 10:
  2287. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2288. break;
  2289. case 9:
  2290. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2291. break;
  2292. case 8:
  2293. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2294. break;
  2295. case 7:
  2296. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2297. break;
  2298. case 6:
  2299. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2300. break;
  2301. case 5:
  2302. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2303. break;
  2304. case 4:
  2305. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2306. break;
  2307. case 3:
  2308. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2309. break;
  2310. case 2:
  2311. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2312. break;
  2313. case 1:
  2314. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2315. break;
  2316. case 0:
  2317. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2318. break;
  2319. default:
  2320. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2321. break;
  2322. }
  2323. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2324. __func__, ucontrol->value.integer.value[0],
  2325. cdc_dma_tx_cfg[ch_num].sample_rate);
  2326. return 0;
  2327. }
  2328. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2329. struct snd_ctl_elem_value *ucontrol)
  2330. {
  2331. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2332. if (ch_num < 0) {
  2333. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2334. return ch_num;
  2335. }
  2336. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2337. case SNDRV_PCM_FORMAT_S32_LE:
  2338. ucontrol->value.integer.value[0] = 3;
  2339. break;
  2340. case SNDRV_PCM_FORMAT_S24_3LE:
  2341. ucontrol->value.integer.value[0] = 2;
  2342. break;
  2343. case SNDRV_PCM_FORMAT_S24_LE:
  2344. ucontrol->value.integer.value[0] = 1;
  2345. break;
  2346. case SNDRV_PCM_FORMAT_S16_LE:
  2347. default:
  2348. ucontrol->value.integer.value[0] = 0;
  2349. break;
  2350. }
  2351. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2352. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2353. ucontrol->value.integer.value[0]);
  2354. return 0;
  2355. }
  2356. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2357. struct snd_ctl_elem_value *ucontrol)
  2358. {
  2359. int rc = 0;
  2360. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2361. if (ch_num < 0) {
  2362. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2363. return ch_num;
  2364. }
  2365. switch (ucontrol->value.integer.value[0]) {
  2366. case 3:
  2367. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2368. break;
  2369. case 2:
  2370. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2371. break;
  2372. case 1:
  2373. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2374. break;
  2375. case 0:
  2376. default:
  2377. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2378. break;
  2379. }
  2380. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2381. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2382. ucontrol->value.integer.value[0]);
  2383. return rc;
  2384. }
  2385. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  2386. {
  2387. int idx = 0;
  2388. switch (be_id) {
  2389. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2390. idx = WSA_CDC_DMA_RX_0;
  2391. break;
  2392. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2393. idx = WSA_CDC_DMA_TX_0;
  2394. break;
  2395. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2396. idx = WSA_CDC_DMA_RX_1;
  2397. break;
  2398. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2399. idx = WSA_CDC_DMA_TX_1;
  2400. break;
  2401. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2402. idx = WSA_CDC_DMA_TX_2;
  2403. break;
  2404. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2405. idx = RX_CDC_DMA_RX_0;
  2406. break;
  2407. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2408. idx = RX_CDC_DMA_RX_1;
  2409. break;
  2410. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2411. idx = RX_CDC_DMA_RX_2;
  2412. break;
  2413. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2414. idx = RX_CDC_DMA_RX_3;
  2415. break;
  2416. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2417. idx = RX_CDC_DMA_RX_5;
  2418. break;
  2419. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2420. idx = TX_CDC_DMA_TX_0;
  2421. break;
  2422. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2423. idx = TX_CDC_DMA_TX_3;
  2424. break;
  2425. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2426. idx = TX_CDC_DMA_TX_4;
  2427. break;
  2428. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2429. idx = VA_CDC_DMA_TX_0;
  2430. break;
  2431. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2432. idx = VA_CDC_DMA_TX_1;
  2433. break;
  2434. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2435. idx = VA_CDC_DMA_TX_2;
  2436. break;
  2437. default:
  2438. idx = RX_CDC_DMA_RX_0;
  2439. break;
  2440. }
  2441. return idx;
  2442. }
  2443. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  2444. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  2445. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2446. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  2447. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2448. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  2449. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2450. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  2451. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2452. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  2453. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2454. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  2455. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2456. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  2457. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2458. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  2459. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2460. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  2461. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2462. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  2463. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2464. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  2465. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2466. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  2467. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2468. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  2469. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2470. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  2471. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2472. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  2473. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2474. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  2475. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2476. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  2477. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2478. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  2479. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2480. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc_dma_rx_0_format,
  2481. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2482. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc_dma_rx_1_format,
  2483. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2484. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc_dma_rx_2_format,
  2485. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2486. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc_dma_rx_3_format,
  2487. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2488. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc_dma_rx_5_format,
  2489. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2490. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  2491. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2492. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  2493. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2494. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  2495. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2496. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  2497. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2498. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  2499. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2500. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  2501. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2502. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  2503. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2504. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  2505. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2506. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  2507. wsa_cdc_dma_rx_0_sample_rate,
  2508. cdc_dma_rx_sample_rate_get,
  2509. cdc_dma_rx_sample_rate_put),
  2510. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  2511. wsa_cdc_dma_rx_1_sample_rate,
  2512. cdc_dma_rx_sample_rate_get,
  2513. cdc_dma_rx_sample_rate_put),
  2514. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  2515. rx_cdc_dma_rx_0_sample_rate,
  2516. cdc_dma_rx_sample_rate_get,
  2517. cdc_dma_rx_sample_rate_put),
  2518. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  2519. rx_cdc_dma_rx_1_sample_rate,
  2520. cdc_dma_rx_sample_rate_get,
  2521. cdc_dma_rx_sample_rate_put),
  2522. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  2523. rx_cdc_dma_rx_2_sample_rate,
  2524. cdc_dma_rx_sample_rate_get,
  2525. cdc_dma_rx_sample_rate_put),
  2526. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  2527. rx_cdc_dma_rx_3_sample_rate,
  2528. cdc_dma_rx_sample_rate_get,
  2529. cdc_dma_rx_sample_rate_put),
  2530. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  2531. rx_cdc_dma_rx_5_sample_rate,
  2532. cdc_dma_rx_sample_rate_get,
  2533. cdc_dma_rx_sample_rate_put),
  2534. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  2535. wsa_cdc_dma_tx_0_sample_rate,
  2536. cdc_dma_tx_sample_rate_get,
  2537. cdc_dma_tx_sample_rate_put),
  2538. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  2539. wsa_cdc_dma_tx_1_sample_rate,
  2540. cdc_dma_tx_sample_rate_get,
  2541. cdc_dma_tx_sample_rate_put),
  2542. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  2543. wsa_cdc_dma_tx_2_sample_rate,
  2544. cdc_dma_tx_sample_rate_get,
  2545. cdc_dma_tx_sample_rate_put),
  2546. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  2547. tx_cdc_dma_tx_0_sample_rate,
  2548. cdc_dma_tx_sample_rate_get,
  2549. cdc_dma_tx_sample_rate_put),
  2550. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  2551. tx_cdc_dma_tx_3_sample_rate,
  2552. cdc_dma_tx_sample_rate_get,
  2553. cdc_dma_tx_sample_rate_put),
  2554. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  2555. tx_cdc_dma_tx_4_sample_rate,
  2556. cdc_dma_tx_sample_rate_get,
  2557. cdc_dma_tx_sample_rate_put),
  2558. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  2559. va_cdc_dma_tx_0_sample_rate,
  2560. cdc_dma_tx_sample_rate_get,
  2561. cdc_dma_tx_sample_rate_put),
  2562. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  2563. va_cdc_dma_tx_1_sample_rate,
  2564. cdc_dma_tx_sample_rate_get,
  2565. cdc_dma_tx_sample_rate_put),
  2566. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  2567. va_cdc_dma_tx_2_sample_rate,
  2568. cdc_dma_tx_sample_rate_get,
  2569. cdc_dma_tx_sample_rate_put),
  2570. };
  2571. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  2572. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  2573. usb_audio_rx_sample_rate_get,
  2574. usb_audio_rx_sample_rate_put),
  2575. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  2576. usb_audio_tx_sample_rate_get,
  2577. usb_audio_tx_sample_rate_put),
  2578. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2579. tdm_rx_sample_rate_get,
  2580. tdm_rx_sample_rate_put),
  2581. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2582. tdm_rx_sample_rate_get,
  2583. tdm_rx_sample_rate_put),
  2584. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2585. tdm_rx_sample_rate_get,
  2586. tdm_rx_sample_rate_put),
  2587. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2588. tdm_tx_sample_rate_get,
  2589. tdm_tx_sample_rate_put),
  2590. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2591. tdm_tx_sample_rate_get,
  2592. tdm_tx_sample_rate_put),
  2593. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2594. tdm_tx_sample_rate_get,
  2595. tdm_tx_sample_rate_put),
  2596. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2597. aux_pcm_rx_sample_rate_get,
  2598. aux_pcm_rx_sample_rate_put),
  2599. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  2600. aux_pcm_rx_sample_rate_get,
  2601. aux_pcm_rx_sample_rate_put),
  2602. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  2603. aux_pcm_rx_sample_rate_get,
  2604. aux_pcm_rx_sample_rate_put),
  2605. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2606. aux_pcm_tx_sample_rate_get,
  2607. aux_pcm_tx_sample_rate_put),
  2608. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  2609. aux_pcm_tx_sample_rate_get,
  2610. aux_pcm_tx_sample_rate_put),
  2611. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  2612. aux_pcm_tx_sample_rate_get,
  2613. aux_pcm_tx_sample_rate_put),
  2614. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  2615. mi2s_rx_sample_rate_get,
  2616. mi2s_rx_sample_rate_put),
  2617. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  2618. mi2s_rx_sample_rate_get,
  2619. mi2s_rx_sample_rate_put),
  2620. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  2621. mi2s_rx_sample_rate_get,
  2622. mi2s_rx_sample_rate_put),
  2623. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  2624. mi2s_tx_sample_rate_get,
  2625. mi2s_tx_sample_rate_put),
  2626. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  2627. mi2s_tx_sample_rate_get,
  2628. mi2s_tx_sample_rate_put),
  2629. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  2630. mi2s_tx_sample_rate_get,
  2631. mi2s_tx_sample_rate_put),
  2632. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  2633. usb_audio_rx_format_get, usb_audio_rx_format_put),
  2634. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  2635. usb_audio_tx_format_get, usb_audio_tx_format_put),
  2636. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  2637. tdm_rx_format_get,
  2638. tdm_rx_format_put),
  2639. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  2640. tdm_rx_format_get,
  2641. tdm_rx_format_put),
  2642. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  2643. tdm_rx_format_get,
  2644. tdm_rx_format_put),
  2645. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  2646. tdm_tx_format_get,
  2647. tdm_tx_format_put),
  2648. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  2649. tdm_tx_format_get,
  2650. tdm_tx_format_put),
  2651. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  2652. tdm_tx_format_get,
  2653. tdm_tx_format_put),
  2654. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2655. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2656. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  2657. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2658. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  2659. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2660. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2661. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2662. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  2663. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2664. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  2665. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2666. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  2667. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2668. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  2669. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2670. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  2671. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2672. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  2673. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2674. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  2675. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2676. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  2677. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2678. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  2679. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  2680. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  2681. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  2682. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  2683. proxy_rx_ch_get, proxy_rx_ch_put),
  2684. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  2685. tdm_rx_ch_get,
  2686. tdm_rx_ch_put),
  2687. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  2688. tdm_rx_ch_get,
  2689. tdm_rx_ch_put),
  2690. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  2691. tdm_rx_ch_get,
  2692. tdm_rx_ch_put),
  2693. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  2694. tdm_tx_ch_get,
  2695. tdm_tx_ch_put),
  2696. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  2697. tdm_tx_ch_get,
  2698. tdm_tx_ch_put),
  2699. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  2700. tdm_tx_ch_get,
  2701. tdm_tx_ch_put),
  2702. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  2703. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2704. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  2705. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2706. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  2707. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2708. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  2709. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2710. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  2711. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2712. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  2713. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2714. };
  2715. static const struct snd_kcontrol_new msm_snd_controls[] = {
  2716. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  2717. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  2718. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2719. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2720. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2721. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2722. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  2723. ext_disp_rx_format_get, ext_disp_rx_format_put),
  2724. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2725. aux_pcm_rx_sample_rate_get,
  2726. aux_pcm_rx_sample_rate_put),
  2727. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2728. aux_pcm_tx_sample_rate_get,
  2729. aux_pcm_tx_sample_rate_put),
  2730. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  2731. ext_disp_rx_sample_rate_get,
  2732. ext_disp_rx_sample_rate_put),
  2733. };
  2734. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  2735. {
  2736. int idx;
  2737. switch (be_id) {
  2738. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  2739. idx = EXT_DISP_RX_IDX_DP;
  2740. break;
  2741. default:
  2742. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  2743. idx = -EINVAL;
  2744. break;
  2745. }
  2746. return idx;
  2747. }
  2748. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  2749. struct snd_pcm_hw_params *params)
  2750. {
  2751. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  2752. struct snd_interval *rate = hw_param_interval(params,
  2753. SNDRV_PCM_HW_PARAM_RATE);
  2754. struct snd_interval *channels = hw_param_interval(params,
  2755. SNDRV_PCM_HW_PARAM_CHANNELS);
  2756. int idx, rc = 0;
  2757. pr_debug("%s: format = %d, rate = %d\n",
  2758. __func__, params_format(params), params_rate(params));
  2759. switch (dai_link->id) {
  2760. case MSM_BACKEND_DAI_USB_RX:
  2761. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2762. usb_rx_cfg.bit_format);
  2763. rate->min = rate->max = usb_rx_cfg.sample_rate;
  2764. channels->min = channels->max = usb_rx_cfg.channels;
  2765. break;
  2766. case MSM_BACKEND_DAI_USB_TX:
  2767. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2768. usb_tx_cfg.bit_format);
  2769. rate->min = rate->max = usb_tx_cfg.sample_rate;
  2770. channels->min = channels->max = usb_tx_cfg.channels;
  2771. break;
  2772. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  2773. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  2774. if (idx < 0) {
  2775. pr_err("%s: Incorrect ext disp idx %d\n",
  2776. __func__, idx);
  2777. rc = idx;
  2778. goto done;
  2779. }
  2780. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2781. ext_disp_rx_cfg[idx].bit_format);
  2782. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  2783. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  2784. break;
  2785. case MSM_BACKEND_DAI_AFE_PCM_RX:
  2786. channels->min = channels->max = proxy_rx_cfg.channels;
  2787. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  2788. break;
  2789. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  2790. channels->min = channels->max =
  2791. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  2792. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2793. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  2794. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  2795. break;
  2796. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  2797. channels->min = channels->max =
  2798. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  2799. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2800. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  2801. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  2802. break;
  2803. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  2804. channels->min = channels->max =
  2805. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  2806. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2807. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  2808. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  2809. break;
  2810. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  2811. channels->min = channels->max =
  2812. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  2813. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2814. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  2815. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  2816. break;
  2817. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  2818. channels->min = channels->max =
  2819. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  2820. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2821. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  2822. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  2823. break;
  2824. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  2825. channels->min = channels->max =
  2826. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  2827. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2828. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  2829. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  2830. break;
  2831. case MSM_BACKEND_DAI_AUXPCM_RX:
  2832. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2833. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  2834. rate->min = rate->max =
  2835. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  2836. channels->min = channels->max =
  2837. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  2838. break;
  2839. case MSM_BACKEND_DAI_AUXPCM_TX:
  2840. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2841. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  2842. rate->min = rate->max =
  2843. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  2844. channels->min = channels->max =
  2845. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  2846. break;
  2847. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  2848. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2849. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  2850. rate->min = rate->max =
  2851. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  2852. channels->min = channels->max =
  2853. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  2854. break;
  2855. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  2856. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2857. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  2858. rate->min = rate->max =
  2859. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  2860. channels->min = channels->max =
  2861. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  2862. break;
  2863. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  2864. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2865. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  2866. rate->min = rate->max =
  2867. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  2868. channels->min = channels->max =
  2869. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  2870. break;
  2871. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  2872. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2873. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  2874. rate->min = rate->max =
  2875. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  2876. channels->min = channels->max =
  2877. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  2878. break;
  2879. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  2880. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2881. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  2882. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  2883. channels->min = channels->max =
  2884. mi2s_rx_cfg[PRIM_MI2S].channels;
  2885. break;
  2886. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  2887. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2888. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  2889. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  2890. channels->min = channels->max =
  2891. mi2s_tx_cfg[PRIM_MI2S].channels;
  2892. break;
  2893. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  2894. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2895. mi2s_rx_cfg[SEC_MI2S].bit_format);
  2896. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  2897. channels->min = channels->max =
  2898. mi2s_rx_cfg[SEC_MI2S].channels;
  2899. break;
  2900. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  2901. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2902. mi2s_tx_cfg[SEC_MI2S].bit_format);
  2903. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  2904. channels->min = channels->max =
  2905. mi2s_tx_cfg[SEC_MI2S].channels;
  2906. break;
  2907. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  2908. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2909. mi2s_rx_cfg[TERT_MI2S].bit_format);
  2910. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  2911. channels->min = channels->max =
  2912. mi2s_rx_cfg[TERT_MI2S].channels;
  2913. break;
  2914. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  2915. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2916. mi2s_tx_cfg[TERT_MI2S].bit_format);
  2917. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  2918. channels->min = channels->max =
  2919. mi2s_tx_cfg[TERT_MI2S].channels;
  2920. break;
  2921. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2922. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2923. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2924. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  2925. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2926. cdc_dma_tx_cfg[idx].bit_format);
  2927. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  2928. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  2929. break;
  2930. default:
  2931. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  2932. break;
  2933. }
  2934. done:
  2935. return rc;
  2936. }
  2937. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  2938. {
  2939. struct snd_soc_card *card = component->card;
  2940. struct msm_asoc_mach_data *pdata =
  2941. snd_soc_card_get_drvdata(card);
  2942. if (!pdata->fsa_handle)
  2943. return false;
  2944. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  2945. }
  2946. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  2947. {
  2948. int value = 0;
  2949. bool ret = false;
  2950. struct snd_soc_card *card;
  2951. struct msm_asoc_mach_data *pdata;
  2952. if (!component) {
  2953. pr_err("%s component is NULL\n", __func__);
  2954. return false;
  2955. }
  2956. card = component->card;
  2957. pdata = snd_soc_card_get_drvdata(card);
  2958. if (!pdata)
  2959. return false;
  2960. if (wcd_mbhc_cfg.enable_usbc_analog)
  2961. return msm_usbc_swap_gnd_mic(component, active);
  2962. /* if usbc is not defined, swap using us_euro_gpio_p */
  2963. if (pdata->us_euro_gpio_p) {
  2964. value = msm_cdc_pinctrl_get_state(
  2965. pdata->us_euro_gpio_p);
  2966. if (value)
  2967. msm_cdc_pinctrl_select_sleep_state(
  2968. pdata->us_euro_gpio_p);
  2969. else
  2970. msm_cdc_pinctrl_select_active_state(
  2971. pdata->us_euro_gpio_p);
  2972. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  2973. __func__, value, !value);
  2974. ret = true;
  2975. }
  2976. return ret;
  2977. }
  2978. static int kona_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  2979. struct snd_pcm_hw_params *params)
  2980. {
  2981. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2982. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2983. int ret = 0;
  2984. int slot_width = 32;
  2985. int channels, slots;
  2986. unsigned int slot_mask, rate, clk_freq;
  2987. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  2988. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  2989. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  2990. switch (cpu_dai->id) {
  2991. case AFE_PORT_ID_PRIMARY_TDM_RX:
  2992. slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  2993. break;
  2994. case AFE_PORT_ID_SECONDARY_TDM_RX:
  2995. slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  2996. break;
  2997. case AFE_PORT_ID_TERTIARY_TDM_RX:
  2998. slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  2999. break;
  3000. case AFE_PORT_ID_PRIMARY_TDM_TX:
  3001. slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3002. break;
  3003. case AFE_PORT_ID_SECONDARY_TDM_TX:
  3004. slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3005. break;
  3006. case AFE_PORT_ID_TERTIARY_TDM_TX:
  3007. slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3008. break;
  3009. default:
  3010. pr_err("%s: dai id 0x%x not supported\n",
  3011. __func__, cpu_dai->id);
  3012. return -EINVAL;
  3013. }
  3014. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3015. /*2 slot config - bits 0 and 1 set for the first two slots */
  3016. slot_mask = 0x0000FFFF >> (16 - slots);
  3017. channels = slots;
  3018. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  3019. __func__, slot_width, slots);
  3020. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  3021. slots, slot_width);
  3022. if (ret < 0) {
  3023. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  3024. __func__, ret);
  3025. goto end;
  3026. }
  3027. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3028. 0, NULL, channels, slot_offset);
  3029. if (ret < 0) {
  3030. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  3031. __func__, ret);
  3032. goto end;
  3033. }
  3034. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  3035. /*2 slot config - bits 0 and 1 set for the first two slots */
  3036. slot_mask = 0x0000FFFF >> (16 - slots);
  3037. channels = slots;
  3038. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  3039. __func__, slot_width, slots);
  3040. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  3041. slots, slot_width);
  3042. if (ret < 0) {
  3043. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  3044. __func__, ret);
  3045. goto end;
  3046. }
  3047. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3048. channels, slot_offset, 0, NULL);
  3049. if (ret < 0) {
  3050. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  3051. __func__, ret);
  3052. goto end;
  3053. }
  3054. } else {
  3055. ret = -EINVAL;
  3056. pr_err("%s: invalid use case, err:%d\n",
  3057. __func__, ret);
  3058. goto end;
  3059. }
  3060. rate = params_rate(params);
  3061. clk_freq = rate * slot_width * slots;
  3062. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  3063. if (ret < 0)
  3064. pr_err("%s: failed to set tdm clk, err:%d\n",
  3065. __func__, ret);
  3066. end:
  3067. return ret;
  3068. }
  3069. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  3070. struct snd_pcm_hw_params *params)
  3071. {
  3072. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3073. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3074. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3075. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3076. int ret = 0;
  3077. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  3078. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3079. u32 user_set_tx_ch = 0;
  3080. u32 user_set_rx_ch = 0;
  3081. u32 ch_id;
  3082. ret = snd_soc_dai_get_channel_map(codec_dai,
  3083. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  3084. &rx_ch_cdc_dma);
  3085. if (ret < 0) {
  3086. pr_err("%s: failed to get codec chan map, err:%d\n",
  3087. __func__, ret);
  3088. goto err;
  3089. }
  3090. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3091. switch (dai_link->id) {
  3092. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3093. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3094. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3095. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3096. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3097. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3098. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  3099. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  3100. {
  3101. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3102. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  3103. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  3104. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  3105. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  3106. user_set_rx_ch, &rx_ch_cdc_dma);
  3107. if (ret < 0) {
  3108. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3109. __func__, ret);
  3110. goto err;
  3111. }
  3112. }
  3113. break;
  3114. }
  3115. } else {
  3116. switch (dai_link->id) {
  3117. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3118. {
  3119. user_set_tx_ch = msm_vi_feed_tx_ch;
  3120. }
  3121. break;
  3122. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3123. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3124. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3125. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3126. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3127. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3128. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3129. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3130. {
  3131. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3132. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  3133. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  3134. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  3135. }
  3136. break;
  3137. }
  3138. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  3139. &tx_ch_cdc_dma, 0, 0);
  3140. if (ret < 0) {
  3141. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3142. __func__, ret);
  3143. goto err;
  3144. }
  3145. }
  3146. err:
  3147. return ret;
  3148. }
  3149. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  3150. {
  3151. cpumask_t mask;
  3152. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  3153. pm_qos_remove_request(&substream->latency_pm_qos_req);
  3154. cpumask_clear(&mask);
  3155. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  3156. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  3157. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  3158. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  3159. pm_qos_add_request(&substream->latency_pm_qos_req,
  3160. PM_QOS_CPU_DMA_LATENCY,
  3161. MSM_LL_QOS_VALUE);
  3162. return 0;
  3163. }
  3164. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  3165. {
  3166. int ret = 0;
  3167. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3168. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3169. int index = cpu_dai->id;
  3170. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  3171. dev_dbg(rtd->card->dev,
  3172. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  3173. __func__, substream->name, substream->stream,
  3174. cpu_dai->name, cpu_dai->id);
  3175. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3176. ret = -EINVAL;
  3177. dev_err(rtd->card->dev,
  3178. "%s: CPU DAI id (%d) out of range\n",
  3179. __func__, cpu_dai->id);
  3180. goto err;
  3181. }
  3182. /*
  3183. * Mutex protection in case the same MI2S
  3184. * interface using for both TX and RX so
  3185. * that the same clock won't be enable twice.
  3186. */
  3187. mutex_lock(&mi2s_intf_conf[index].lock);
  3188. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  3189. /* Check if msm needs to provide the clock to the interface */
  3190. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  3191. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  3192. fmt = SND_SOC_DAIFMT_CBM_CFM;
  3193. }
  3194. ret = msm_mi2s_set_sclk(substream, true);
  3195. if (ret < 0) {
  3196. dev_err(rtd->card->dev,
  3197. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  3198. __func__, ret);
  3199. goto clean_up;
  3200. }
  3201. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  3202. if (ret < 0) {
  3203. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  3204. __func__, index, ret);
  3205. goto clk_off;
  3206. }
  3207. }
  3208. clk_off:
  3209. if (ret < 0)
  3210. msm_mi2s_set_sclk(substream, false);
  3211. clean_up:
  3212. if (ret < 0)
  3213. mi2s_intf_conf[index].ref_cnt--;
  3214. mutex_unlock(&mi2s_intf_conf[index].lock);
  3215. err:
  3216. return ret;
  3217. }
  3218. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  3219. {
  3220. int ret = 0;
  3221. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3222. int index = rtd->cpu_dai->id;
  3223. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  3224. substream->name, substream->stream);
  3225. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3226. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  3227. return;
  3228. }
  3229. mutex_lock(&mi2s_intf_conf[index].lock);
  3230. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  3231. ret = msm_mi2s_set_sclk(substream, false);
  3232. if (ret < 0)
  3233. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  3234. __func__, index, ret);
  3235. }
  3236. mutex_unlock(&mi2s_intf_conf[index].lock);
  3237. }
  3238. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  3239. struct snd_pcm_hw_params *params)
  3240. {
  3241. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3242. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3243. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3244. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3245. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  3246. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3247. int ret = 0;
  3248. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  3249. codec_dai->name, codec_dai->id);
  3250. ret = snd_soc_dai_get_channel_map(codec_dai,
  3251. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3252. if (ret) {
  3253. dev_err(rtd->dev,
  3254. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  3255. __func__, ret);
  3256. goto err;
  3257. }
  3258. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  3259. __func__, tx_ch_cnt, dai_link->id);
  3260. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3261. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  3262. if (ret)
  3263. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  3264. __func__, ret);
  3265. err:
  3266. return ret;
  3267. }
  3268. static struct snd_soc_ops kona_tdm_be_ops = {
  3269. .hw_params = kona_tdm_snd_hw_params,
  3270. };
  3271. static struct snd_soc_ops msm_mi2s_be_ops = {
  3272. .startup = msm_mi2s_snd_startup,
  3273. .shutdown = msm_mi2s_snd_shutdown,
  3274. };
  3275. static struct snd_soc_ops msm_fe_qos_ops = {
  3276. .prepare = msm_fe_qos_prepare,
  3277. };
  3278. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  3279. .hw_params = msm_snd_cdc_dma_hw_params,
  3280. };
  3281. static struct snd_soc_ops msm_wcn_ops = {
  3282. .hw_params = msm_wcn_hw_params,
  3283. };
  3284. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  3285. struct snd_kcontrol *kcontrol, int event)
  3286. {
  3287. struct msm_asoc_mach_data *pdata = NULL;
  3288. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  3289. int ret = 0;
  3290. u32 dmic_idx;
  3291. int *dmic_gpio_cnt;
  3292. struct device_node *dmic_gpio;
  3293. char *wname;
  3294. wname = strpbrk(w->name, "012345");
  3295. if (!wname) {
  3296. dev_err(component->dev, "%s: widget not found\n", __func__);
  3297. return -EINVAL;
  3298. }
  3299. ret = kstrtouint(wname, 10, &dmic_idx);
  3300. if (ret < 0) {
  3301. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  3302. __func__);
  3303. return -EINVAL;
  3304. }
  3305. pdata = snd_soc_card_get_drvdata(component->card);
  3306. switch (dmic_idx) {
  3307. case 0:
  3308. case 1:
  3309. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  3310. dmic_gpio = pdata->dmic01_gpio_p;
  3311. break;
  3312. case 2:
  3313. case 3:
  3314. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  3315. dmic_gpio = pdata->dmic23_gpio_p;
  3316. break;
  3317. case 4:
  3318. case 5:
  3319. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  3320. dmic_gpio = pdata->dmic45_gpio_p;
  3321. break;
  3322. default:
  3323. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  3324. __func__);
  3325. return -EINVAL;
  3326. }
  3327. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  3328. __func__, event, dmic_idx, *dmic_gpio_cnt);
  3329. switch (event) {
  3330. case SND_SOC_DAPM_PRE_PMU:
  3331. (*dmic_gpio_cnt)++;
  3332. if (*dmic_gpio_cnt == 1) {
  3333. ret = msm_cdc_pinctrl_select_active_state(
  3334. dmic_gpio);
  3335. if (ret < 0) {
  3336. pr_err("%s: gpio set cannot be activated %sd",
  3337. __func__, "dmic_gpio");
  3338. return ret;
  3339. }
  3340. }
  3341. break;
  3342. case SND_SOC_DAPM_POST_PMD:
  3343. (*dmic_gpio_cnt)--;
  3344. if (*dmic_gpio_cnt == 0) {
  3345. ret = msm_cdc_pinctrl_select_sleep_state(
  3346. dmic_gpio);
  3347. if (ret < 0) {
  3348. pr_err("%s: gpio set cannot be de-activated %sd",
  3349. __func__, "dmic_gpio");
  3350. return ret;
  3351. }
  3352. }
  3353. break;
  3354. default:
  3355. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  3356. return -EINVAL;
  3357. }
  3358. return 0;
  3359. }
  3360. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  3361. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  3362. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  3363. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  3364. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3365. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  3366. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  3367. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  3368. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  3369. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  3370. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  3371. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  3372. };
  3373. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  3374. {
  3375. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  3376. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  3377. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3378. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  3379. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  3380. }
  3381. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  3382. {
  3383. int ret = -EINVAL;
  3384. struct snd_soc_component *component;
  3385. struct snd_soc_dapm_context *dapm;
  3386. struct snd_card *card;
  3387. struct snd_info_entry *entry;
  3388. struct snd_soc_component *aux_comp;
  3389. struct msm_asoc_mach_data *pdata =
  3390. snd_soc_card_get_drvdata(rtd->card);
  3391. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  3392. if (!component) {
  3393. pr_err("%s: could not find component for bolero_codec\n",
  3394. __func__);
  3395. return ret;
  3396. }
  3397. dapm = snd_soc_component_get_dapm(component);
  3398. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  3399. ARRAY_SIZE(msm_int_snd_controls));
  3400. if (ret < 0) {
  3401. pr_err("%s: add_component_controls failed: %d\n",
  3402. __func__, ret);
  3403. return ret;
  3404. }
  3405. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  3406. ARRAY_SIZE(msm_common_snd_controls));
  3407. if (ret < 0) {
  3408. pr_err("%s: add common snd controls failed: %d\n",
  3409. __func__, ret);
  3410. return ret;
  3411. }
  3412. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  3413. ARRAY_SIZE(msm_int_dapm_widgets));
  3414. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  3415. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  3416. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  3417. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  3418. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  3419. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  3420. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  3421. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  3422. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  3423. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  3424. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  3425. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  3426. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  3427. snd_soc_dapm_sync(dapm);
  3428. /*
  3429. * Send speaker configuration only for WSA8810.
  3430. * Default configuration is for WSA8815.
  3431. */
  3432. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  3433. __func__, rtd->card->num_aux_devs);
  3434. if (rtd->card->num_aux_devs &&
  3435. !list_empty(&rtd->card->component_dev_list)) {
  3436. aux_comp = list_first_entry(
  3437. &rtd->card->component_dev_list,
  3438. struct snd_soc_component,
  3439. card_aux_list);
  3440. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  3441. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  3442. wsa_macro_set_spkr_mode(component,
  3443. WSA_MACRO_SPKR_MODE_1);
  3444. wsa_macro_set_spkr_gain_offset(component,
  3445. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  3446. }
  3447. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  3448. sm_port_map);
  3449. }
  3450. card = rtd->card->snd_card;
  3451. if (!pdata->codec_root) {
  3452. entry = snd_info_create_subdir(card->module, "codecs",
  3453. card->proc_root);
  3454. if (!entry) {
  3455. pr_debug("%s: Cannot create codecs module entry\n",
  3456. __func__);
  3457. ret = 0;
  3458. goto err;
  3459. }
  3460. pdata->codec_root = entry;
  3461. }
  3462. bolero_info_create_codec_entry(pdata->codec_root, component);
  3463. codec_reg_done = true;
  3464. return 0;
  3465. err:
  3466. return ret;
  3467. }
  3468. static void *def_wcd_mbhc_cal(void)
  3469. {
  3470. void *wcd_mbhc_cal;
  3471. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  3472. u16 *btn_high;
  3473. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  3474. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  3475. if (!wcd_mbhc_cal)
  3476. return NULL;
  3477. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  3478. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  3479. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  3480. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  3481. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  3482. btn_high[0] = 75;
  3483. btn_high[1] = 150;
  3484. btn_high[2] = 237;
  3485. btn_high[3] = 500;
  3486. btn_high[4] = 500;
  3487. btn_high[5] = 500;
  3488. btn_high[6] = 500;
  3489. btn_high[7] = 500;
  3490. return wcd_mbhc_cal;
  3491. }
  3492. /* Digital audio interface glue - connects codec <---> CPU */
  3493. static struct snd_soc_dai_link msm_common_dai_links[] = {
  3494. /* FrontEnd DAI Links */
  3495. {/* hw:x,0 */
  3496. .name = MSM_DAILINK_NAME(Media1),
  3497. .stream_name = "MultiMedia1",
  3498. .cpu_dai_name = "MultiMedia1",
  3499. .platform_name = "msm-pcm-dsp.0",
  3500. .dynamic = 1,
  3501. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3502. .dpcm_playback = 1,
  3503. .dpcm_capture = 1,
  3504. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3505. SND_SOC_DPCM_TRIGGER_POST},
  3506. .codec_dai_name = "snd-soc-dummy-dai",
  3507. .codec_name = "snd-soc-dummy",
  3508. .ignore_suspend = 1,
  3509. /* this dainlink has playback support */
  3510. .ignore_pmdown_time = 1,
  3511. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  3512. },
  3513. {/* hw:x,1 */
  3514. .name = MSM_DAILINK_NAME(Media2),
  3515. .stream_name = "MultiMedia2",
  3516. .cpu_dai_name = "MultiMedia2",
  3517. .platform_name = "msm-pcm-dsp.0",
  3518. .dynamic = 1,
  3519. .dpcm_playback = 1,
  3520. .dpcm_capture = 1,
  3521. .codec_dai_name = "snd-soc-dummy-dai",
  3522. .codec_name = "snd-soc-dummy",
  3523. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3524. SND_SOC_DPCM_TRIGGER_POST},
  3525. .ignore_suspend = 1,
  3526. /* this dainlink has playback support */
  3527. .ignore_pmdown_time = 1,
  3528. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  3529. },
  3530. {/* hw:x,2 */
  3531. .name = "VoiceMMode1",
  3532. .stream_name = "VoiceMMode1",
  3533. .cpu_dai_name = "VoiceMMode1",
  3534. .platform_name = "msm-pcm-voice",
  3535. .dynamic = 1,
  3536. .dpcm_playback = 1,
  3537. .dpcm_capture = 1,
  3538. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3539. SND_SOC_DPCM_TRIGGER_POST},
  3540. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3541. .ignore_suspend = 1,
  3542. .ignore_pmdown_time = 1,
  3543. .codec_dai_name = "snd-soc-dummy-dai",
  3544. .codec_name = "snd-soc-dummy",
  3545. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  3546. },
  3547. {/* hw:x,3 */
  3548. .name = "MSM VoIP",
  3549. .stream_name = "VoIP",
  3550. .cpu_dai_name = "VoIP",
  3551. .platform_name = "msm-voip-dsp",
  3552. .dynamic = 1,
  3553. .dpcm_playback = 1,
  3554. .dpcm_capture = 1,
  3555. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3556. SND_SOC_DPCM_TRIGGER_POST},
  3557. .codec_dai_name = "snd-soc-dummy-dai",
  3558. .codec_name = "snd-soc-dummy",
  3559. .ignore_suspend = 1,
  3560. /* this dainlink has playback support */
  3561. .ignore_pmdown_time = 1,
  3562. .id = MSM_FRONTEND_DAI_VOIP,
  3563. },
  3564. {/* hw:x,4 */
  3565. .name = MSM_DAILINK_NAME(ULL),
  3566. .stream_name = "MultiMedia3",
  3567. .cpu_dai_name = "MultiMedia3",
  3568. .platform_name = "msm-pcm-dsp.2",
  3569. .dynamic = 1,
  3570. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3571. .dpcm_playback = 1,
  3572. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3573. SND_SOC_DPCM_TRIGGER_POST},
  3574. .codec_dai_name = "snd-soc-dummy-dai",
  3575. .codec_name = "snd-soc-dummy",
  3576. .ignore_suspend = 1,
  3577. /* this dainlink has playback support */
  3578. .ignore_pmdown_time = 1,
  3579. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  3580. },
  3581. /* Hostless PCM purpose */
  3582. {/* hw:x,5 */
  3583. .name = "MSM AFE-PCM RX",
  3584. .stream_name = "AFE-PROXY RX",
  3585. .cpu_dai_name = "msm-dai-q6-dev.241",
  3586. .codec_name = "msm-stub-codec.1",
  3587. .codec_dai_name = "msm-stub-rx",
  3588. .platform_name = "msm-pcm-afe",
  3589. .dpcm_playback = 1,
  3590. .ignore_suspend = 1,
  3591. /* this dainlink has playback support */
  3592. .ignore_pmdown_time = 1,
  3593. },
  3594. {/* hw:x,6 */
  3595. .name = "MSM AFE-PCM TX",
  3596. .stream_name = "AFE-PROXY TX",
  3597. .cpu_dai_name = "msm-dai-q6-dev.240",
  3598. .codec_name = "msm-stub-codec.1",
  3599. .codec_dai_name = "msm-stub-tx",
  3600. .platform_name = "msm-pcm-afe",
  3601. .dpcm_capture = 1,
  3602. .ignore_suspend = 1,
  3603. },
  3604. {/* hw:x,7 */
  3605. .name = MSM_DAILINK_NAME(Compress1),
  3606. .stream_name = "Compress1",
  3607. .cpu_dai_name = "MultiMedia4",
  3608. .platform_name = "msm-compress-dsp",
  3609. .dynamic = 1,
  3610. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  3611. .dpcm_playback = 1,
  3612. .dpcm_capture = 1,
  3613. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3614. SND_SOC_DPCM_TRIGGER_POST},
  3615. .codec_dai_name = "snd-soc-dummy-dai",
  3616. .codec_name = "snd-soc-dummy",
  3617. .ignore_suspend = 1,
  3618. .ignore_pmdown_time = 1,
  3619. /* this dainlink has playback support */
  3620. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  3621. },
  3622. {/* hw:x,8 */
  3623. .name = "AUXPCM Hostless",
  3624. .stream_name = "AUXPCM Hostless",
  3625. .cpu_dai_name = "AUXPCM_HOSTLESS",
  3626. .platform_name = "msm-pcm-hostless",
  3627. .dynamic = 1,
  3628. .dpcm_playback = 1,
  3629. .dpcm_capture = 1,
  3630. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3631. SND_SOC_DPCM_TRIGGER_POST},
  3632. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3633. .ignore_suspend = 1,
  3634. /* this dainlink has playback support */
  3635. .ignore_pmdown_time = 1,
  3636. .codec_dai_name = "snd-soc-dummy-dai",
  3637. .codec_name = "snd-soc-dummy",
  3638. },
  3639. {/* hw:x,9 */
  3640. .name = MSM_DAILINK_NAME(LowLatency),
  3641. .stream_name = "MultiMedia5",
  3642. .cpu_dai_name = "MultiMedia5",
  3643. .platform_name = "msm-pcm-dsp.1",
  3644. .dynamic = 1,
  3645. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3646. .dpcm_playback = 1,
  3647. .dpcm_capture = 1,
  3648. .codec_dai_name = "snd-soc-dummy-dai",
  3649. .codec_name = "snd-soc-dummy",
  3650. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3651. SND_SOC_DPCM_TRIGGER_POST},
  3652. .ignore_suspend = 1,
  3653. /* this dainlink has playback support */
  3654. .ignore_pmdown_time = 1,
  3655. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  3656. .ops = &msm_fe_qos_ops,
  3657. },
  3658. {/* hw:x,10 */
  3659. .name = "Listen 1 Audio Service",
  3660. .stream_name = "Listen 1 Audio Service",
  3661. .cpu_dai_name = "LSM1",
  3662. .platform_name = "msm-lsm-client",
  3663. .dynamic = 1,
  3664. .dpcm_capture = 1,
  3665. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3666. SND_SOC_DPCM_TRIGGER_POST },
  3667. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3668. .ignore_suspend = 1,
  3669. .codec_dai_name = "snd-soc-dummy-dai",
  3670. .codec_name = "snd-soc-dummy",
  3671. .id = MSM_FRONTEND_DAI_LSM1,
  3672. },
  3673. /* Multiple Tunnel instances */
  3674. {/* hw:x,11 */
  3675. .name = MSM_DAILINK_NAME(Compress2),
  3676. .stream_name = "Compress2",
  3677. .cpu_dai_name = "MultiMedia7",
  3678. .platform_name = "msm-compress-dsp",
  3679. .dynamic = 1,
  3680. .dpcm_playback = 1,
  3681. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3682. SND_SOC_DPCM_TRIGGER_POST},
  3683. .codec_dai_name = "snd-soc-dummy-dai",
  3684. .codec_name = "snd-soc-dummy",
  3685. .ignore_suspend = 1,
  3686. .ignore_pmdown_time = 1,
  3687. /* this dainlink has playback support */
  3688. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  3689. },
  3690. {/* hw:x,12 */
  3691. .name = MSM_DAILINK_NAME(MultiMedia10),
  3692. .stream_name = "MultiMedia10",
  3693. .cpu_dai_name = "MultiMedia10",
  3694. .platform_name = "msm-pcm-dsp.1",
  3695. .dynamic = 1,
  3696. .dpcm_playback = 1,
  3697. .dpcm_capture = 1,
  3698. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3699. SND_SOC_DPCM_TRIGGER_POST},
  3700. .codec_dai_name = "snd-soc-dummy-dai",
  3701. .codec_name = "snd-soc-dummy",
  3702. .ignore_suspend = 1,
  3703. .ignore_pmdown_time = 1,
  3704. /* this dainlink has playback support */
  3705. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  3706. },
  3707. {/* hw:x,13 */
  3708. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  3709. .stream_name = "MM_NOIRQ",
  3710. .cpu_dai_name = "MultiMedia8",
  3711. .platform_name = "msm-pcm-dsp-noirq",
  3712. .dynamic = 1,
  3713. .dpcm_playback = 1,
  3714. .dpcm_capture = 1,
  3715. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3716. SND_SOC_DPCM_TRIGGER_POST},
  3717. .codec_dai_name = "snd-soc-dummy-dai",
  3718. .codec_name = "snd-soc-dummy",
  3719. .ignore_suspend = 1,
  3720. .ignore_pmdown_time = 1,
  3721. /* this dainlink has playback support */
  3722. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  3723. .ops = &msm_fe_qos_ops,
  3724. },
  3725. /* HDMI Hostless */
  3726. {/* hw:x,14 */
  3727. .name = "HDMI_RX_HOSTLESS",
  3728. .stream_name = "HDMI_RX_HOSTLESS",
  3729. .cpu_dai_name = "HDMI_HOSTLESS",
  3730. .platform_name = "msm-pcm-hostless",
  3731. .dynamic = 1,
  3732. .dpcm_playback = 1,
  3733. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3734. SND_SOC_DPCM_TRIGGER_POST},
  3735. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3736. .ignore_suspend = 1,
  3737. .ignore_pmdown_time = 1,
  3738. .codec_dai_name = "snd-soc-dummy-dai",
  3739. .codec_name = "snd-soc-dummy",
  3740. },
  3741. {/* hw:x,15 */
  3742. .name = "VoiceMMode2",
  3743. .stream_name = "VoiceMMode2",
  3744. .cpu_dai_name = "VoiceMMode2",
  3745. .platform_name = "msm-pcm-voice",
  3746. .dynamic = 1,
  3747. .dpcm_playback = 1,
  3748. .dpcm_capture = 1,
  3749. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3750. SND_SOC_DPCM_TRIGGER_POST},
  3751. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3752. .ignore_suspend = 1,
  3753. .ignore_pmdown_time = 1,
  3754. .codec_dai_name = "snd-soc-dummy-dai",
  3755. .codec_name = "snd-soc-dummy",
  3756. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  3757. },
  3758. /* LSM FE */
  3759. {/* hw:x,16 */
  3760. .name = "Listen 2 Audio Service",
  3761. .stream_name = "Listen 2 Audio Service",
  3762. .cpu_dai_name = "LSM2",
  3763. .platform_name = "msm-lsm-client",
  3764. .dynamic = 1,
  3765. .dpcm_capture = 1,
  3766. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3767. SND_SOC_DPCM_TRIGGER_POST },
  3768. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3769. .ignore_suspend = 1,
  3770. .codec_dai_name = "snd-soc-dummy-dai",
  3771. .codec_name = "snd-soc-dummy",
  3772. .id = MSM_FRONTEND_DAI_LSM2,
  3773. },
  3774. {/* hw:x,17 */
  3775. .name = "Listen 3 Audio Service",
  3776. .stream_name = "Listen 3 Audio Service",
  3777. .cpu_dai_name = "LSM3",
  3778. .platform_name = "msm-lsm-client",
  3779. .dynamic = 1,
  3780. .dpcm_capture = 1,
  3781. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3782. SND_SOC_DPCM_TRIGGER_POST },
  3783. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3784. .ignore_suspend = 1,
  3785. .codec_dai_name = "snd-soc-dummy-dai",
  3786. .codec_name = "snd-soc-dummy",
  3787. .id = MSM_FRONTEND_DAI_LSM3,
  3788. },
  3789. {/* hw:x,18 */
  3790. .name = "Listen 4 Audio Service",
  3791. .stream_name = "Listen 4 Audio Service",
  3792. .cpu_dai_name = "LSM4",
  3793. .platform_name = "msm-lsm-client",
  3794. .dynamic = 1,
  3795. .dpcm_capture = 1,
  3796. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3797. SND_SOC_DPCM_TRIGGER_POST },
  3798. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3799. .ignore_suspend = 1,
  3800. .codec_dai_name = "snd-soc-dummy-dai",
  3801. .codec_name = "snd-soc-dummy",
  3802. .id = MSM_FRONTEND_DAI_LSM4,
  3803. },
  3804. {/* hw:x,19 */
  3805. .name = "Listen 5 Audio Service",
  3806. .stream_name = "Listen 5 Audio Service",
  3807. .cpu_dai_name = "LSM5",
  3808. .platform_name = "msm-lsm-client",
  3809. .dynamic = 1,
  3810. .dpcm_capture = 1,
  3811. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3812. SND_SOC_DPCM_TRIGGER_POST },
  3813. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3814. .ignore_suspend = 1,
  3815. .codec_dai_name = "snd-soc-dummy-dai",
  3816. .codec_name = "snd-soc-dummy",
  3817. .id = MSM_FRONTEND_DAI_LSM5,
  3818. },
  3819. {/* hw:x,20 */
  3820. .name = "Listen 6 Audio Service",
  3821. .stream_name = "Listen 6 Audio Service",
  3822. .cpu_dai_name = "LSM6",
  3823. .platform_name = "msm-lsm-client",
  3824. .dynamic = 1,
  3825. .dpcm_capture = 1,
  3826. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3827. SND_SOC_DPCM_TRIGGER_POST },
  3828. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3829. .ignore_suspend = 1,
  3830. .codec_dai_name = "snd-soc-dummy-dai",
  3831. .codec_name = "snd-soc-dummy",
  3832. .id = MSM_FRONTEND_DAI_LSM6,
  3833. },
  3834. {/* hw:x,21 */
  3835. .name = "Listen 7 Audio Service",
  3836. .stream_name = "Listen 7 Audio Service",
  3837. .cpu_dai_name = "LSM7",
  3838. .platform_name = "msm-lsm-client",
  3839. .dynamic = 1,
  3840. .dpcm_capture = 1,
  3841. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3842. SND_SOC_DPCM_TRIGGER_POST },
  3843. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3844. .ignore_suspend = 1,
  3845. .codec_dai_name = "snd-soc-dummy-dai",
  3846. .codec_name = "snd-soc-dummy",
  3847. .id = MSM_FRONTEND_DAI_LSM7,
  3848. },
  3849. {/* hw:x,22 */
  3850. .name = "Listen 8 Audio Service",
  3851. .stream_name = "Listen 8 Audio Service",
  3852. .cpu_dai_name = "LSM8",
  3853. .platform_name = "msm-lsm-client",
  3854. .dynamic = 1,
  3855. .dpcm_capture = 1,
  3856. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3857. SND_SOC_DPCM_TRIGGER_POST },
  3858. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3859. .ignore_suspend = 1,
  3860. .codec_dai_name = "snd-soc-dummy-dai",
  3861. .codec_name = "snd-soc-dummy",
  3862. .id = MSM_FRONTEND_DAI_LSM8,
  3863. },
  3864. {/* hw:x,23 */
  3865. .name = MSM_DAILINK_NAME(Media9),
  3866. .stream_name = "MultiMedia9",
  3867. .cpu_dai_name = "MultiMedia9",
  3868. .platform_name = "msm-pcm-dsp.0",
  3869. .dynamic = 1,
  3870. .dpcm_playback = 1,
  3871. .dpcm_capture = 1,
  3872. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3873. SND_SOC_DPCM_TRIGGER_POST},
  3874. .codec_dai_name = "snd-soc-dummy-dai",
  3875. .codec_name = "snd-soc-dummy",
  3876. .ignore_suspend = 1,
  3877. /* this dainlink has playback support */
  3878. .ignore_pmdown_time = 1,
  3879. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  3880. },
  3881. {/* hw:x,24 */
  3882. .name = MSM_DAILINK_NAME(Compress4),
  3883. .stream_name = "Compress4",
  3884. .cpu_dai_name = "MultiMedia11",
  3885. .platform_name = "msm-compress-dsp",
  3886. .dynamic = 1,
  3887. .dpcm_playback = 1,
  3888. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3889. SND_SOC_DPCM_TRIGGER_POST},
  3890. .codec_dai_name = "snd-soc-dummy-dai",
  3891. .codec_name = "snd-soc-dummy",
  3892. .ignore_suspend = 1,
  3893. .ignore_pmdown_time = 1,
  3894. /* this dainlink has playback support */
  3895. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  3896. },
  3897. {/* hw:x,25 */
  3898. .name = MSM_DAILINK_NAME(Compress5),
  3899. .stream_name = "Compress5",
  3900. .cpu_dai_name = "MultiMedia12",
  3901. .platform_name = "msm-compress-dsp",
  3902. .dynamic = 1,
  3903. .dpcm_playback = 1,
  3904. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3905. SND_SOC_DPCM_TRIGGER_POST},
  3906. .codec_dai_name = "snd-soc-dummy-dai",
  3907. .codec_name = "snd-soc-dummy",
  3908. .ignore_suspend = 1,
  3909. .ignore_pmdown_time = 1,
  3910. /* this dainlink has playback support */
  3911. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  3912. },
  3913. {/* hw:x,26 */
  3914. .name = MSM_DAILINK_NAME(Compress6),
  3915. .stream_name = "Compress6",
  3916. .cpu_dai_name = "MultiMedia13",
  3917. .platform_name = "msm-compress-dsp",
  3918. .dynamic = 1,
  3919. .dpcm_playback = 1,
  3920. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3921. SND_SOC_DPCM_TRIGGER_POST},
  3922. .codec_dai_name = "snd-soc-dummy-dai",
  3923. .codec_name = "snd-soc-dummy",
  3924. .ignore_suspend = 1,
  3925. .ignore_pmdown_time = 1,
  3926. /* this dainlink has playback support */
  3927. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  3928. },
  3929. {/* hw:x,27 */
  3930. .name = MSM_DAILINK_NAME(Compress7),
  3931. .stream_name = "Compress7",
  3932. .cpu_dai_name = "MultiMedia14",
  3933. .platform_name = "msm-compress-dsp",
  3934. .dynamic = 1,
  3935. .dpcm_playback = 1,
  3936. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3937. SND_SOC_DPCM_TRIGGER_POST},
  3938. .codec_dai_name = "snd-soc-dummy-dai",
  3939. .codec_name = "snd-soc-dummy",
  3940. .ignore_suspend = 1,
  3941. .ignore_pmdown_time = 1,
  3942. /* this dainlink has playback support */
  3943. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  3944. },
  3945. {/* hw:x,28 */
  3946. .name = MSM_DAILINK_NAME(Compress8),
  3947. .stream_name = "Compress8",
  3948. .cpu_dai_name = "MultiMedia15",
  3949. .platform_name = "msm-compress-dsp",
  3950. .dynamic = 1,
  3951. .dpcm_playback = 1,
  3952. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3953. SND_SOC_DPCM_TRIGGER_POST},
  3954. .codec_dai_name = "snd-soc-dummy-dai",
  3955. .codec_name = "snd-soc-dummy",
  3956. .ignore_suspend = 1,
  3957. .ignore_pmdown_time = 1,
  3958. /* this dainlink has playback support */
  3959. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  3960. },
  3961. {/* hw:x,29 */
  3962. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  3963. .stream_name = "MM_NOIRQ_2",
  3964. .cpu_dai_name = "MultiMedia16",
  3965. .platform_name = "msm-pcm-dsp-noirq",
  3966. .dynamic = 1,
  3967. .dpcm_playback = 1,
  3968. .dpcm_capture = 1,
  3969. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3970. SND_SOC_DPCM_TRIGGER_POST},
  3971. .codec_dai_name = "snd-soc-dummy-dai",
  3972. .codec_name = "snd-soc-dummy",
  3973. .ignore_suspend = 1,
  3974. .ignore_pmdown_time = 1,
  3975. /* this dainlink has playback support */
  3976. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  3977. },
  3978. {/* hw:x,30 */
  3979. .name = "CDC_DMA Hostless",
  3980. .stream_name = "CDC_DMA Hostless",
  3981. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  3982. .platform_name = "msm-pcm-hostless",
  3983. .dynamic = 1,
  3984. .dpcm_playback = 1,
  3985. .dpcm_capture = 1,
  3986. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3987. SND_SOC_DPCM_TRIGGER_POST},
  3988. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3989. .ignore_suspend = 1,
  3990. /* this dailink has playback support */
  3991. .ignore_pmdown_time = 1,
  3992. .codec_dai_name = "snd-soc-dummy-dai",
  3993. .codec_name = "snd-soc-dummy",
  3994. },
  3995. {/* hw:x,31 */
  3996. .name = "TX3_CDC_DMA Hostless",
  3997. .stream_name = "TX3_CDC_DMA Hostless",
  3998. .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS",
  3999. .platform_name = "msm-pcm-hostless",
  4000. .dynamic = 1,
  4001. .dpcm_capture = 1,
  4002. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4003. SND_SOC_DPCM_TRIGGER_POST},
  4004. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4005. .ignore_suspend = 1,
  4006. .codec_dai_name = "snd-soc-dummy-dai",
  4007. .codec_name = "snd-soc-dummy",
  4008. },
  4009. };
  4010. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  4011. {/* hw:x,37 */
  4012. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  4013. .stream_name = "WSA CDC DMA0 Capture",
  4014. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  4015. .platform_name = "msm-pcm-hostless",
  4016. .codec_name = "bolero_codec",
  4017. .codec_dai_name = "wsa_macro_vifeedback",
  4018. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  4019. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4020. .ignore_suspend = 1,
  4021. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4022. .ops = &msm_cdc_dma_be_ops,
  4023. },
  4024. };
  4025. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  4026. {
  4027. .name = MSM_DAILINK_NAME(ASM Loopback),
  4028. .stream_name = "MultiMedia6",
  4029. .cpu_dai_name = "MultiMedia6",
  4030. .platform_name = "msm-pcm-loopback",
  4031. .dynamic = 1,
  4032. .dpcm_playback = 1,
  4033. .dpcm_capture = 1,
  4034. .codec_dai_name = "snd-soc-dummy-dai",
  4035. .codec_name = "snd-soc-dummy",
  4036. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4037. SND_SOC_DPCM_TRIGGER_POST},
  4038. .ignore_suspend = 1,
  4039. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4040. .ignore_pmdown_time = 1,
  4041. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  4042. },
  4043. {
  4044. .name = "USB Audio Hostless",
  4045. .stream_name = "USB Audio Hostless",
  4046. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  4047. .platform_name = "msm-pcm-hostless",
  4048. .dynamic = 1,
  4049. .dpcm_playback = 1,
  4050. .dpcm_capture = 1,
  4051. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4052. SND_SOC_DPCM_TRIGGER_POST},
  4053. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4054. .ignore_suspend = 1,
  4055. .ignore_pmdown_time = 1,
  4056. .codec_dai_name = "snd-soc-dummy-dai",
  4057. .codec_name = "snd-soc-dummy",
  4058. },
  4059. {
  4060. .name = "SLIMBUS_7 Hostless",
  4061. .stream_name = "SLIMBUS_7 Hostless",
  4062. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  4063. .platform_name = "msm-pcm-hostless",
  4064. .dynamic = 1,
  4065. .dpcm_capture = 1,
  4066. .dpcm_playback = 1,
  4067. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4068. SND_SOC_DPCM_TRIGGER_POST},
  4069. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4070. .ignore_suspend = 1,
  4071. .ignore_pmdown_time = 1,
  4072. .codec_dai_name = "snd-soc-dummy-dai",
  4073. .codec_name = "snd-soc-dummy",
  4074. },
  4075. {
  4076. .name = "Compress Capture",
  4077. .stream_name = "Compress9",
  4078. .cpu_dai_name = "MultiMedia17",
  4079. .platform_name = "msm-compress-dsp",
  4080. .dynamic = 1,
  4081. .dpcm_capture = 1,
  4082. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4083. SND_SOC_DPCM_TRIGGER_POST},
  4084. .codec_dai_name = "snd-soc-dummy-dai",
  4085. .codec_name = "snd-soc-dummy",
  4086. .ignore_suspend = 1,
  4087. .ignore_pmdown_time = 1,
  4088. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  4089. },
  4090. };
  4091. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  4092. /* Backend AFE DAI Links */
  4093. {
  4094. .name = LPASS_BE_AFE_PCM_RX,
  4095. .stream_name = "AFE Playback",
  4096. .cpu_dai_name = "msm-dai-q6-dev.224",
  4097. .platform_name = "msm-pcm-routing",
  4098. .codec_name = "msm-stub-codec.1",
  4099. .codec_dai_name = "msm-stub-rx",
  4100. .no_pcm = 1,
  4101. .dpcm_playback = 1,
  4102. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  4103. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4104. /* this dainlink has playback support */
  4105. .ignore_pmdown_time = 1,
  4106. .ignore_suspend = 1,
  4107. },
  4108. {
  4109. .name = LPASS_BE_AFE_PCM_TX,
  4110. .stream_name = "AFE Capture",
  4111. .cpu_dai_name = "msm-dai-q6-dev.225",
  4112. .platform_name = "msm-pcm-routing",
  4113. .codec_name = "msm-stub-codec.1",
  4114. .codec_dai_name = "msm-stub-tx",
  4115. .no_pcm = 1,
  4116. .dpcm_capture = 1,
  4117. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  4118. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4119. .ignore_suspend = 1,
  4120. },
  4121. /* Incall Record Uplink BACK END DAI Link */
  4122. {
  4123. .name = LPASS_BE_INCALL_RECORD_TX,
  4124. .stream_name = "Voice Uplink Capture",
  4125. .cpu_dai_name = "msm-dai-q6-dev.32772",
  4126. .platform_name = "msm-pcm-routing",
  4127. .codec_name = "msm-stub-codec.1",
  4128. .codec_dai_name = "msm-stub-tx",
  4129. .no_pcm = 1,
  4130. .dpcm_capture = 1,
  4131. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  4132. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4133. .ignore_suspend = 1,
  4134. },
  4135. /* Incall Record Downlink BACK END DAI Link */
  4136. {
  4137. .name = LPASS_BE_INCALL_RECORD_RX,
  4138. .stream_name = "Voice Downlink Capture",
  4139. .cpu_dai_name = "msm-dai-q6-dev.32771",
  4140. .platform_name = "msm-pcm-routing",
  4141. .codec_name = "msm-stub-codec.1",
  4142. .codec_dai_name = "msm-stub-tx",
  4143. .no_pcm = 1,
  4144. .dpcm_capture = 1,
  4145. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  4146. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4147. .ignore_suspend = 1,
  4148. },
  4149. /* Incall Music BACK END DAI Link */
  4150. {
  4151. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  4152. .stream_name = "Voice Farend Playback",
  4153. .cpu_dai_name = "msm-dai-q6-dev.32773",
  4154. .platform_name = "msm-pcm-routing",
  4155. .codec_name = "msm-stub-codec.1",
  4156. .codec_dai_name = "msm-stub-rx",
  4157. .no_pcm = 1,
  4158. .dpcm_playback = 1,
  4159. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  4160. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4161. .ignore_suspend = 1,
  4162. .ignore_pmdown_time = 1,
  4163. },
  4164. /* Incall Music 2 BACK END DAI Link */
  4165. {
  4166. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  4167. .stream_name = "Voice2 Farend Playback",
  4168. .cpu_dai_name = "msm-dai-q6-dev.32770",
  4169. .platform_name = "msm-pcm-routing",
  4170. .codec_name = "msm-stub-codec.1",
  4171. .codec_dai_name = "msm-stub-rx",
  4172. .no_pcm = 1,
  4173. .dpcm_playback = 1,
  4174. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  4175. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4176. .ignore_suspend = 1,
  4177. .ignore_pmdown_time = 1,
  4178. },
  4179. {
  4180. .name = LPASS_BE_USB_AUDIO_RX,
  4181. .stream_name = "USB Audio Playback",
  4182. .cpu_dai_name = "msm-dai-q6-dev.28672",
  4183. .platform_name = "msm-pcm-routing",
  4184. .codec_name = "msm-stub-codec.1",
  4185. .codec_dai_name = "msm-stub-rx",
  4186. .no_pcm = 1,
  4187. .dpcm_playback = 1,
  4188. .id = MSM_BACKEND_DAI_USB_RX,
  4189. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4190. .ignore_pmdown_time = 1,
  4191. .ignore_suspend = 1,
  4192. },
  4193. {
  4194. .name = LPASS_BE_USB_AUDIO_TX,
  4195. .stream_name = "USB Audio Capture",
  4196. .cpu_dai_name = "msm-dai-q6-dev.28673",
  4197. .platform_name = "msm-pcm-routing",
  4198. .codec_name = "msm-stub-codec.1",
  4199. .codec_dai_name = "msm-stub-tx",
  4200. .no_pcm = 1,
  4201. .dpcm_capture = 1,
  4202. .id = MSM_BACKEND_DAI_USB_TX,
  4203. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4204. .ignore_suspend = 1,
  4205. },
  4206. {
  4207. .name = LPASS_BE_PRI_TDM_RX_0,
  4208. .stream_name = "Primary TDM0 Playback",
  4209. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  4210. .platform_name = "msm-pcm-routing",
  4211. .codec_name = "msm-stub-codec.1",
  4212. .codec_dai_name = "msm-stub-rx",
  4213. .no_pcm = 1,
  4214. .dpcm_playback = 1,
  4215. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  4216. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4217. .ops = &kona_tdm_be_ops,
  4218. .ignore_suspend = 1,
  4219. .ignore_pmdown_time = 1,
  4220. },
  4221. {
  4222. .name = LPASS_BE_PRI_TDM_TX_0,
  4223. .stream_name = "Primary TDM0 Capture",
  4224. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  4225. .platform_name = "msm-pcm-routing",
  4226. .codec_name = "msm-stub-codec.1",
  4227. .codec_dai_name = "msm-stub-tx",
  4228. .no_pcm = 1,
  4229. .dpcm_capture = 1,
  4230. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  4231. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4232. .ops = &kona_tdm_be_ops,
  4233. .ignore_suspend = 1,
  4234. },
  4235. {
  4236. .name = LPASS_BE_SEC_TDM_RX_0,
  4237. .stream_name = "Secondary TDM0 Playback",
  4238. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  4239. .platform_name = "msm-pcm-routing",
  4240. .codec_name = "msm-stub-codec.1",
  4241. .codec_dai_name = "msm-stub-rx",
  4242. .no_pcm = 1,
  4243. .dpcm_playback = 1,
  4244. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  4245. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4246. .ops = &kona_tdm_be_ops,
  4247. .ignore_suspend = 1,
  4248. .ignore_pmdown_time = 1,
  4249. },
  4250. {
  4251. .name = LPASS_BE_SEC_TDM_TX_0,
  4252. .stream_name = "Secondary TDM0 Capture",
  4253. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  4254. .platform_name = "msm-pcm-routing",
  4255. .codec_name = "msm-stub-codec.1",
  4256. .codec_dai_name = "msm-stub-tx",
  4257. .no_pcm = 1,
  4258. .dpcm_capture = 1,
  4259. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  4260. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4261. .ops = &kona_tdm_be_ops,
  4262. .ignore_suspend = 1,
  4263. },
  4264. {
  4265. .name = LPASS_BE_TERT_TDM_RX_0,
  4266. .stream_name = "Tertiary TDM0 Playback",
  4267. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  4268. .platform_name = "msm-pcm-routing",
  4269. .codec_name = "msm-stub-codec.1",
  4270. .codec_dai_name = "msm-stub-rx",
  4271. .no_pcm = 1,
  4272. .dpcm_playback = 1,
  4273. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  4274. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4275. .ops = &kona_tdm_be_ops,
  4276. .ignore_suspend = 1,
  4277. .ignore_pmdown_time = 1,
  4278. },
  4279. {
  4280. .name = LPASS_BE_TERT_TDM_TX_0,
  4281. .stream_name = "Tertiary TDM0 Capture",
  4282. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  4283. .platform_name = "msm-pcm-routing",
  4284. .codec_name = "msm-stub-codec.1",
  4285. .codec_dai_name = "msm-stub-tx",
  4286. .no_pcm = 1,
  4287. .dpcm_capture = 1,
  4288. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  4289. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4290. .ops = &kona_tdm_be_ops,
  4291. .ignore_suspend = 1,
  4292. },
  4293. };
  4294. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  4295. {
  4296. .name = LPASS_BE_SLIMBUS_7_RX,
  4297. .stream_name = "Slimbus7 Playback",
  4298. .cpu_dai_name = "msm-dai-q6-dev.16398",
  4299. .platform_name = "msm-pcm-routing",
  4300. .codec_name = "btfmslim_slave",
  4301. /* BT codec driver determines capabilities based on
  4302. * dai name, bt codecdai name should always contains
  4303. * supported usecase information
  4304. */
  4305. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  4306. .no_pcm = 1,
  4307. .dpcm_playback = 1,
  4308. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  4309. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4310. .init = &msm_wcn_init,
  4311. .ops = &msm_wcn_ops,
  4312. /* dai link has playback support */
  4313. .ignore_pmdown_time = 1,
  4314. .ignore_suspend = 1,
  4315. },
  4316. {
  4317. .name = LPASS_BE_SLIMBUS_7_TX,
  4318. .stream_name = "Slimbus7 Capture",
  4319. .cpu_dai_name = "msm-dai-q6-dev.16399",
  4320. .platform_name = "msm-pcm-routing",
  4321. .codec_name = "btfmslim_slave",
  4322. .codec_dai_name = "btfm_bt_sco_slim_tx",
  4323. .no_pcm = 1,
  4324. .dpcm_capture = 1,
  4325. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  4326. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4327. .ops = &msm_wcn_ops,
  4328. .ignore_suspend = 1,
  4329. },
  4330. };
  4331. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  4332. /* DISP PORT BACK END DAI Link */
  4333. {
  4334. .name = LPASS_BE_DISPLAY_PORT,
  4335. .stream_name = "Display Port Playback",
  4336. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4337. .platform_name = "msm-pcm-routing",
  4338. .codec_name = "msm-ext-disp-audio-codec-rx",
  4339. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  4340. .no_pcm = 1,
  4341. .dpcm_playback = 1,
  4342. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  4343. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4344. .ignore_pmdown_time = 1,
  4345. .ignore_suspend = 1,
  4346. },
  4347. /* DISP PORT 1 BACK END DAI Link */
  4348. {
  4349. .name = LPASS_BE_DISPLAY_PORT1,
  4350. .stream_name = "Display Port1 Playback",
  4351. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4352. .platform_name = "msm-pcm-routing",
  4353. .codec_name = "msm-ext-disp-audio-codec-rx",
  4354. .codec_dai_name = "msm_dp_audio_codec_rx1_dai",
  4355. .no_pcm = 1,
  4356. .dpcm_playback = 1,
  4357. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  4358. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4359. .ignore_pmdown_time = 1,
  4360. .ignore_suspend = 1,
  4361. },
  4362. };
  4363. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  4364. {
  4365. .name = LPASS_BE_PRI_MI2S_RX,
  4366. .stream_name = "Primary MI2S Playback",
  4367. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4368. .platform_name = "msm-pcm-routing",
  4369. .codec_name = "msm-stub-codec.1",
  4370. .codec_dai_name = "msm-stub-rx",
  4371. .no_pcm = 1,
  4372. .dpcm_playback = 1,
  4373. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  4374. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4375. .ops = &msm_mi2s_be_ops,
  4376. .ignore_suspend = 1,
  4377. .ignore_pmdown_time = 1,
  4378. },
  4379. {
  4380. .name = LPASS_BE_PRI_MI2S_TX,
  4381. .stream_name = "Primary MI2S Capture",
  4382. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4383. .platform_name = "msm-pcm-routing",
  4384. .codec_name = "msm-stub-codec.1",
  4385. .codec_dai_name = "msm-stub-tx",
  4386. .no_pcm = 1,
  4387. .dpcm_capture = 1,
  4388. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  4389. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4390. .ops = &msm_mi2s_be_ops,
  4391. .ignore_suspend = 1,
  4392. },
  4393. {
  4394. .name = LPASS_BE_SEC_MI2S_RX,
  4395. .stream_name = "Secondary MI2S Playback",
  4396. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4397. .platform_name = "msm-pcm-routing",
  4398. .codec_name = "msm-stub-codec.1",
  4399. .codec_dai_name = "msm-stub-rx",
  4400. .no_pcm = 1,
  4401. .dpcm_playback = 1,
  4402. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  4403. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4404. .ops = &msm_mi2s_be_ops,
  4405. .ignore_suspend = 1,
  4406. .ignore_pmdown_time = 1,
  4407. },
  4408. {
  4409. .name = LPASS_BE_SEC_MI2S_TX,
  4410. .stream_name = "Secondary MI2S Capture",
  4411. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4412. .platform_name = "msm-pcm-routing",
  4413. .codec_name = "msm-stub-codec.1",
  4414. .codec_dai_name = "msm-stub-tx",
  4415. .no_pcm = 1,
  4416. .dpcm_capture = 1,
  4417. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  4418. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4419. .ops = &msm_mi2s_be_ops,
  4420. .ignore_suspend = 1,
  4421. },
  4422. {
  4423. .name = LPASS_BE_TERT_MI2S_RX,
  4424. .stream_name = "Tertiary MI2S Playback",
  4425. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4426. .platform_name = "msm-pcm-routing",
  4427. .codec_name = "msm-stub-codec.1",
  4428. .codec_dai_name = "msm-stub-rx",
  4429. .no_pcm = 1,
  4430. .dpcm_playback = 1,
  4431. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  4432. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4433. .ops = &msm_mi2s_be_ops,
  4434. .ignore_suspend = 1,
  4435. .ignore_pmdown_time = 1,
  4436. },
  4437. {
  4438. .name = LPASS_BE_TERT_MI2S_TX,
  4439. .stream_name = "Tertiary MI2S Capture",
  4440. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4441. .platform_name = "msm-pcm-routing",
  4442. .codec_name = "msm-stub-codec.1",
  4443. .codec_dai_name = "msm-stub-tx",
  4444. .no_pcm = 1,
  4445. .dpcm_capture = 1,
  4446. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  4447. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4448. .ops = &msm_mi2s_be_ops,
  4449. .ignore_suspend = 1,
  4450. },
  4451. };
  4452. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  4453. /* Primary AUX PCM Backend DAI Links */
  4454. {
  4455. .name = LPASS_BE_AUXPCM_RX,
  4456. .stream_name = "AUX PCM Playback",
  4457. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4458. .platform_name = "msm-pcm-routing",
  4459. .codec_name = "msm-stub-codec.1",
  4460. .codec_dai_name = "msm-stub-rx",
  4461. .no_pcm = 1,
  4462. .dpcm_playback = 1,
  4463. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  4464. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4465. .ignore_pmdown_time = 1,
  4466. .ignore_suspend = 1,
  4467. },
  4468. {
  4469. .name = LPASS_BE_AUXPCM_TX,
  4470. .stream_name = "AUX PCM Capture",
  4471. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4472. .platform_name = "msm-pcm-routing",
  4473. .codec_name = "msm-stub-codec.1",
  4474. .codec_dai_name = "msm-stub-tx",
  4475. .no_pcm = 1,
  4476. .dpcm_capture = 1,
  4477. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  4478. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4479. .ignore_suspend = 1,
  4480. },
  4481. /* Secondary AUX PCM Backend DAI Links */
  4482. {
  4483. .name = LPASS_BE_SEC_AUXPCM_RX,
  4484. .stream_name = "Sec AUX PCM Playback",
  4485. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4486. .platform_name = "msm-pcm-routing",
  4487. .codec_name = "msm-stub-codec.1",
  4488. .codec_dai_name = "msm-stub-rx",
  4489. .no_pcm = 1,
  4490. .dpcm_playback = 1,
  4491. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  4492. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4493. .ignore_pmdown_time = 1,
  4494. .ignore_suspend = 1,
  4495. },
  4496. {
  4497. .name = LPASS_BE_SEC_AUXPCM_TX,
  4498. .stream_name = "Sec AUX PCM Capture",
  4499. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4500. .platform_name = "msm-pcm-routing",
  4501. .codec_name = "msm-stub-codec.1",
  4502. .codec_dai_name = "msm-stub-tx",
  4503. .no_pcm = 1,
  4504. .dpcm_capture = 1,
  4505. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  4506. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4507. .ignore_suspend = 1,
  4508. },
  4509. /* Tertiary AUX PCM Backend DAI Links */
  4510. {
  4511. .name = LPASS_BE_TERT_AUXPCM_RX,
  4512. .stream_name = "Tert AUX PCM Playback",
  4513. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4514. .platform_name = "msm-pcm-routing",
  4515. .codec_name = "msm-stub-codec.1",
  4516. .codec_dai_name = "msm-stub-rx",
  4517. .no_pcm = 1,
  4518. .dpcm_playback = 1,
  4519. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  4520. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4521. .ignore_suspend = 1,
  4522. },
  4523. {
  4524. .name = LPASS_BE_TERT_AUXPCM_TX,
  4525. .stream_name = "Tert AUX PCM Capture",
  4526. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4527. .platform_name = "msm-pcm-routing",
  4528. .codec_name = "msm-stub-codec.1",
  4529. .codec_dai_name = "msm-stub-tx",
  4530. .no_pcm = 1,
  4531. .dpcm_capture = 1,
  4532. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  4533. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4534. .ignore_suspend = 1,
  4535. },
  4536. };
  4537. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  4538. /* WSA CDC DMA Backend DAI Links */
  4539. {
  4540. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  4541. .stream_name = "WSA CDC DMA0 Playback",
  4542. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  4543. .platform_name = "msm-pcm-routing",
  4544. .codec_name = "bolero_codec",
  4545. .codec_dai_name = "wsa_macro_rx1",
  4546. .no_pcm = 1,
  4547. .dpcm_playback = 1,
  4548. .init = &msm_int_audrx_init,
  4549. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  4550. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4551. .ignore_pmdown_time = 1,
  4552. .ignore_suspend = 1,
  4553. .ops = &msm_cdc_dma_be_ops,
  4554. },
  4555. {
  4556. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  4557. .stream_name = "WSA CDC DMA1 Playback",
  4558. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  4559. .platform_name = "msm-pcm-routing",
  4560. .codec_name = "bolero_codec",
  4561. .codec_dai_name = "wsa_macro_rx_mix",
  4562. .no_pcm = 1,
  4563. .dpcm_playback = 1,
  4564. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  4565. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4566. .ignore_pmdown_time = 1,
  4567. .ignore_suspend = 1,
  4568. .ops = &msm_cdc_dma_be_ops,
  4569. },
  4570. {
  4571. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  4572. .stream_name = "WSA CDC DMA1 Capture",
  4573. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  4574. .platform_name = "msm-pcm-routing",
  4575. .codec_name = "bolero_codec",
  4576. .codec_dai_name = "wsa_macro_echo",
  4577. .no_pcm = 1,
  4578. .dpcm_capture = 1,
  4579. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  4580. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4581. .ignore_suspend = 1,
  4582. .ops = &msm_cdc_dma_be_ops,
  4583. },
  4584. };
  4585. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  4586. /* RX CDC DMA Backend DAI Links */
  4587. {
  4588. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  4589. .stream_name = "RX CDC DMA0 Playback",
  4590. .cpu_dai_name = "msm-dai-cdc-dma-dev.45104",
  4591. .platform_name = "msm-pcm-routing",
  4592. .codec_name = "bolero_codec",
  4593. .codec_dai_name = "rx_macro_rx1",
  4594. .no_pcm = 1,
  4595. .dpcm_playback = 1,
  4596. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  4597. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4598. .ignore_pmdown_time = 1,
  4599. .ignore_suspend = 1,
  4600. .ops = &msm_cdc_dma_be_ops,
  4601. },
  4602. {
  4603. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  4604. .stream_name = "RX CDC DMA1 Playback",
  4605. .cpu_dai_name = "msm-dai-cdc-dma-dev.45106",
  4606. .platform_name = "msm-pcm-routing",
  4607. .codec_name = "bolero_codec",
  4608. .codec_dai_name = "rx_macro_rx2",
  4609. .no_pcm = 1,
  4610. .dpcm_playback = 1,
  4611. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  4612. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4613. .ignore_pmdown_time = 1,
  4614. .ignore_suspend = 1,
  4615. .ops = &msm_cdc_dma_be_ops,
  4616. },
  4617. {
  4618. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  4619. .stream_name = "RX CDC DMA2 Playback",
  4620. .cpu_dai_name = "msm-dai-cdc-dma-dev.45108",
  4621. .platform_name = "msm-pcm-routing",
  4622. .codec_name = "bolero_codec",
  4623. .codec_dai_name = "rx_macro_rx3",
  4624. .no_pcm = 1,
  4625. .dpcm_playback = 1,
  4626. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  4627. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4628. .ignore_pmdown_time = 1,
  4629. .ignore_suspend = 1,
  4630. .ops = &msm_cdc_dma_be_ops,
  4631. },
  4632. {
  4633. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  4634. .stream_name = "RX CDC DMA3 Playback",
  4635. .cpu_dai_name = "msm-dai-cdc-dma-dev.45110",
  4636. .platform_name = "msm-pcm-routing",
  4637. .codec_name = "bolero_codec",
  4638. .codec_dai_name = "rx_macro_rx4",
  4639. .no_pcm = 1,
  4640. .dpcm_playback = 1,
  4641. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  4642. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4643. .ignore_pmdown_time = 1,
  4644. .ignore_suspend = 1,
  4645. .ops = &msm_cdc_dma_be_ops,
  4646. },
  4647. /* TX CDC DMA Backend DAI Links */
  4648. {
  4649. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  4650. .stream_name = "TX CDC DMA3 Capture",
  4651. .cpu_dai_name = "msm-dai-cdc-dma-dev.45111",
  4652. .platform_name = "msm-pcm-routing",
  4653. .codec_name = "bolero_codec",
  4654. .codec_dai_name = "tx_macro_tx1",
  4655. .no_pcm = 1,
  4656. .dpcm_capture = 1,
  4657. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  4658. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4659. .ignore_suspend = 1,
  4660. .ops = &msm_cdc_dma_be_ops,
  4661. },
  4662. {
  4663. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  4664. .stream_name = "TX CDC DMA4 Capture",
  4665. .cpu_dai_name = "msm-dai-cdc-dma-dev.45113",
  4666. .platform_name = "msm-pcm-routing",
  4667. .codec_name = "bolero_codec",
  4668. .codec_dai_name = "tx_macro_tx2",
  4669. .no_pcm = 1,
  4670. .dpcm_capture = 1,
  4671. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  4672. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4673. .ignore_suspend = 1,
  4674. .ops = &msm_cdc_dma_be_ops,
  4675. },
  4676. };
  4677. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  4678. {
  4679. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  4680. .stream_name = "VA CDC DMA0 Capture",
  4681. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  4682. .platform_name = "msm-pcm-routing",
  4683. .codec_name = "bolero_codec",
  4684. .codec_dai_name = "va_macro_tx1",
  4685. .no_pcm = 1,
  4686. .dpcm_capture = 1,
  4687. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  4688. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4689. .ignore_suspend = 1,
  4690. .ops = &msm_cdc_dma_be_ops,
  4691. },
  4692. {
  4693. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  4694. .stream_name = "VA CDC DMA1 Capture",
  4695. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  4696. .platform_name = "msm-pcm-routing",
  4697. .codec_name = "bolero_codec",
  4698. .codec_dai_name = "va_macro_tx2",
  4699. .no_pcm = 1,
  4700. .dpcm_capture = 1,
  4701. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  4702. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4703. .ignore_suspend = 1,
  4704. .ops = &msm_cdc_dma_be_ops,
  4705. },
  4706. {
  4707. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  4708. .stream_name = "VA CDC DMA2 Capture",
  4709. .cpu_dai_name = "msm-dai-cdc-dma-dev.45093",
  4710. .platform_name = "msm-pcm-routing",
  4711. .codec_name = "bolero_codec",
  4712. .codec_dai_name = "va_macro_tx3",
  4713. .no_pcm = 1,
  4714. .dpcm_capture = 1,
  4715. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  4716. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4717. .ignore_suspend = 1,
  4718. .ops = &msm_cdc_dma_be_ops,
  4719. },
  4720. };
  4721. static struct snd_soc_dai_link msm_kona_dai_links[
  4722. ARRAY_SIZE(msm_common_dai_links) +
  4723. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  4724. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  4725. ARRAY_SIZE(msm_common_be_dai_links) +
  4726. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  4727. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  4728. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  4729. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  4730. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  4731. ARRAY_SIZE(ext_disp_be_dai_link) +
  4732. ARRAY_SIZE(msm_wcn_be_dai_links)];
  4733. static int msm_populate_dai_link_component_of_node(
  4734. struct snd_soc_card *card)
  4735. {
  4736. int i, index, ret = 0;
  4737. struct device *cdev = card->dev;
  4738. struct snd_soc_dai_link *dai_link = card->dai_link;
  4739. struct device_node *np;
  4740. if (!cdev) {
  4741. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  4742. return -ENODEV;
  4743. }
  4744. for (i = 0; i < card->num_links; i++) {
  4745. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  4746. continue;
  4747. /* populate platform_of_node for snd card dai links */
  4748. if (dai_link[i].platform_name &&
  4749. !dai_link[i].platform_of_node) {
  4750. index = of_property_match_string(cdev->of_node,
  4751. "asoc-platform-names",
  4752. dai_link[i].platform_name);
  4753. if (index < 0) {
  4754. dev_err(cdev, "%s: No match found for platform name: %s\n",
  4755. __func__, dai_link[i].platform_name);
  4756. ret = index;
  4757. goto err;
  4758. }
  4759. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  4760. index);
  4761. if (!np) {
  4762. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  4763. __func__, dai_link[i].platform_name,
  4764. index);
  4765. ret = -ENODEV;
  4766. goto err;
  4767. }
  4768. dai_link[i].platform_of_node = np;
  4769. dai_link[i].platform_name = NULL;
  4770. }
  4771. /* populate cpu_of_node for snd card dai links */
  4772. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  4773. index = of_property_match_string(cdev->of_node,
  4774. "asoc-cpu-names",
  4775. dai_link[i].cpu_dai_name);
  4776. if (index >= 0) {
  4777. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  4778. index);
  4779. if (!np) {
  4780. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  4781. __func__,
  4782. dai_link[i].cpu_dai_name);
  4783. ret = -ENODEV;
  4784. goto err;
  4785. }
  4786. dai_link[i].cpu_of_node = np;
  4787. dai_link[i].cpu_dai_name = NULL;
  4788. }
  4789. }
  4790. /* populate codec_of_node for snd card dai links */
  4791. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  4792. index = of_property_match_string(cdev->of_node,
  4793. "asoc-codec-names",
  4794. dai_link[i].codec_name);
  4795. if (index < 0)
  4796. continue;
  4797. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  4798. index);
  4799. if (!np) {
  4800. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  4801. __func__, dai_link[i].codec_name);
  4802. ret = -ENODEV;
  4803. goto err;
  4804. }
  4805. dai_link[i].codec_of_node = np;
  4806. dai_link[i].codec_name = NULL;
  4807. }
  4808. }
  4809. err:
  4810. return ret;
  4811. }
  4812. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  4813. {
  4814. int ret = -EINVAL;
  4815. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  4816. if (!component) {
  4817. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  4818. return ret;
  4819. }
  4820. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  4821. ARRAY_SIZE(msm_snd_controls));
  4822. if (ret < 0) {
  4823. dev_err(component->dev,
  4824. "%s: add_codec_controls failed, err = %d\n",
  4825. __func__, ret);
  4826. return ret;
  4827. }
  4828. return ret;
  4829. }
  4830. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  4831. struct snd_pcm_hw_params *params)
  4832. {
  4833. return 0;
  4834. }
  4835. static struct snd_soc_ops msm_stub_be_ops = {
  4836. .hw_params = msm_snd_stub_hw_params,
  4837. };
  4838. struct snd_soc_card snd_soc_card_stub_msm = {
  4839. .name = "kona-stub-snd-card",
  4840. };
  4841. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  4842. /* FrontEnd DAI Links */
  4843. {
  4844. .name = "MSMSTUB Media1",
  4845. .stream_name = "MultiMedia1",
  4846. .cpu_dai_name = "MultiMedia1",
  4847. .platform_name = "msm-pcm-dsp.0",
  4848. .dynamic = 1,
  4849. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4850. .dpcm_playback = 1,
  4851. .dpcm_capture = 1,
  4852. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4853. SND_SOC_DPCM_TRIGGER_POST},
  4854. .codec_dai_name = "snd-soc-dummy-dai",
  4855. .codec_name = "snd-soc-dummy",
  4856. .ignore_suspend = 1,
  4857. /* this dainlink has playback support */
  4858. .ignore_pmdown_time = 1,
  4859. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  4860. },
  4861. };
  4862. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  4863. /* Backend DAI Links */
  4864. {
  4865. .name = LPASS_BE_AUXPCM_RX,
  4866. .stream_name = "AUX PCM Playback",
  4867. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4868. .platform_name = "msm-pcm-routing",
  4869. .codec_name = "msm-stub-codec.1",
  4870. .codec_dai_name = "msm-stub-rx",
  4871. .no_pcm = 1,
  4872. .dpcm_playback = 1,
  4873. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  4874. .init = &msm_audrx_stub_init,
  4875. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4876. .ignore_pmdown_time = 1,
  4877. .ignore_suspend = 1,
  4878. .ops = &msm_stub_be_ops,
  4879. },
  4880. {
  4881. .name = LPASS_BE_AUXPCM_TX,
  4882. .stream_name = "AUX PCM Capture",
  4883. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4884. .platform_name = "msm-pcm-routing",
  4885. .codec_name = "msm-stub-codec.1",
  4886. .codec_dai_name = "msm-stub-tx",
  4887. .no_pcm = 1,
  4888. .dpcm_capture = 1,
  4889. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  4890. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4891. .ignore_suspend = 1,
  4892. .ops = &msm_stub_be_ops,
  4893. },
  4894. };
  4895. static struct snd_soc_dai_link msm_stub_dai_links[
  4896. ARRAY_SIZE(msm_stub_fe_dai_links) +
  4897. ARRAY_SIZE(msm_stub_be_dai_links)];
  4898. static const struct of_device_id kona_asoc_machine_of_match[] = {
  4899. { .compatible = "qcom,kona-asoc-snd",
  4900. .data = "codec"},
  4901. { .compatible = "qcom,kona-asoc-snd-stub",
  4902. .data = "stub_codec"},
  4903. {},
  4904. };
  4905. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  4906. {
  4907. struct snd_soc_card *card = NULL;
  4908. struct snd_soc_dai_link *dailink = NULL;
  4909. int len_1 = 0;
  4910. int len_2 = 0;
  4911. int total_links = 0;
  4912. int rc = 0;
  4913. u32 mi2s_audio_intf = 0;
  4914. u32 auxpcm_audio_intf = 0;
  4915. u32 val = 0;
  4916. const struct of_device_id *match;
  4917. match = of_match_node(kona_asoc_machine_of_match, dev->of_node);
  4918. if (!match) {
  4919. dev_err(dev, "%s: No DT match found for sound card\n",
  4920. __func__);
  4921. return NULL;
  4922. }
  4923. if (!strcmp(match->data, "codec")) {
  4924. card = &snd_soc_card_kona_msm;
  4925. memcpy(msm_kona_dai_links + total_links,
  4926. msm_common_dai_links,
  4927. sizeof(msm_common_dai_links));
  4928. total_links += ARRAY_SIZE(msm_common_dai_links);
  4929. memcpy(msm_kona_dai_links + total_links,
  4930. msm_bolero_fe_dai_links,
  4931. sizeof(msm_bolero_fe_dai_links));
  4932. total_links +=
  4933. ARRAY_SIZE(msm_bolero_fe_dai_links);
  4934. memcpy(msm_kona_dai_links + total_links,
  4935. msm_common_misc_fe_dai_links,
  4936. sizeof(msm_common_misc_fe_dai_links));
  4937. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  4938. memcpy(msm_kona_dai_links + total_links,
  4939. msm_common_be_dai_links,
  4940. sizeof(msm_common_be_dai_links));
  4941. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  4942. memcpy(msm_kona_dai_links + total_links,
  4943. msm_wsa_cdc_dma_be_dai_links,
  4944. sizeof(msm_wsa_cdc_dma_be_dai_links));
  4945. total_links +=
  4946. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  4947. memcpy(msm_kona_dai_links + total_links,
  4948. msm_rx_tx_cdc_dma_be_dai_links,
  4949. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  4950. total_links +=
  4951. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  4952. memcpy(msm_kona_dai_links + total_links,
  4953. msm_va_cdc_dma_be_dai_links,
  4954. sizeof(msm_va_cdc_dma_be_dai_links));
  4955. total_links +=
  4956. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  4957. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  4958. &mi2s_audio_intf);
  4959. if (rc) {
  4960. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  4961. __func__);
  4962. } else {
  4963. if (mi2s_audio_intf) {
  4964. memcpy(msm_kona_dai_links + total_links,
  4965. msm_mi2s_be_dai_links,
  4966. sizeof(msm_mi2s_be_dai_links));
  4967. total_links +=
  4968. ARRAY_SIZE(msm_mi2s_be_dai_links);
  4969. }
  4970. }
  4971. rc = of_property_read_u32(dev->of_node,
  4972. "qcom,auxpcm-audio-intf",
  4973. &auxpcm_audio_intf);
  4974. if (rc) {
  4975. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  4976. __func__);
  4977. } else {
  4978. if (auxpcm_audio_intf) {
  4979. memcpy(msm_kona_dai_links + total_links,
  4980. msm_auxpcm_be_dai_links,
  4981. sizeof(msm_auxpcm_be_dai_links));
  4982. total_links +=
  4983. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  4984. }
  4985. }
  4986. rc = of_property_read_u32(dev->of_node,
  4987. "qcom,ext-disp-audio-rx", &val);
  4988. if (!rc && val) {
  4989. dev_dbg(dev, "%s(): ext disp audio support present\n",
  4990. __func__);
  4991. memcpy(msm_kona_dai_links + total_links,
  4992. ext_disp_be_dai_link,
  4993. sizeof(ext_disp_be_dai_link));
  4994. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  4995. }
  4996. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  4997. if (!rc && val) {
  4998. dev_dbg(dev, "%s(): WCN BT support present\n",
  4999. __func__);
  5000. memcpy(msm_kona_dai_links + total_links,
  5001. msm_wcn_be_dai_links,
  5002. sizeof(msm_wcn_be_dai_links));
  5003. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  5004. }
  5005. dailink = msm_kona_dai_links;
  5006. } else if(!strcmp(match->data, "stub_codec")) {
  5007. card = &snd_soc_card_stub_msm;
  5008. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  5009. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  5010. memcpy(msm_stub_dai_links,
  5011. msm_stub_fe_dai_links,
  5012. sizeof(msm_stub_fe_dai_links));
  5013. memcpy(msm_stub_dai_links + len_1,
  5014. msm_stub_be_dai_links,
  5015. sizeof(msm_stub_be_dai_links));
  5016. dailink = msm_stub_dai_links;
  5017. total_links = len_2;
  5018. }
  5019. if (card) {
  5020. card->dai_link = dailink;
  5021. card->num_links = total_links;
  5022. }
  5023. return card;
  5024. }
  5025. static int msm_wsa881x_init(struct snd_soc_component *component)
  5026. {
  5027. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5028. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5029. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  5030. SPKR_L_BOOST, SPKR_L_VI};
  5031. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  5032. SPKR_R_BOOST, SPKR_R_VI};
  5033. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  5034. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  5035. struct msm_asoc_mach_data *pdata;
  5036. struct snd_soc_dapm_context *dapm;
  5037. struct snd_card *card;
  5038. struct snd_info_entry *entry;
  5039. int ret = 0;
  5040. if (!component) {
  5041. pr_err("%s component is NULL\n", __func__);
  5042. return -EINVAL;
  5043. }
  5044. card = component->card->snd_card;
  5045. dapm = snd_soc_component_get_dapm(component);
  5046. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  5047. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  5048. __func__, component->name);
  5049. wsa881x_set_channel_map(component, &spkleft_ports[0],
  5050. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5051. &ch_rate[0], &spkleft_port_types[0]);
  5052. if (dapm->component) {
  5053. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  5054. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  5055. }
  5056. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  5057. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  5058. __func__, component->name);
  5059. wsa881x_set_channel_map(component, &spkright_ports[0],
  5060. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5061. &ch_rate[0], &spkright_port_types[0]);
  5062. if (dapm->component) {
  5063. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  5064. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  5065. }
  5066. } else {
  5067. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  5068. component->name);
  5069. ret = -EINVAL;
  5070. goto err;
  5071. }
  5072. pdata = snd_soc_card_get_drvdata(component->card);
  5073. if (!pdata->codec_root) {
  5074. entry = snd_info_create_subdir(card->module, "codecs",
  5075. card->proc_root);
  5076. if (!entry) {
  5077. pr_err("%s: Cannot create codecs module entry\n",
  5078. __func__);
  5079. ret = 0;
  5080. goto err;
  5081. }
  5082. pdata->codec_root = entry;
  5083. }
  5084. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  5085. component);
  5086. err:
  5087. return ret;
  5088. }
  5089. static int msm_aux_codec_init(struct snd_soc_component *component)
  5090. {
  5091. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  5092. int ret = 0;
  5093. void *mbhc_calibration;
  5094. struct snd_info_entry *entry;
  5095. struct snd_card *card = component->card->snd_card;
  5096. struct msm_asoc_mach_data *pdata;
  5097. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  5098. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  5099. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  5100. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  5101. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  5102. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  5103. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  5104. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  5105. snd_soc_dapm_sync(dapm);
  5106. pdata = snd_soc_card_get_drvdata(component->card);
  5107. if (!pdata->codec_root) {
  5108. entry = snd_info_create_subdir(card->module, "codecs",
  5109. card->proc_root);
  5110. if (!entry) {
  5111. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  5112. __func__);
  5113. ret = 0;
  5114. goto mbhc_cfg_cal;
  5115. }
  5116. pdata->codec_root = entry;
  5117. }
  5118. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  5119. mbhc_cfg_cal:
  5120. mbhc_calibration = def_wcd_mbhc_cal();
  5121. if (!mbhc_calibration)
  5122. return -ENOMEM;
  5123. wcd_mbhc_cfg.calibration = mbhc_calibration;
  5124. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  5125. if (ret) {
  5126. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  5127. __func__, ret);
  5128. goto err_hs_detect;
  5129. }
  5130. return 0;
  5131. err_hs_detect:
  5132. kfree(mbhc_calibration);
  5133. return ret;
  5134. }
  5135. static int msm_init_aux_dev(struct platform_device *pdev,
  5136. struct snd_soc_card *card)
  5137. {
  5138. struct device_node *wsa_of_node;
  5139. struct device_node *aux_codec_of_node;
  5140. u32 wsa_max_devs;
  5141. u32 wsa_dev_cnt;
  5142. u32 codec_aux_dev_cnt = 0;
  5143. int i;
  5144. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  5145. struct aux_codec_dev_info *aux_cdc_dev_info;
  5146. const char *auxdev_name_prefix[1];
  5147. char *dev_name_str = NULL;
  5148. int found = 0;
  5149. int codecs_found = 0;
  5150. int ret = 0;
  5151. /* Get maximum WSA device count for this platform */
  5152. ret = of_property_read_u32(pdev->dev.of_node,
  5153. "qcom,wsa-max-devs", &wsa_max_devs);
  5154. if (ret) {
  5155. dev_info(&pdev->dev,
  5156. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  5157. __func__, pdev->dev.of_node->full_name, ret);
  5158. wsa_max_devs = 0;
  5159. goto codec_aux_dev;
  5160. }
  5161. if (wsa_max_devs == 0) {
  5162. dev_warn(&pdev->dev,
  5163. "%s: Max WSA devices is 0 for this target?\n",
  5164. __func__);
  5165. goto codec_aux_dev;
  5166. }
  5167. /* Get count of WSA device phandles for this platform */
  5168. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  5169. "qcom,wsa-devs", NULL);
  5170. if (wsa_dev_cnt == -ENOENT) {
  5171. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  5172. __func__);
  5173. goto err;
  5174. } else if (wsa_dev_cnt <= 0) {
  5175. dev_err(&pdev->dev,
  5176. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  5177. __func__, wsa_dev_cnt);
  5178. ret = -EINVAL;
  5179. goto err;
  5180. }
  5181. /*
  5182. * Expect total phandles count to be NOT less than maximum possible
  5183. * WSA count. However, if it is less, then assign same value to
  5184. * max count as well.
  5185. */
  5186. if (wsa_dev_cnt < wsa_max_devs) {
  5187. dev_dbg(&pdev->dev,
  5188. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  5189. __func__, wsa_max_devs, wsa_dev_cnt);
  5190. wsa_max_devs = wsa_dev_cnt;
  5191. }
  5192. /* Make sure prefix string passed for each WSA device */
  5193. ret = of_property_count_strings(pdev->dev.of_node,
  5194. "qcom,wsa-aux-dev-prefix");
  5195. if (ret != wsa_dev_cnt) {
  5196. dev_err(&pdev->dev,
  5197. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  5198. __func__, wsa_dev_cnt, ret);
  5199. ret = -EINVAL;
  5200. goto err;
  5201. }
  5202. /*
  5203. * Alloc mem to store phandle and index info of WSA device, if already
  5204. * registered with ALSA core
  5205. */
  5206. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  5207. sizeof(struct msm_wsa881x_dev_info),
  5208. GFP_KERNEL);
  5209. if (!wsa881x_dev_info) {
  5210. ret = -ENOMEM;
  5211. goto err;
  5212. }
  5213. /*
  5214. * search and check whether all WSA devices are already
  5215. * registered with ALSA core or not. If found a node, store
  5216. * the node and the index in a local array of struct for later
  5217. * use.
  5218. */
  5219. for (i = 0; i < wsa_dev_cnt; i++) {
  5220. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  5221. "qcom,wsa-devs", i);
  5222. if (unlikely(!wsa_of_node)) {
  5223. /* we should not be here */
  5224. dev_err(&pdev->dev,
  5225. "%s: wsa dev node is not present\n",
  5226. __func__);
  5227. ret = -EINVAL;
  5228. goto err;
  5229. }
  5230. if (soc_find_component(wsa_of_node, NULL)) {
  5231. /* WSA device registered with ALSA core */
  5232. wsa881x_dev_info[found].of_node = wsa_of_node;
  5233. wsa881x_dev_info[found].index = i;
  5234. found++;
  5235. if (found == wsa_max_devs)
  5236. break;
  5237. }
  5238. }
  5239. if (found < wsa_max_devs) {
  5240. dev_dbg(&pdev->dev,
  5241. "%s: failed to find %d components. Found only %d\n",
  5242. __func__, wsa_max_devs, found);
  5243. return -EPROBE_DEFER;
  5244. }
  5245. dev_info(&pdev->dev,
  5246. "%s: found %d wsa881x devices registered with ALSA core\n",
  5247. __func__, found);
  5248. codec_aux_dev:
  5249. /* Get count of aux codec device phandles for this platform */
  5250. codec_aux_dev_cnt = of_count_phandle_with_args(
  5251. pdev->dev.of_node,
  5252. "qcom,codec-aux-devs", NULL);
  5253. if (codec_aux_dev_cnt == -ENOENT) {
  5254. dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n",
  5255. __func__);
  5256. goto err;
  5257. } else if (codec_aux_dev_cnt <= 0) {
  5258. dev_err(&pdev->dev,
  5259. "%s: Error reading aux codec device from DT, dev_cnt=%d\n",
  5260. __func__, codec_aux_dev_cnt);
  5261. ret = -EINVAL;
  5262. goto err;
  5263. }
  5264. /*
  5265. * Alloc mem to store phandle and index info of aux codec
  5266. * if already registered with ALSA core
  5267. */
  5268. aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_aux_dev_cnt,
  5269. sizeof(struct aux_codec_dev_info),
  5270. GFP_KERNEL);
  5271. if (!aux_cdc_dev_info) {
  5272. ret = -ENOMEM;
  5273. goto err;
  5274. }
  5275. /*
  5276. * search and check whether all aux codecs are already
  5277. * registered with ALSA core or not. If found a node, store
  5278. * the node and the index in a local array of struct for later
  5279. * use.
  5280. */
  5281. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5282. aux_codec_of_node = of_parse_phandle(pdev->dev.of_node,
  5283. "qcom,codec-aux-devs", i);
  5284. if (unlikely(!aux_codec_of_node)) {
  5285. /* we should not be here */
  5286. dev_err(&pdev->dev,
  5287. "%s: aux codec dev node is not present\n",
  5288. __func__);
  5289. ret = -EINVAL;
  5290. goto err;
  5291. }
  5292. if (soc_find_component(aux_codec_of_node, NULL)) {
  5293. /* AUX codec registered with ALSA core */
  5294. aux_cdc_dev_info[codecs_found].of_node =
  5295. aux_codec_of_node;
  5296. aux_cdc_dev_info[codecs_found].index = i;
  5297. codecs_found++;
  5298. }
  5299. }
  5300. if (codecs_found < codec_aux_dev_cnt) {
  5301. dev_dbg(&pdev->dev,
  5302. "%s: failed to find %d components. Found only %d\n",
  5303. __func__, codec_aux_dev_cnt, codecs_found);
  5304. return -EPROBE_DEFER;
  5305. }
  5306. dev_info(&pdev->dev,
  5307. "%s: found %d AUX codecs registered with ALSA core\n",
  5308. __func__, codecs_found);
  5309. card->num_aux_devs = wsa_max_devs + codec_aux_dev_cnt;
  5310. card->num_configs = wsa_max_devs + codec_aux_dev_cnt;
  5311. /* Alloc array of AUX devs struct */
  5312. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  5313. sizeof(struct snd_soc_aux_dev),
  5314. GFP_KERNEL);
  5315. if (!msm_aux_dev) {
  5316. ret = -ENOMEM;
  5317. goto err;
  5318. }
  5319. /* Alloc array of codec conf struct */
  5320. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs,
  5321. sizeof(struct snd_soc_codec_conf),
  5322. GFP_KERNEL);
  5323. if (!msm_codec_conf) {
  5324. ret = -ENOMEM;
  5325. goto err;
  5326. }
  5327. for (i = 0; i < wsa_max_devs; i++) {
  5328. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  5329. GFP_KERNEL);
  5330. if (!dev_name_str) {
  5331. ret = -ENOMEM;
  5332. goto err;
  5333. }
  5334. ret = of_property_read_string_index(pdev->dev.of_node,
  5335. "qcom,wsa-aux-dev-prefix",
  5336. wsa881x_dev_info[i].index,
  5337. auxdev_name_prefix);
  5338. if (ret) {
  5339. dev_err(&pdev->dev,
  5340. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  5341. __func__, ret);
  5342. ret = -EINVAL;
  5343. goto err;
  5344. }
  5345. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  5346. msm_aux_dev[i].name = dev_name_str;
  5347. msm_aux_dev[i].codec_name = NULL;
  5348. msm_aux_dev[i].codec_of_node =
  5349. wsa881x_dev_info[i].of_node;
  5350. msm_aux_dev[i].init = msm_wsa881x_init;
  5351. msm_codec_conf[i].dev_name = NULL;
  5352. msm_codec_conf[i].name_prefix = auxdev_name_prefix[0];
  5353. msm_codec_conf[i].of_node =
  5354. wsa881x_dev_info[i].of_node;
  5355. }
  5356. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5357. msm_aux_dev[wsa_max_devs + i].name = NULL;
  5358. msm_aux_dev[wsa_max_devs + i].codec_name = NULL;
  5359. msm_aux_dev[wsa_max_devs + i].codec_of_node =
  5360. aux_cdc_dev_info[i].of_node;
  5361. msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init;
  5362. msm_codec_conf[wsa_max_devs + i].dev_name = NULL;
  5363. msm_codec_conf[wsa_max_devs + i].name_prefix =
  5364. NULL;
  5365. msm_codec_conf[wsa_max_devs + i].of_node =
  5366. aux_cdc_dev_info[i].of_node;
  5367. }
  5368. card->codec_conf = msm_codec_conf;
  5369. card->aux_dev = msm_aux_dev;
  5370. err:
  5371. return ret;
  5372. }
  5373. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  5374. {
  5375. int count = 0;
  5376. u32 mi2s_master_slave[MI2S_MAX];
  5377. int ret = 0;
  5378. for (count = 0; count < MI2S_MAX; count++) {
  5379. mutex_init(&mi2s_intf_conf[count].lock);
  5380. mi2s_intf_conf[count].ref_cnt = 0;
  5381. }
  5382. ret = of_property_read_u32_array(pdev->dev.of_node,
  5383. "qcom,msm-mi2s-master",
  5384. mi2s_master_slave, MI2S_MAX);
  5385. if (ret) {
  5386. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  5387. __func__);
  5388. } else {
  5389. for (count = 0; count < MI2S_MAX; count++) {
  5390. mi2s_intf_conf[count].msm_is_mi2s_master =
  5391. mi2s_master_slave[count];
  5392. }
  5393. }
  5394. }
  5395. static void msm_i2s_auxpcm_deinit(void)
  5396. {
  5397. int count = 0;
  5398. for (count = 0; count < MI2S_MAX; count++) {
  5399. mutex_destroy(&mi2s_intf_conf[count].lock);
  5400. mi2s_intf_conf[count].ref_cnt = 0;
  5401. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  5402. }
  5403. }
  5404. static int kona_ssr_enable(struct device *dev, void *data)
  5405. {
  5406. struct platform_device *pdev = to_platform_device(dev);
  5407. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5408. int ret = 0;
  5409. if (!card) {
  5410. dev_err(dev, "%s: card is NULL\n", __func__);
  5411. ret = -EINVAL;
  5412. goto err;
  5413. }
  5414. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5415. /* TODO */
  5416. dev_dbg(dev, "%s: TODO \n", __func__);
  5417. }
  5418. snd_soc_card_change_online_state(card, 1);
  5419. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  5420. err:
  5421. return ret;
  5422. }
  5423. static void kona_ssr_disable(struct device *dev, void *data)
  5424. {
  5425. struct platform_device *pdev = to_platform_device(dev);
  5426. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5427. if (!card) {
  5428. dev_err(dev, "%s: card is NULL\n", __func__);
  5429. return;
  5430. }
  5431. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  5432. snd_soc_card_change_online_state(card, 0);
  5433. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5434. /* TODO */
  5435. dev_dbg(dev, "%s: TODO \n", __func__);
  5436. }
  5437. }
  5438. static const struct snd_event_ops kona_ssr_ops = {
  5439. .enable = kona_ssr_enable,
  5440. .disable = kona_ssr_disable,
  5441. };
  5442. static int msm_audio_ssr_compare(struct device *dev, void *data)
  5443. {
  5444. struct device_node *node = data;
  5445. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  5446. __func__, dev->of_node, node);
  5447. return (dev->of_node && dev->of_node == node);
  5448. }
  5449. static int msm_audio_ssr_register(struct device *dev)
  5450. {
  5451. struct device_node *np = dev->of_node;
  5452. struct snd_event_clients *ssr_clients = NULL;
  5453. struct device_node *node = NULL;
  5454. int ret = 0;
  5455. int i = 0;
  5456. for (i = 0; ; i++) {
  5457. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  5458. if (!node)
  5459. break;
  5460. snd_event_mstr_add_client(&ssr_clients,
  5461. msm_audio_ssr_compare, node);
  5462. }
  5463. ret = snd_event_master_register(dev, &kona_ssr_ops,
  5464. ssr_clients, NULL);
  5465. if (!ret)
  5466. snd_event_notify(dev, SND_EVENT_UP);
  5467. return ret;
  5468. }
  5469. static int msm_asoc_machine_probe(struct platform_device *pdev)
  5470. {
  5471. struct snd_soc_card *card = NULL;
  5472. struct msm_asoc_mach_data *pdata = NULL;
  5473. const char *mbhc_audio_jack_type = NULL;
  5474. int ret = 0;
  5475. if (!pdev->dev.of_node) {
  5476. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  5477. return -EINVAL;
  5478. }
  5479. pdata = devm_kzalloc(&pdev->dev,
  5480. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  5481. if (!pdata)
  5482. return -ENOMEM;
  5483. card = populate_snd_card_dailinks(&pdev->dev);
  5484. if (!card) {
  5485. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  5486. ret = -EINVAL;
  5487. goto err;
  5488. }
  5489. card->dev = &pdev->dev;
  5490. platform_set_drvdata(pdev, card);
  5491. snd_soc_card_set_drvdata(card, pdata);
  5492. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  5493. if (ret) {
  5494. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  5495. __func__, ret);
  5496. goto err;
  5497. }
  5498. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  5499. if (ret) {
  5500. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  5501. __func__, ret);
  5502. goto err;
  5503. }
  5504. ret = msm_populate_dai_link_component_of_node(card);
  5505. if (ret) {
  5506. ret = -EPROBE_DEFER;
  5507. goto err;
  5508. }
  5509. ret = msm_init_aux_dev(pdev, card);
  5510. if (ret)
  5511. goto err;
  5512. ret = devm_snd_soc_register_card(&pdev->dev, card);
  5513. if (ret == -EPROBE_DEFER) {
  5514. if (codec_reg_done)
  5515. ret = -EINVAL;
  5516. goto err;
  5517. } else if (ret) {
  5518. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  5519. __func__, ret);
  5520. goto err;
  5521. }
  5522. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  5523. __func__, card->name);
  5524. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5525. "qcom,hph-en1-gpio", 0);
  5526. if (!pdata->hph_en1_gpio_p) {
  5527. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  5528. __func__, "qcom,hph-en1-gpio",
  5529. pdev->dev.of_node->full_name);
  5530. }
  5531. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5532. "qcom,hph-en0-gpio", 0);
  5533. if (!pdata->hph_en0_gpio_p) {
  5534. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  5535. __func__, "qcom,hph-en0-gpio",
  5536. pdev->dev.of_node->full_name);
  5537. }
  5538. ret = of_property_read_string(pdev->dev.of_node,
  5539. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  5540. if (ret) {
  5541. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  5542. __func__, "qcom,mbhc-audio-jack-type",
  5543. pdev->dev.of_node->full_name);
  5544. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  5545. } else {
  5546. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  5547. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  5548. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  5549. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  5550. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  5551. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  5552. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  5553. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  5554. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  5555. } else {
  5556. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  5557. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  5558. }
  5559. }
  5560. /*
  5561. * Parse US-Euro gpio info from DT. Report no error if us-euro
  5562. * entry is not found in DT file as some targets do not support
  5563. * US-Euro detection
  5564. */
  5565. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5566. "qcom,us-euro-gpios", 0);
  5567. if (!pdata->us_euro_gpio_p) {
  5568. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  5569. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  5570. } else {
  5571. dev_dbg(&pdev->dev, "%s detected\n",
  5572. "qcom,us-euro-gpios");
  5573. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  5574. }
  5575. msm_i2s_auxpcm_init(pdev);
  5576. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5577. "qcom,cdc-dmic01-gpios",
  5578. 0);
  5579. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5580. "qcom,cdc-dmic23-gpios",
  5581. 0);
  5582. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5583. "qcom,cdc-dmic45-gpios",
  5584. 0);
  5585. ret = msm_audio_ssr_register(&pdev->dev);
  5586. if (ret)
  5587. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  5588. __func__, ret);
  5589. is_initial_boot = true;
  5590. return 0;
  5591. err:
  5592. devm_kfree(&pdev->dev, pdata);
  5593. return ret;
  5594. }
  5595. static int msm_asoc_machine_remove(struct platform_device *pdev)
  5596. {
  5597. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5598. snd_event_master_deregister(&pdev->dev);
  5599. snd_soc_unregister_card(card);
  5600. msm_i2s_auxpcm_deinit();
  5601. return 0;
  5602. }
  5603. static struct platform_driver kona_asoc_machine_driver = {
  5604. .driver = {
  5605. .name = DRV_NAME,
  5606. .owner = THIS_MODULE,
  5607. .pm = &snd_soc_pm_ops,
  5608. .of_match_table = kona_asoc_machine_of_match,
  5609. },
  5610. .probe = msm_asoc_machine_probe,
  5611. .remove = msm_asoc_machine_remove,
  5612. };
  5613. module_platform_driver(kona_asoc_machine_driver);
  5614. MODULE_DESCRIPTION("ALSA SoC msm");
  5615. MODULE_LICENSE("GPL v2");
  5616. MODULE_ALIAS("platform:" DRV_NAME);
  5617. MODULE_DEVICE_TABLE(of, kona_asoc_machine_of_match);