lahaina.c 235 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2020, 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 <soc/soundwire.h>
  28. #include "device_event.h"
  29. #include "msm-pcm-routing-v2.h"
  30. #include "asoc/msm-cdc-pinctrl.h"
  31. #include "asoc/wcd-mbhc-v2.h"
  32. #include "codecs/wcd938x/wcd938x-mbhc.h"
  33. #include "codecs/wsa883x/wsa883x.h"
  34. #include "codecs/wcd938x/wcd938x.h"
  35. #include "codecs/bolero/bolero-cdc.h"
  36. #include <dt-bindings/sound/audio-codec-port-types.h>
  37. #include "codecs/bolero/wsa-macro.h"
  38. #include "lahaina-port-config.h"
  39. #include "msm_dailink.h"
  40. #define DRV_NAME "lahaina-asoc-snd"
  41. #define __CHIPSET__ "LAHAINA "
  42. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  43. #define SAMPLING_RATE_8KHZ 8000
  44. #define SAMPLING_RATE_11P025KHZ 11025
  45. #define SAMPLING_RATE_16KHZ 16000
  46. #define SAMPLING_RATE_22P05KHZ 22050
  47. #define SAMPLING_RATE_32KHZ 32000
  48. #define SAMPLING_RATE_44P1KHZ 44100
  49. #define SAMPLING_RATE_48KHZ 48000
  50. #define SAMPLING_RATE_88P2KHZ 88200
  51. #define SAMPLING_RATE_96KHZ 96000
  52. #define SAMPLING_RATE_176P4KHZ 176400
  53. #define SAMPLING_RATE_192KHZ 192000
  54. #define SAMPLING_RATE_352P8KHZ 352800
  55. #define SAMPLING_RATE_384KHZ 384000
  56. #define IS_FRACTIONAL(x) \
  57. ((x == SAMPLING_RATE_11P025KHZ) || (x == SAMPLING_RATE_22P05KHZ) || \
  58. (x == SAMPLING_RATE_44P1KHZ) || (x == SAMPLING_RATE_88P2KHZ) || \
  59. (x == SAMPLING_RATE_176P4KHZ) || (x == SAMPLING_RATE_352P8KHZ))
  60. #define IS_MSM_INTERFACE_MI2S(x) \
  61. ((x == PRIM_MI2S) || (x == SEC_MI2S) || (x == TERT_MI2S))
  62. #define WCD9XXX_MBHC_DEF_RLOADS 5
  63. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  64. #define CODEC_EXT_CLK_RATE 9600000
  65. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  66. #define DEV_NAME_STR_LEN 32
  67. #define WCD_MBHC_HS_V_MAX 1600
  68. #define TDM_CHANNEL_MAX 8
  69. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  70. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  71. #define WCN_CDC_SLIM_RX_CH_MAX 2
  72. #define WCN_CDC_SLIM_TX_CH_MAX 2
  73. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  74. #define SWR_MAX_SLAVE_DEVICES 6
  75. enum {
  76. RX_PATH = 0,
  77. TX_PATH,
  78. MAX_PATH,
  79. };
  80. enum {
  81. TDM_0 = 0,
  82. TDM_1,
  83. TDM_2,
  84. TDM_3,
  85. TDM_4,
  86. TDM_5,
  87. TDM_6,
  88. TDM_7,
  89. TDM_PORT_MAX,
  90. };
  91. #define TDM_MAX_SLOTS 8
  92. #define TDM_SLOT_WIDTH_BITS 32
  93. #define TDM_SLOT_WIDTH_BYTES TDM_SLOT_WIDTH_BITS/8
  94. enum {
  95. TDM_PRI = 0,
  96. TDM_SEC,
  97. TDM_TERT,
  98. TDM_QUAT,
  99. TDM_QUIN,
  100. TDM_SEN,
  101. TDM_INTERFACE_MAX,
  102. };
  103. enum {
  104. PRIM_AUX_PCM = 0,
  105. SEC_AUX_PCM,
  106. TERT_AUX_PCM,
  107. QUAT_AUX_PCM,
  108. QUIN_AUX_PCM,
  109. SEN_AUX_PCM,
  110. AUX_PCM_MAX,
  111. };
  112. enum {
  113. PRIM_MI2S = 0,
  114. SEC_MI2S,
  115. TERT_MI2S,
  116. QUAT_MI2S,
  117. QUIN_MI2S,
  118. SEN_MI2S,
  119. MI2S_MAX,
  120. };
  121. enum {
  122. WSA_CDC_DMA_RX_0 = 0,
  123. WSA_CDC_DMA_RX_1,
  124. RX_CDC_DMA_RX_0,
  125. RX_CDC_DMA_RX_1,
  126. RX_CDC_DMA_RX_2,
  127. RX_CDC_DMA_RX_3,
  128. RX_CDC_DMA_RX_5,
  129. RX_CDC_DMA_RX_6,
  130. CDC_DMA_RX_MAX,
  131. };
  132. enum {
  133. WSA_CDC_DMA_TX_0 = 0,
  134. WSA_CDC_DMA_TX_1,
  135. WSA_CDC_DMA_TX_2,
  136. TX_CDC_DMA_TX_0,
  137. TX_CDC_DMA_TX_3,
  138. TX_CDC_DMA_TX_4,
  139. VA_CDC_DMA_TX_0,
  140. VA_CDC_DMA_TX_1,
  141. VA_CDC_DMA_TX_2,
  142. CDC_DMA_TX_MAX,
  143. };
  144. enum {
  145. SLIM_RX_7 = 0,
  146. SLIM_RX_MAX,
  147. };
  148. enum {
  149. SLIM_TX_7 = 0,
  150. SLIM_TX_8,
  151. SLIM_TX_MAX,
  152. };
  153. enum {
  154. AFE_LOOPBACK_TX_IDX = 0,
  155. AFE_LOOPBACK_TX_IDX_MAX,
  156. };
  157. struct msm_asoc_mach_data {
  158. struct snd_info_entry *codec_root;
  159. int usbc_en2_gpio; /* used by gpio driver API */
  160. int lito_v2_enabled;
  161. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  162. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  163. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  164. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  165. atomic_t mi2s_gpio_ref_count[MI2S_MAX]; /* used by pinctrl API */
  166. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  167. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  168. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  169. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  170. bool is_afe_config_done;
  171. struct device_node *fsa_handle;
  172. struct clk *lpass_audio_hw_vote;
  173. int core_audio_vote_count;
  174. u32 wsa_max_devs;
  175. u32 tdm_max_slots; /* Max TDM slots used */
  176. int wcd_disabled;
  177. int (*get_wsa_dev_num)(struct snd_soc_component*);
  178. struct afe_cps_hw_intf_cfg cps_config;
  179. };
  180. struct tdm_port {
  181. u32 mode;
  182. u32 channel;
  183. };
  184. struct tdm_dev_config {
  185. unsigned int tdm_slot_offset[TDM_MAX_SLOTS];
  186. };
  187. enum {
  188. EXT_DISP_RX_IDX_DP = 0,
  189. EXT_DISP_RX_IDX_DP1,
  190. EXT_DISP_RX_IDX_MAX,
  191. };
  192. struct dev_config {
  193. u32 sample_rate;
  194. u32 bit_format;
  195. u32 channels;
  196. };
  197. /* Default configuration of slimbus channels */
  198. static struct dev_config slim_rx_cfg[] = {
  199. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  200. };
  201. static struct dev_config slim_tx_cfg[] = {
  202. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  203. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  204. };
  205. /* Default configuration of external display BE */
  206. static struct dev_config ext_disp_rx_cfg[] = {
  207. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  208. [EXT_DISP_RX_IDX_DP1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  209. };
  210. static struct dev_config usb_rx_cfg = {
  211. .sample_rate = SAMPLING_RATE_48KHZ,
  212. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  213. .channels = 2,
  214. };
  215. static struct dev_config usb_tx_cfg = {
  216. .sample_rate = SAMPLING_RATE_48KHZ,
  217. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  218. .channels = 1,
  219. };
  220. static struct dev_config proxy_rx_cfg = {
  221. .sample_rate = SAMPLING_RATE_48KHZ,
  222. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  223. .channels = 2,
  224. };
  225. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  226. {
  227. AFE_API_VERSION_I2S_CONFIG,
  228. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  229. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  230. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  231. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  232. 0,
  233. },
  234. {
  235. AFE_API_VERSION_I2S_CONFIG,
  236. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  237. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  238. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  239. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  240. 0,
  241. },
  242. {
  243. AFE_API_VERSION_I2S_CONFIG,
  244. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  245. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  246. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  247. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  248. 0,
  249. },
  250. {
  251. AFE_API_VERSION_I2S_CONFIG,
  252. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  253. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  254. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  255. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  256. 0,
  257. },
  258. {
  259. AFE_API_VERSION_I2S_CONFIG,
  260. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  261. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  262. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  263. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  264. 0,
  265. },
  266. {
  267. AFE_API_VERSION_I2S_CONFIG,
  268. Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT,
  269. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  270. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  271. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  272. 0,
  273. },
  274. };
  275. struct mi2s_conf {
  276. struct mutex lock;
  277. u32 ref_cnt;
  278. u32 msm_is_mi2s_master;
  279. };
  280. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  281. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  282. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  283. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  284. };
  285. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  286. /* Default configuration of TDM channels */
  287. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  288. { /* PRI TDM */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  291. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  292. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  294. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  295. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  296. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  297. },
  298. { /* SEC TDM */
  299. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  300. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  301. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  302. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  303. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  304. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  305. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  306. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  307. },
  308. { /* TERT TDM */
  309. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  310. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  311. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  312. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  313. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  314. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  315. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  316. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  317. },
  318. { /* QUAT TDM */
  319. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  320. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  321. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  322. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  323. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  324. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  325. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  326. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  327. },
  328. { /* QUIN TDM */
  329. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  330. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  331. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  332. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  333. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  334. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  335. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  336. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  337. },
  338. { /* SEN TDM */
  339. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  340. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  341. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  342. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  343. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  344. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  345. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  346. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  347. },
  348. };
  349. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  350. { /* PRI TDM */
  351. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  352. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  353. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  354. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  355. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  356. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  357. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  358. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  359. },
  360. { /* SEC TDM */
  361. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  362. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  363. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  364. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  365. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  366. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  367. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  368. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  369. },
  370. { /* TERT TDM */
  371. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  372. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  373. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  374. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  375. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  376. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  377. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  378. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  379. },
  380. { /* QUAT TDM */
  381. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  382. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  383. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  384. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  385. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  386. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  387. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  388. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  389. },
  390. { /* QUIN TDM */
  391. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  392. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  393. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  394. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  395. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  396. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  397. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  398. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  399. },
  400. { /* SEN TDM */
  401. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  402. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  403. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  404. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  405. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  406. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  407. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  408. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  409. },
  410. };
  411. /* Default configuration of AUX PCM channels */
  412. static struct dev_config aux_pcm_rx_cfg[] = {
  413. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  414. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  415. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  416. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  417. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  418. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  419. };
  420. static struct dev_config aux_pcm_tx_cfg[] = {
  421. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  422. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  423. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  424. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  425. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  426. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  427. };
  428. /* Default configuration of MI2S channels */
  429. static struct dev_config mi2s_rx_cfg[] = {
  430. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  431. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  432. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  433. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  434. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  435. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  436. };
  437. static struct dev_config mi2s_tx_cfg[] = {
  438. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  439. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  440. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  441. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  442. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  443. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  444. };
  445. static struct tdm_dev_config pri_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  446. { /* PRI TDM */
  447. { {0, 4, 0xFFFF} }, /* RX_0 */
  448. { {8, 12, 0xFFFF} }, /* RX_1 */
  449. { {16, 20, 0xFFFF} }, /* RX_2 */
  450. { {24, 28, 0xFFFF} }, /* RX_3 */
  451. { {0xFFFF} }, /* RX_4 */
  452. { {0xFFFF} }, /* RX_5 */
  453. { {0xFFFF} }, /* RX_6 */
  454. { {0xFFFF} }, /* RX_7 */
  455. },
  456. {
  457. { {0, 4, 8, 12, 0xFFFF} }, /* TX_0 */
  458. { {8, 12, 0xFFFF} }, /* TX_1 */
  459. { {16, 20, 0xFFFF} }, /* TX_2 */
  460. { {24, 28, 0xFFFF} }, /* TX_3 */
  461. { {0xFFFF} }, /* TX_4 */
  462. { {0xFFFF} }, /* TX_5 */
  463. { {0xFFFF} }, /* TX_6 */
  464. { {0xFFFF} }, /* TX_7 */
  465. },
  466. };
  467. static struct tdm_dev_config sec_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  468. { /* SEC TDM */
  469. { {0, 4, 0xFFFF} }, /* RX_0 */
  470. { {8, 12, 0xFFFF} }, /* RX_1 */
  471. { {16, 20, 0xFFFF} }, /* RX_2 */
  472. { {24, 28, 0xFFFF} }, /* RX_3 */
  473. { {0xFFFF} }, /* RX_4 */
  474. { {0xFFFF} }, /* RX_5 */
  475. { {0xFFFF} }, /* RX_6 */
  476. { {0xFFFF} }, /* RX_7 */
  477. },
  478. {
  479. { {0, 4, 0xFFFF} }, /* TX_0 */
  480. { {8, 12, 0xFFFF} }, /* TX_1 */
  481. { {16, 20, 0xFFFF} }, /* TX_2 */
  482. { {24, 28, 0xFFFF} }, /* TX_3 */
  483. { {0xFFFF} }, /* TX_4 */
  484. { {0xFFFF} }, /* TX_5 */
  485. { {0xFFFF} }, /* TX_6 */
  486. { {0xFFFF} }, /* TX_7 */
  487. },
  488. };
  489. static struct tdm_dev_config tert_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  490. { /* TERT TDM */
  491. { {0, 4, 0xFFFF} }, /* RX_0 */
  492. { {8, 12, 0xFFFF} }, /* RX_1 */
  493. { {16, 20, 0xFFFF} }, /* RX_2 */
  494. { {24, 28, 0xFFFF} }, /* RX_3 */
  495. { {0xFFFF} }, /* RX_4 */
  496. { {0xFFFF} }, /* RX_5 */
  497. { {0xFFFF} }, /* RX_6 */
  498. { {0xFFFF} }, /* RX_7 */
  499. },
  500. {
  501. { {0, 4, 0xFFFF} }, /* TX_0 */
  502. { {8, 12, 0xFFFF} }, /* TX_1 */
  503. { {16, 20, 0xFFFF} }, /* TX_2 */
  504. { {24, 28, 0xFFFF} }, /* TX_3 */
  505. { {0xFFFF} }, /* TX_4 */
  506. { {0xFFFF} }, /* TX_5 */
  507. { {0xFFFF} }, /* TX_6 */
  508. { {0xFFFF} }, /* TX_7 */
  509. },
  510. };
  511. static struct tdm_dev_config quat_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  512. { /* QUAT TDM */
  513. { {0, 4, 0xFFFF} }, /* RX_0 */
  514. { {8, 12, 0xFFFF} }, /* RX_1 */
  515. { {16, 20, 0xFFFF} }, /* RX_2 */
  516. { {24, 28, 0xFFFF} }, /* RX_3 */
  517. { {0xFFFF} }, /* RX_4 */
  518. { {0xFFFF} }, /* RX_5 */
  519. { {0xFFFF} }, /* RX_6 */
  520. { {0xFFFF} }, /* RX_7 */
  521. },
  522. {
  523. { {0, 4, 0xFFFF} }, /* TX_0 */
  524. { {8, 12, 0xFFFF} }, /* TX_1 */
  525. { {16, 20, 0xFFFF} }, /* TX_2 */
  526. { {24, 28, 0xFFFF} }, /* TX_3 */
  527. { {0xFFFF} }, /* TX_4 */
  528. { {0xFFFF} }, /* TX_5 */
  529. { {0xFFFF} }, /* TX_6 */
  530. { {0xFFFF} }, /* TX_7 */
  531. },
  532. };
  533. static struct tdm_dev_config quin_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  534. { /* QUIN TDM */
  535. { {0, 4, 0xFFFF} }, /* RX_0 */
  536. { {8, 12, 0xFFFF} }, /* RX_1 */
  537. { {16, 20, 0xFFFF} }, /* RX_2 */
  538. { {24, 28, 0xFFFF} }, /* RX_3 */
  539. { {0xFFFF} }, /* RX_4 */
  540. { {0xFFFF} }, /* RX_5 */
  541. { {0xFFFF} }, /* RX_6 */
  542. { {0xFFFF} }, /* RX_7 */
  543. },
  544. {
  545. { {0, 4, 0xFFFF} }, /* TX_0 */
  546. { {8, 12, 0xFFFF} }, /* TX_1 */
  547. { {16, 20, 0xFFFF} }, /* TX_2 */
  548. { {24, 28, 0xFFFF} }, /* TX_3 */
  549. { {0xFFFF} }, /* TX_4 */
  550. { {0xFFFF} }, /* TX_5 */
  551. { {0xFFFF} }, /* TX_6 */
  552. { {0xFFFF} }, /* TX_7 */
  553. },
  554. };
  555. static struct tdm_dev_config sen_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  556. { /* SEN TDM */
  557. { {0, 4, 0xFFFF} }, /* RX_0 */
  558. { {8, 12, 0xFFFF} }, /* RX_1 */
  559. { {16, 20, 0xFFFF} }, /* RX_2 */
  560. { {24, 28, 0xFFFF} }, /* RX_3 */
  561. { {0xFFFF} }, /* RX_4 */
  562. { {0xFFFF} }, /* RX_5 */
  563. { {0xFFFF} }, /* RX_6 */
  564. { {0xFFFF} }, /* RX_7 */
  565. },
  566. {
  567. { {0, 4, 0xFFFF} }, /* TX_0 */
  568. { {8, 12, 0xFFFF} }, /* TX_1 */
  569. { {16, 20, 0xFFFF} }, /* TX_2 */
  570. { {24, 28, 0xFFFF} }, /* TX_3 */
  571. { {0xFFFF} }, /* TX_4 */
  572. { {0xFFFF} }, /* TX_5 */
  573. { {0xFFFF} }, /* TX_6 */
  574. { {0xFFFF} }, /* TX_7 */
  575. },
  576. };
  577. static void *tdm_cfg[TDM_INTERFACE_MAX] = {
  578. pri_tdm_dev_config,
  579. sec_tdm_dev_config,
  580. tert_tdm_dev_config,
  581. quat_tdm_dev_config,
  582. quin_tdm_dev_config,
  583. sen_tdm_dev_config,
  584. };
  585. /* Default configuration of Codec DMA Interface RX */
  586. static struct dev_config cdc_dma_rx_cfg[] = {
  587. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  588. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  589. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  590. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  591. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  592. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  593. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  594. [RX_CDC_DMA_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  595. };
  596. /* Default configuration of Codec DMA Interface TX */
  597. static struct dev_config cdc_dma_tx_cfg[] = {
  598. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  599. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  600. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  601. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  602. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  603. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  604. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  605. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  606. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  607. };
  608. static struct dev_config afe_loopback_tx_cfg[] = {
  609. [AFE_LOOPBACK_TX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  610. };
  611. static int msm_vi_feed_tx_ch = 2;
  612. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  613. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  614. "S32_LE"};
  615. static char const *cdc80_bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
  616. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  617. "Six", "Seven", "Eight"};
  618. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  619. "KHZ_16", "KHZ_22P05",
  620. "KHZ_32", "KHZ_44P1", "KHZ_48",
  621. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  622. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  623. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  624. "Five", "Six", "Seven",
  625. "Eight"};
  626. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  627. "KHZ_48", "KHZ_176P4",
  628. "KHZ_352P8"};
  629. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  630. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  631. "Five", "Six", "Seven", "Eight"};
  632. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  633. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  634. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  635. "KHZ_48", "KHZ_88P2", "KHZ_96",
  636. "KHZ_176P4", "KHZ_192","KHZ_352P8",
  637. "KHZ_384"};
  638. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  639. "Five", "Six", "Seven",
  640. "Eight"};
  641. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  642. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  643. "Five", "Six", "Seven",
  644. "Eight"};
  645. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  646. "KHZ_16", "KHZ_22P05",
  647. "KHZ_32", "KHZ_44P1", "KHZ_48",
  648. "KHZ_88P2", "KHZ_96",
  649. "KHZ_176P4", "KHZ_192",
  650. "KHZ_352P8", "KHZ_384"};
  651. static char const *cdc80_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  652. "KHZ_16", "KHZ_22P05",
  653. "KHZ_32", "KHZ_44P1", "KHZ_48",
  654. "KHZ_88P2", "KHZ_96",
  655. "KHZ_176P4", "KHZ_192"};
  656. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  657. "S24_3LE"};
  658. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  659. "KHZ_192", "KHZ_32", "KHZ_44P1",
  660. "KHZ_88P2", "KHZ_176P4"};
  661. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  662. "KHZ_44P1", "KHZ_48",
  663. "KHZ_88P2", "KHZ_96"};
  664. static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
  665. "KHZ_44P1", "KHZ_48",
  666. "KHZ_88P2", "KHZ_96"};
  667. static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
  668. "KHZ_44P1", "KHZ_48",
  669. "KHZ_88P2", "KHZ_96"};
  670. static const char *const afe_loopback_tx_ch_text[] = {"One", "Two"};
  671. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  672. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  673. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  674. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  675. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  676. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  677. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  678. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  679. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  680. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  681. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  682. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  683. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  684. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  685. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  686. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  687. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  688. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  689. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  690. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  691. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  692. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  693. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  694. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  695. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  696. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  697. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  698. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  699. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  700. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  701. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  702. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  703. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  704. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_sample_rate, mi2s_rate_text);
  705. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  706. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  707. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  708. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  709. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  710. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_sample_rate, mi2s_rate_text);
  711. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  712. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  713. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  714. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  715. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  716. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  717. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  718. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_chs, mi2s_ch_text);
  719. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  720. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  721. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  722. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  723. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  724. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_chs, mi2s_ch_text);
  725. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  726. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  727. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  728. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  729. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  730. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  731. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  732. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_6_chs, cdc_dma_rx_ch_text);
  733. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  734. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  735. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  736. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  737. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  738. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  739. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  740. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  741. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  742. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  743. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  744. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  745. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  746. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  747. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  748. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  749. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  750. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  751. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  752. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  753. cdc_dma_sample_rate_text);
  754. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  755. cdc_dma_sample_rate_text);
  756. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  757. cdc_dma_sample_rate_text);
  758. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  759. cdc_dma_sample_rate_text);
  760. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  761. cdc_dma_sample_rate_text);
  762. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  763. cdc_dma_sample_rate_text);
  764. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  765. cdc_dma_sample_rate_text);
  766. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  767. cdc_dma_sample_rate_text);
  768. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  769. cdc_dma_sample_rate_text);
  770. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  771. cdc_dma_sample_rate_text);
  772. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  773. cdc_dma_sample_rate_text);
  774. /* WCD9380 */
  775. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_0_format, cdc80_bit_format_text);
  776. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_1_format, cdc80_bit_format_text);
  777. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_2_format, cdc80_bit_format_text);
  778. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_3_format, cdc80_bit_format_text);
  779. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_5_format, cdc80_bit_format_text);
  780. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_6_format, cdc80_bit_format_text);
  781. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_0_sample_rate,
  782. cdc80_dma_sample_rate_text);
  783. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_1_sample_rate,
  784. cdc80_dma_sample_rate_text);
  785. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_2_sample_rate,
  786. cdc80_dma_sample_rate_text);
  787. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_3_sample_rate,
  788. cdc80_dma_sample_rate_text);
  789. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_5_sample_rate,
  790. cdc80_dma_sample_rate_text);
  791. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_6_sample_rate,
  792. cdc80_dma_sample_rate_text);
  793. /* WCD9385 */
  794. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_0_format, bit_format_text);
  795. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_1_format, bit_format_text);
  796. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_2_format, bit_format_text);
  797. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_3_format, bit_format_text);
  798. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_5_format, bit_format_text);
  799. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_6_format, bit_format_text);
  800. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_0_sample_rate,
  801. cdc_dma_sample_rate_text);
  802. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_1_sample_rate,
  803. cdc_dma_sample_rate_text);
  804. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_2_sample_rate,
  805. cdc_dma_sample_rate_text);
  806. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_3_sample_rate,
  807. cdc_dma_sample_rate_text);
  808. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_5_sample_rate,
  809. cdc_dma_sample_rate_text);
  810. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_6_sample_rate,
  811. cdc_dma_sample_rate_text);
  812. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  813. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  814. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  815. ext_disp_sample_rate_text);
  816. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  817. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
  818. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
  819. static SOC_ENUM_SINGLE_EXT_DECL(afe_loopback_tx_chs, afe_loopback_tx_ch_text);
  820. static bool is_initial_boot;
  821. static bool codec_reg_done;
  822. static struct snd_soc_card snd_soc_card_lahaina_msm;
  823. static int dmic_0_1_gpio_cnt;
  824. static int dmic_2_3_gpio_cnt;
  825. static int dmic_4_5_gpio_cnt;
  826. static void *def_wcd_mbhc_cal(void);
  827. static int msm_aux_codec_init(struct snd_soc_pcm_runtime*);
  828. static int msm_int_audrx_init(struct snd_soc_pcm_runtime*);
  829. /*
  830. * Need to report LINEIN
  831. * if R/L channel impedance is larger than 5K ohm
  832. */
  833. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  834. .read_fw_bin = false,
  835. .calibration = NULL,
  836. .detect_extn_cable = true,
  837. .mono_stero_detection = false,
  838. .swap_gnd_mic = NULL,
  839. .hs_ext_micbias = true,
  840. .key_code[0] = KEY_MEDIA,
  841. .key_code[1] = KEY_VOICECOMMAND,
  842. .key_code[2] = KEY_VOLUMEUP,
  843. .key_code[3] = KEY_VOLUMEDOWN,
  844. .key_code[4] = 0,
  845. .key_code[5] = 0,
  846. .key_code[6] = 0,
  847. .key_code[7] = 0,
  848. .linein_th = 5000,
  849. .moisture_en = false,
  850. .mbhc_micbias = MIC_BIAS_2,
  851. .anc_micbias = MIC_BIAS_2,
  852. .enable_anc_mic_detect = false,
  853. .moisture_duty_cycle_en = true,
  854. };
  855. /* set audio task affinity to core 1 & 2 */
  856. static const unsigned int audio_core_list[] = {1, 2};
  857. static cpumask_t audio_cpu_map = CPU_MASK_NONE;
  858. static struct dev_pm_qos_request *msm_audio_req = NULL;
  859. static unsigned int qos_client_active_cnt = 0;
  860. static void msm_audio_add_qos_request()
  861. {
  862. int i;
  863. int cpu = 0;
  864. msm_audio_req = kzalloc(sizeof(struct dev_pm_qos_request) * NR_CPUS,
  865. GFP_KERNEL);
  866. if (!msm_audio_req) {
  867. pr_err("%s failed to alloc mem for qos req.\n", __func__);
  868. return;
  869. }
  870. for (i = 0; i < ARRAY_SIZE(audio_core_list); i++) {
  871. if (audio_core_list[i] >= NR_CPUS)
  872. pr_err("%s incorrect cpu id: %d specified.\n", __func__, audio_core_list[i]);
  873. else
  874. cpumask_set_cpu(audio_core_list[i], &audio_cpu_map);
  875. }
  876. for_each_cpu(cpu, &audio_cpu_map) {
  877. dev_pm_qos_add_request(get_cpu_device(cpu),
  878. &msm_audio_req[cpu],
  879. DEV_PM_QOS_RESUME_LATENCY,
  880. PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE);
  881. pr_debug("%s set cpu affinity to core %d.\n", __func__, cpu);
  882. }
  883. }
  884. static void msm_audio_remove_qos_request()
  885. {
  886. int cpu = 0;
  887. if (msm_audio_req) {
  888. for_each_cpu(cpu, &audio_cpu_map) {
  889. dev_pm_qos_remove_request(
  890. &msm_audio_req[cpu]);
  891. pr_debug("%s remove cpu affinity of core %d.\n", __func__, cpu);
  892. }
  893. kfree(msm_audio_req);
  894. }
  895. }
  896. static void msm_audio_update_qos_request(u32 latency)
  897. {
  898. int cpu = 0;
  899. if (msm_audio_req) {
  900. for_each_cpu(cpu, &audio_cpu_map) {
  901. dev_pm_qos_update_request(
  902. &msm_audio_req[cpu], latency);
  903. pr_debug("%s update latency of core %d to %ul.\n", __func__, cpu, latency);
  904. }
  905. }
  906. }
  907. static inline int param_is_mask(int p)
  908. {
  909. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  910. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  911. }
  912. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  913. int n)
  914. {
  915. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  916. }
  917. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  918. unsigned int bit)
  919. {
  920. if (bit >= SNDRV_MASK_MAX)
  921. return;
  922. if (param_is_mask(n)) {
  923. struct snd_mask *m = param_to_mask(p, n);
  924. m->bits[0] = 0;
  925. m->bits[1] = 0;
  926. m->bits[bit >> 5] |= (1 << (bit & 31));
  927. }
  928. }
  929. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  930. struct snd_ctl_elem_value *ucontrol)
  931. {
  932. int sample_rate_val = 0;
  933. switch (usb_rx_cfg.sample_rate) {
  934. case SAMPLING_RATE_384KHZ:
  935. sample_rate_val = 12;
  936. break;
  937. case SAMPLING_RATE_352P8KHZ:
  938. sample_rate_val = 11;
  939. break;
  940. case SAMPLING_RATE_192KHZ:
  941. sample_rate_val = 10;
  942. break;
  943. case SAMPLING_RATE_176P4KHZ:
  944. sample_rate_val = 9;
  945. break;
  946. case SAMPLING_RATE_96KHZ:
  947. sample_rate_val = 8;
  948. break;
  949. case SAMPLING_RATE_88P2KHZ:
  950. sample_rate_val = 7;
  951. break;
  952. case SAMPLING_RATE_48KHZ:
  953. sample_rate_val = 6;
  954. break;
  955. case SAMPLING_RATE_44P1KHZ:
  956. sample_rate_val = 5;
  957. break;
  958. case SAMPLING_RATE_32KHZ:
  959. sample_rate_val = 4;
  960. break;
  961. case SAMPLING_RATE_22P05KHZ:
  962. sample_rate_val = 3;
  963. break;
  964. case SAMPLING_RATE_16KHZ:
  965. sample_rate_val = 2;
  966. break;
  967. case SAMPLING_RATE_11P025KHZ:
  968. sample_rate_val = 1;
  969. break;
  970. case SAMPLING_RATE_8KHZ:
  971. default:
  972. sample_rate_val = 0;
  973. break;
  974. }
  975. ucontrol->value.integer.value[0] = sample_rate_val;
  976. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  977. usb_rx_cfg.sample_rate);
  978. return 0;
  979. }
  980. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  981. struct snd_ctl_elem_value *ucontrol)
  982. {
  983. switch (ucontrol->value.integer.value[0]) {
  984. case 12:
  985. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  986. break;
  987. case 11:
  988. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  989. break;
  990. case 10:
  991. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  992. break;
  993. case 9:
  994. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  995. break;
  996. case 8:
  997. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  998. break;
  999. case 7:
  1000. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1001. break;
  1002. case 6:
  1003. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1004. break;
  1005. case 5:
  1006. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1007. break;
  1008. case 4:
  1009. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1010. break;
  1011. case 3:
  1012. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1013. break;
  1014. case 2:
  1015. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1016. break;
  1017. case 1:
  1018. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1019. break;
  1020. case 0:
  1021. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1022. break;
  1023. default:
  1024. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1025. break;
  1026. }
  1027. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  1028. __func__, ucontrol->value.integer.value[0],
  1029. usb_rx_cfg.sample_rate);
  1030. return 0;
  1031. }
  1032. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1033. struct snd_ctl_elem_value *ucontrol)
  1034. {
  1035. int sample_rate_val = 0;
  1036. switch (usb_tx_cfg.sample_rate) {
  1037. case SAMPLING_RATE_384KHZ:
  1038. sample_rate_val = 12;
  1039. break;
  1040. case SAMPLING_RATE_352P8KHZ:
  1041. sample_rate_val = 11;
  1042. break;
  1043. case SAMPLING_RATE_192KHZ:
  1044. sample_rate_val = 10;
  1045. break;
  1046. case SAMPLING_RATE_176P4KHZ:
  1047. sample_rate_val = 9;
  1048. break;
  1049. case SAMPLING_RATE_96KHZ:
  1050. sample_rate_val = 8;
  1051. break;
  1052. case SAMPLING_RATE_88P2KHZ:
  1053. sample_rate_val = 7;
  1054. break;
  1055. case SAMPLING_RATE_48KHZ:
  1056. sample_rate_val = 6;
  1057. break;
  1058. case SAMPLING_RATE_44P1KHZ:
  1059. sample_rate_val = 5;
  1060. break;
  1061. case SAMPLING_RATE_32KHZ:
  1062. sample_rate_val = 4;
  1063. break;
  1064. case SAMPLING_RATE_22P05KHZ:
  1065. sample_rate_val = 3;
  1066. break;
  1067. case SAMPLING_RATE_16KHZ:
  1068. sample_rate_val = 2;
  1069. break;
  1070. case SAMPLING_RATE_11P025KHZ:
  1071. sample_rate_val = 1;
  1072. break;
  1073. case SAMPLING_RATE_8KHZ:
  1074. sample_rate_val = 0;
  1075. break;
  1076. default:
  1077. sample_rate_val = 6;
  1078. break;
  1079. }
  1080. ucontrol->value.integer.value[0] = sample_rate_val;
  1081. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  1082. usb_tx_cfg.sample_rate);
  1083. return 0;
  1084. }
  1085. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1086. struct snd_ctl_elem_value *ucontrol)
  1087. {
  1088. switch (ucontrol->value.integer.value[0]) {
  1089. case 12:
  1090. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1091. break;
  1092. case 11:
  1093. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1094. break;
  1095. case 10:
  1096. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1097. break;
  1098. case 9:
  1099. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1100. break;
  1101. case 8:
  1102. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1103. break;
  1104. case 7:
  1105. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1106. break;
  1107. case 6:
  1108. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1109. break;
  1110. case 5:
  1111. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1112. break;
  1113. case 4:
  1114. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1115. break;
  1116. case 3:
  1117. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1118. break;
  1119. case 2:
  1120. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1121. break;
  1122. case 1:
  1123. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1124. break;
  1125. case 0:
  1126. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1127. break;
  1128. default:
  1129. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1130. break;
  1131. }
  1132. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  1133. __func__, ucontrol->value.integer.value[0],
  1134. usb_tx_cfg.sample_rate);
  1135. return 0;
  1136. }
  1137. static int afe_loopback_tx_ch_get(struct snd_kcontrol *kcontrol,
  1138. struct snd_ctl_elem_value *ucontrol)
  1139. {
  1140. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  1141. afe_loopback_tx_cfg[0].channels);
  1142. ucontrol->value.enumerated.item[0] =
  1143. afe_loopback_tx_cfg[0].channels - 1;
  1144. return 0;
  1145. }
  1146. static int afe_loopback_tx_ch_put(struct snd_kcontrol *kcontrol,
  1147. struct snd_ctl_elem_value *ucontrol)
  1148. {
  1149. afe_loopback_tx_cfg[0].channels =
  1150. ucontrol->value.enumerated.item[0] + 1;
  1151. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  1152. afe_loopback_tx_cfg[0].channels);
  1153. return 1;
  1154. }
  1155. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  1156. struct snd_ctl_elem_value *ucontrol)
  1157. {
  1158. switch (usb_rx_cfg.bit_format) {
  1159. case SNDRV_PCM_FORMAT_S32_LE:
  1160. ucontrol->value.integer.value[0] = 3;
  1161. break;
  1162. case SNDRV_PCM_FORMAT_S24_3LE:
  1163. ucontrol->value.integer.value[0] = 2;
  1164. break;
  1165. case SNDRV_PCM_FORMAT_S24_LE:
  1166. ucontrol->value.integer.value[0] = 1;
  1167. break;
  1168. case SNDRV_PCM_FORMAT_S16_LE:
  1169. default:
  1170. ucontrol->value.integer.value[0] = 0;
  1171. break;
  1172. }
  1173. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1174. __func__, usb_rx_cfg.bit_format,
  1175. ucontrol->value.integer.value[0]);
  1176. return 0;
  1177. }
  1178. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  1179. struct snd_ctl_elem_value *ucontrol)
  1180. {
  1181. int rc = 0;
  1182. switch (ucontrol->value.integer.value[0]) {
  1183. case 3:
  1184. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1185. break;
  1186. case 2:
  1187. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1188. break;
  1189. case 1:
  1190. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1191. break;
  1192. case 0:
  1193. default:
  1194. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1195. break;
  1196. }
  1197. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1198. __func__, usb_rx_cfg.bit_format,
  1199. ucontrol->value.integer.value[0]);
  1200. return rc;
  1201. }
  1202. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  1203. struct snd_ctl_elem_value *ucontrol)
  1204. {
  1205. switch (usb_tx_cfg.bit_format) {
  1206. case SNDRV_PCM_FORMAT_S32_LE:
  1207. ucontrol->value.integer.value[0] = 3;
  1208. break;
  1209. case SNDRV_PCM_FORMAT_S24_3LE:
  1210. ucontrol->value.integer.value[0] = 2;
  1211. break;
  1212. case SNDRV_PCM_FORMAT_S24_LE:
  1213. ucontrol->value.integer.value[0] = 1;
  1214. break;
  1215. case SNDRV_PCM_FORMAT_S16_LE:
  1216. default:
  1217. ucontrol->value.integer.value[0] = 0;
  1218. break;
  1219. }
  1220. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1221. __func__, usb_tx_cfg.bit_format,
  1222. ucontrol->value.integer.value[0]);
  1223. return 0;
  1224. }
  1225. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  1226. struct snd_ctl_elem_value *ucontrol)
  1227. {
  1228. int rc = 0;
  1229. switch (ucontrol->value.integer.value[0]) {
  1230. case 3:
  1231. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1232. break;
  1233. case 2:
  1234. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1235. break;
  1236. case 1:
  1237. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1238. break;
  1239. case 0:
  1240. default:
  1241. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1242. break;
  1243. }
  1244. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1245. __func__, usb_tx_cfg.bit_format,
  1246. ucontrol->value.integer.value[0]);
  1247. return rc;
  1248. }
  1249. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1250. struct snd_ctl_elem_value *ucontrol)
  1251. {
  1252. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1253. usb_rx_cfg.channels);
  1254. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1255. return 0;
  1256. }
  1257. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1258. struct snd_ctl_elem_value *ucontrol)
  1259. {
  1260. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1261. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1262. return 1;
  1263. }
  1264. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1265. struct snd_ctl_elem_value *ucontrol)
  1266. {
  1267. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1268. usb_tx_cfg.channels);
  1269. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1270. return 0;
  1271. }
  1272. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1273. struct snd_ctl_elem_value *ucontrol)
  1274. {
  1275. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1276. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1277. return 1;
  1278. }
  1279. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  1280. struct snd_ctl_elem_value *ucontrol)
  1281. {
  1282. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  1283. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  1284. ucontrol->value.integer.value[0]);
  1285. return 0;
  1286. }
  1287. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  1288. struct snd_ctl_elem_value *ucontrol)
  1289. {
  1290. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  1291. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  1292. return 1;
  1293. }
  1294. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  1295. {
  1296. int idx = 0;
  1297. if (strnstr(kcontrol->id.name, "Display Port RX",
  1298. sizeof("Display Port RX"))) {
  1299. idx = EXT_DISP_RX_IDX_DP;
  1300. } else if (strnstr(kcontrol->id.name, "Display Port1 RX",
  1301. sizeof("Display Port1 RX"))) {
  1302. idx = EXT_DISP_RX_IDX_DP1;
  1303. } else {
  1304. pr_err("%s: unsupported BE: %s\n",
  1305. __func__, kcontrol->id.name);
  1306. idx = -EINVAL;
  1307. }
  1308. return idx;
  1309. }
  1310. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  1311. struct snd_ctl_elem_value *ucontrol)
  1312. {
  1313. int idx = ext_disp_get_port_idx(kcontrol);
  1314. if (idx < 0)
  1315. return idx;
  1316. switch (ext_disp_rx_cfg[idx].bit_format) {
  1317. case SNDRV_PCM_FORMAT_S24_3LE:
  1318. ucontrol->value.integer.value[0] = 2;
  1319. break;
  1320. case SNDRV_PCM_FORMAT_S24_LE:
  1321. ucontrol->value.integer.value[0] = 1;
  1322. break;
  1323. case SNDRV_PCM_FORMAT_S16_LE:
  1324. default:
  1325. ucontrol->value.integer.value[0] = 0;
  1326. break;
  1327. }
  1328. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1329. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1330. ucontrol->value.integer.value[0]);
  1331. return 0;
  1332. }
  1333. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  1334. struct snd_ctl_elem_value *ucontrol)
  1335. {
  1336. int idx = ext_disp_get_port_idx(kcontrol);
  1337. if (idx < 0)
  1338. return idx;
  1339. switch (ucontrol->value.integer.value[0]) {
  1340. case 2:
  1341. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1342. break;
  1343. case 1:
  1344. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1345. break;
  1346. case 0:
  1347. default:
  1348. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1349. break;
  1350. }
  1351. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1352. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1353. ucontrol->value.integer.value[0]);
  1354. return 0;
  1355. }
  1356. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  1357. struct snd_ctl_elem_value *ucontrol)
  1358. {
  1359. int idx = ext_disp_get_port_idx(kcontrol);
  1360. if (idx < 0)
  1361. return idx;
  1362. ucontrol->value.integer.value[0] =
  1363. ext_disp_rx_cfg[idx].channels - 2;
  1364. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1365. idx, ext_disp_rx_cfg[idx].channels);
  1366. return 0;
  1367. }
  1368. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  1369. struct snd_ctl_elem_value *ucontrol)
  1370. {
  1371. int idx = ext_disp_get_port_idx(kcontrol);
  1372. if (idx < 0)
  1373. return idx;
  1374. ext_disp_rx_cfg[idx].channels =
  1375. ucontrol->value.integer.value[0] + 2;
  1376. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1377. idx, ext_disp_rx_cfg[idx].channels);
  1378. return 1;
  1379. }
  1380. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1381. struct snd_ctl_elem_value *ucontrol)
  1382. {
  1383. int sample_rate_val;
  1384. int idx = ext_disp_get_port_idx(kcontrol);
  1385. if (idx < 0)
  1386. return idx;
  1387. switch (ext_disp_rx_cfg[idx].sample_rate) {
  1388. case SAMPLING_RATE_176P4KHZ:
  1389. sample_rate_val = 6;
  1390. break;
  1391. case SAMPLING_RATE_88P2KHZ:
  1392. sample_rate_val = 5;
  1393. break;
  1394. case SAMPLING_RATE_44P1KHZ:
  1395. sample_rate_val = 4;
  1396. break;
  1397. case SAMPLING_RATE_32KHZ:
  1398. sample_rate_val = 3;
  1399. break;
  1400. case SAMPLING_RATE_192KHZ:
  1401. sample_rate_val = 2;
  1402. break;
  1403. case SAMPLING_RATE_96KHZ:
  1404. sample_rate_val = 1;
  1405. break;
  1406. case SAMPLING_RATE_48KHZ:
  1407. default:
  1408. sample_rate_val = 0;
  1409. break;
  1410. }
  1411. ucontrol->value.integer.value[0] = sample_rate_val;
  1412. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  1413. idx, ext_disp_rx_cfg[idx].sample_rate);
  1414. return 0;
  1415. }
  1416. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1417. struct snd_ctl_elem_value *ucontrol)
  1418. {
  1419. int idx = ext_disp_get_port_idx(kcontrol);
  1420. if (idx < 0)
  1421. return idx;
  1422. switch (ucontrol->value.integer.value[0]) {
  1423. case 6:
  1424. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  1425. break;
  1426. case 5:
  1427. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  1428. break;
  1429. case 4:
  1430. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  1431. break;
  1432. case 3:
  1433. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  1434. break;
  1435. case 2:
  1436. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  1437. break;
  1438. case 1:
  1439. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  1440. break;
  1441. case 0:
  1442. default:
  1443. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  1444. break;
  1445. }
  1446. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  1447. __func__, ucontrol->value.integer.value[0], idx,
  1448. ext_disp_rx_cfg[idx].sample_rate);
  1449. return 0;
  1450. }
  1451. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1452. struct snd_ctl_elem_value *ucontrol)
  1453. {
  1454. pr_debug("%s: proxy_rx channels = %d\n",
  1455. __func__, proxy_rx_cfg.channels);
  1456. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1457. return 0;
  1458. }
  1459. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1460. struct snd_ctl_elem_value *ucontrol)
  1461. {
  1462. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1463. pr_debug("%s: proxy_rx channels = %d\n",
  1464. __func__, proxy_rx_cfg.channels);
  1465. return 1;
  1466. }
  1467. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1468. struct tdm_port *port)
  1469. {
  1470. if (port) {
  1471. if (strnstr(kcontrol->id.name, "PRI",
  1472. sizeof(kcontrol->id.name))) {
  1473. port->mode = TDM_PRI;
  1474. } else if (strnstr(kcontrol->id.name, "SEC",
  1475. sizeof(kcontrol->id.name))) {
  1476. port->mode = TDM_SEC;
  1477. } else if (strnstr(kcontrol->id.name, "TERT",
  1478. sizeof(kcontrol->id.name))) {
  1479. port->mode = TDM_TERT;
  1480. } else if (strnstr(kcontrol->id.name, "QUAT",
  1481. sizeof(kcontrol->id.name))) {
  1482. port->mode = TDM_QUAT;
  1483. } else if (strnstr(kcontrol->id.name, "QUIN",
  1484. sizeof(kcontrol->id.name))) {
  1485. port->mode = TDM_QUIN;
  1486. } else if (strnstr(kcontrol->id.name, "SEN",
  1487. sizeof(kcontrol->id.name))) {
  1488. port->mode = TDM_SEN;
  1489. } else {
  1490. pr_err("%s: unsupported mode in: %s\n",
  1491. __func__, kcontrol->id.name);
  1492. return -EINVAL;
  1493. }
  1494. if (strnstr(kcontrol->id.name, "RX_0",
  1495. sizeof(kcontrol->id.name)) ||
  1496. strnstr(kcontrol->id.name, "TX_0",
  1497. sizeof(kcontrol->id.name))) {
  1498. port->channel = TDM_0;
  1499. } else if (strnstr(kcontrol->id.name, "RX_1",
  1500. sizeof(kcontrol->id.name)) ||
  1501. strnstr(kcontrol->id.name, "TX_1",
  1502. sizeof(kcontrol->id.name))) {
  1503. port->channel = TDM_1;
  1504. } else if (strnstr(kcontrol->id.name, "RX_2",
  1505. sizeof(kcontrol->id.name)) ||
  1506. strnstr(kcontrol->id.name, "TX_2",
  1507. sizeof(kcontrol->id.name))) {
  1508. port->channel = TDM_2;
  1509. } else if (strnstr(kcontrol->id.name, "RX_3",
  1510. sizeof(kcontrol->id.name)) ||
  1511. strnstr(kcontrol->id.name, "TX_3",
  1512. sizeof(kcontrol->id.name))) {
  1513. port->channel = TDM_3;
  1514. } else if (strnstr(kcontrol->id.name, "RX_4",
  1515. sizeof(kcontrol->id.name)) ||
  1516. strnstr(kcontrol->id.name, "TX_4",
  1517. sizeof(kcontrol->id.name))) {
  1518. port->channel = TDM_4;
  1519. } else if (strnstr(kcontrol->id.name, "RX_5",
  1520. sizeof(kcontrol->id.name)) ||
  1521. strnstr(kcontrol->id.name, "TX_5",
  1522. sizeof(kcontrol->id.name))) {
  1523. port->channel = TDM_5;
  1524. } else if (strnstr(kcontrol->id.name, "RX_6",
  1525. sizeof(kcontrol->id.name)) ||
  1526. strnstr(kcontrol->id.name, "TX_6",
  1527. sizeof(kcontrol->id.name))) {
  1528. port->channel = TDM_6;
  1529. } else if (strnstr(kcontrol->id.name, "RX_7",
  1530. sizeof(kcontrol->id.name)) ||
  1531. strnstr(kcontrol->id.name, "TX_7",
  1532. sizeof(kcontrol->id.name))) {
  1533. port->channel = TDM_7;
  1534. } else {
  1535. pr_err("%s: unsupported channel in: %s\n",
  1536. __func__, kcontrol->id.name);
  1537. return -EINVAL;
  1538. }
  1539. } else {
  1540. return -EINVAL;
  1541. }
  1542. return 0;
  1543. }
  1544. static int tdm_get_sample_rate(int value)
  1545. {
  1546. int sample_rate = 0;
  1547. switch (value) {
  1548. case 0:
  1549. sample_rate = SAMPLING_RATE_8KHZ;
  1550. break;
  1551. case 1:
  1552. sample_rate = SAMPLING_RATE_16KHZ;
  1553. break;
  1554. case 2:
  1555. sample_rate = SAMPLING_RATE_32KHZ;
  1556. break;
  1557. case 3:
  1558. sample_rate = SAMPLING_RATE_48KHZ;
  1559. break;
  1560. case 4:
  1561. sample_rate = SAMPLING_RATE_176P4KHZ;
  1562. break;
  1563. case 5:
  1564. sample_rate = SAMPLING_RATE_352P8KHZ;
  1565. break;
  1566. default:
  1567. sample_rate = SAMPLING_RATE_48KHZ;
  1568. break;
  1569. }
  1570. return sample_rate;
  1571. }
  1572. static int tdm_get_sample_rate_val(int sample_rate)
  1573. {
  1574. int sample_rate_val = 0;
  1575. switch (sample_rate) {
  1576. case SAMPLING_RATE_8KHZ:
  1577. sample_rate_val = 0;
  1578. break;
  1579. case SAMPLING_RATE_16KHZ:
  1580. sample_rate_val = 1;
  1581. break;
  1582. case SAMPLING_RATE_32KHZ:
  1583. sample_rate_val = 2;
  1584. break;
  1585. case SAMPLING_RATE_48KHZ:
  1586. sample_rate_val = 3;
  1587. break;
  1588. case SAMPLING_RATE_176P4KHZ:
  1589. sample_rate_val = 4;
  1590. break;
  1591. case SAMPLING_RATE_352P8KHZ:
  1592. sample_rate_val = 5;
  1593. break;
  1594. default:
  1595. sample_rate_val = 3;
  1596. break;
  1597. }
  1598. return sample_rate_val;
  1599. }
  1600. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1601. struct snd_ctl_elem_value *ucontrol)
  1602. {
  1603. struct tdm_port port;
  1604. int ret = tdm_get_port_idx(kcontrol, &port);
  1605. if (ret) {
  1606. pr_err("%s: unsupported control: %s\n",
  1607. __func__, kcontrol->id.name);
  1608. } else {
  1609. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1610. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1611. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1612. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1613. ucontrol->value.enumerated.item[0]);
  1614. }
  1615. return ret;
  1616. }
  1617. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1618. struct snd_ctl_elem_value *ucontrol)
  1619. {
  1620. struct tdm_port port;
  1621. int ret = tdm_get_port_idx(kcontrol, &port);
  1622. if (ret) {
  1623. pr_err("%s: unsupported control: %s\n",
  1624. __func__, kcontrol->id.name);
  1625. } else {
  1626. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1627. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1628. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1629. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1630. ucontrol->value.enumerated.item[0]);
  1631. }
  1632. return ret;
  1633. }
  1634. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1635. struct snd_ctl_elem_value *ucontrol)
  1636. {
  1637. struct tdm_port port;
  1638. int ret = tdm_get_port_idx(kcontrol, &port);
  1639. if (ret) {
  1640. pr_err("%s: unsupported control: %s\n",
  1641. __func__, kcontrol->id.name);
  1642. } else {
  1643. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1644. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1645. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1646. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1647. ucontrol->value.enumerated.item[0]);
  1648. }
  1649. return ret;
  1650. }
  1651. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1652. struct snd_ctl_elem_value *ucontrol)
  1653. {
  1654. struct tdm_port port;
  1655. int ret = tdm_get_port_idx(kcontrol, &port);
  1656. if (ret) {
  1657. pr_err("%s: unsupported control: %s\n",
  1658. __func__, kcontrol->id.name);
  1659. } else {
  1660. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1661. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1662. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1663. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1664. ucontrol->value.enumerated.item[0]);
  1665. }
  1666. return ret;
  1667. }
  1668. static int tdm_get_format(int value)
  1669. {
  1670. int format = 0;
  1671. switch (value) {
  1672. case 0:
  1673. format = SNDRV_PCM_FORMAT_S16_LE;
  1674. break;
  1675. case 1:
  1676. format = SNDRV_PCM_FORMAT_S24_LE;
  1677. break;
  1678. case 2:
  1679. format = SNDRV_PCM_FORMAT_S32_LE;
  1680. break;
  1681. default:
  1682. format = SNDRV_PCM_FORMAT_S16_LE;
  1683. break;
  1684. }
  1685. return format;
  1686. }
  1687. static int tdm_get_format_val(int format)
  1688. {
  1689. int value = 0;
  1690. switch (format) {
  1691. case SNDRV_PCM_FORMAT_S16_LE:
  1692. value = 0;
  1693. break;
  1694. case SNDRV_PCM_FORMAT_S24_LE:
  1695. value = 1;
  1696. break;
  1697. case SNDRV_PCM_FORMAT_S32_LE:
  1698. value = 2;
  1699. break;
  1700. default:
  1701. value = 0;
  1702. break;
  1703. }
  1704. return value;
  1705. }
  1706. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1707. struct snd_ctl_elem_value *ucontrol)
  1708. {
  1709. struct tdm_port port;
  1710. int ret = tdm_get_port_idx(kcontrol, &port);
  1711. if (ret) {
  1712. pr_err("%s: unsupported control: %s\n",
  1713. __func__, kcontrol->id.name);
  1714. } else {
  1715. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1716. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1717. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1718. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1719. ucontrol->value.enumerated.item[0]);
  1720. }
  1721. return ret;
  1722. }
  1723. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1724. struct snd_ctl_elem_value *ucontrol)
  1725. {
  1726. struct tdm_port port;
  1727. int ret = tdm_get_port_idx(kcontrol, &port);
  1728. if (ret) {
  1729. pr_err("%s: unsupported control: %s\n",
  1730. __func__, kcontrol->id.name);
  1731. } else {
  1732. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1733. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1734. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1735. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1736. ucontrol->value.enumerated.item[0]);
  1737. }
  1738. return ret;
  1739. }
  1740. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1741. struct snd_ctl_elem_value *ucontrol)
  1742. {
  1743. struct tdm_port port;
  1744. int ret = tdm_get_port_idx(kcontrol, &port);
  1745. if (ret) {
  1746. pr_err("%s: unsupported control: %s\n",
  1747. __func__, kcontrol->id.name);
  1748. } else {
  1749. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1750. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1751. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1752. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1753. ucontrol->value.enumerated.item[0]);
  1754. }
  1755. return ret;
  1756. }
  1757. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1758. struct snd_ctl_elem_value *ucontrol)
  1759. {
  1760. struct tdm_port port;
  1761. int ret = tdm_get_port_idx(kcontrol, &port);
  1762. if (ret) {
  1763. pr_err("%s: unsupported control: %s\n",
  1764. __func__, kcontrol->id.name);
  1765. } else {
  1766. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1767. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1768. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1769. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1770. ucontrol->value.enumerated.item[0]);
  1771. }
  1772. return ret;
  1773. }
  1774. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1775. struct snd_ctl_elem_value *ucontrol)
  1776. {
  1777. struct tdm_port port;
  1778. int ret = tdm_get_port_idx(kcontrol, &port);
  1779. if (ret) {
  1780. pr_err("%s: unsupported control: %s\n",
  1781. __func__, kcontrol->id.name);
  1782. } else {
  1783. ucontrol->value.enumerated.item[0] =
  1784. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1785. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1786. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1787. ucontrol->value.enumerated.item[0]);
  1788. }
  1789. return ret;
  1790. }
  1791. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1792. struct snd_ctl_elem_value *ucontrol)
  1793. {
  1794. struct tdm_port port;
  1795. int ret = tdm_get_port_idx(kcontrol, &port);
  1796. if (ret) {
  1797. pr_err("%s: unsupported control: %s\n",
  1798. __func__, kcontrol->id.name);
  1799. } else {
  1800. tdm_rx_cfg[port.mode][port.channel].channels =
  1801. ucontrol->value.enumerated.item[0] + 1;
  1802. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1803. tdm_rx_cfg[port.mode][port.channel].channels,
  1804. ucontrol->value.enumerated.item[0] + 1);
  1805. }
  1806. return ret;
  1807. }
  1808. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1809. struct snd_ctl_elem_value *ucontrol)
  1810. {
  1811. struct tdm_port port;
  1812. int ret = tdm_get_port_idx(kcontrol, &port);
  1813. if (ret) {
  1814. pr_err("%s: unsupported control: %s\n",
  1815. __func__, kcontrol->id.name);
  1816. } else {
  1817. ucontrol->value.enumerated.item[0] =
  1818. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1819. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1820. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1821. ucontrol->value.enumerated.item[0]);
  1822. }
  1823. return ret;
  1824. }
  1825. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1826. struct snd_ctl_elem_value *ucontrol)
  1827. {
  1828. struct tdm_port port;
  1829. int ret = tdm_get_port_idx(kcontrol, &port);
  1830. if (ret) {
  1831. pr_err("%s: unsupported control: %s\n",
  1832. __func__, kcontrol->id.name);
  1833. } else {
  1834. tdm_tx_cfg[port.mode][port.channel].channels =
  1835. ucontrol->value.enumerated.item[0] + 1;
  1836. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1837. tdm_tx_cfg[port.mode][port.channel].channels,
  1838. ucontrol->value.enumerated.item[0] + 1);
  1839. }
  1840. return ret;
  1841. }
  1842. static int tdm_slot_map_put(struct snd_kcontrol *kcontrol,
  1843. struct snd_ctl_elem_value *ucontrol)
  1844. {
  1845. int slot_index = 0;
  1846. int interface = ucontrol->value.integer.value[0];
  1847. int channel = ucontrol->value.integer.value[1];
  1848. unsigned int offset_val = 0;
  1849. unsigned int *slot_offset = NULL;
  1850. struct tdm_dev_config *config = NULL;
  1851. unsigned int max_slot_offset = 0;
  1852. struct msm_asoc_mach_data *pdata = NULL;
  1853. struct snd_soc_component *component = NULL;
  1854. if (interface < 0 || interface >= (TDM_INTERFACE_MAX * MAX_PATH)) {
  1855. pr_err("%s: incorrect interface = %d\n", __func__, interface);
  1856. return -EINVAL;
  1857. }
  1858. if (channel < 0 || channel >= TDM_PORT_MAX) {
  1859. pr_err("%s: incorrect channel = %d\n", __func__, channel);
  1860. return -EINVAL;
  1861. }
  1862. pr_debug("%s: interface = %d, channel = %d\n", __func__,
  1863. interface, channel);
  1864. component = snd_soc_kcontrol_component(kcontrol);
  1865. pdata = snd_soc_card_get_drvdata(component->card);
  1866. config = ((struct tdm_dev_config *) tdm_cfg[interface / MAX_PATH]) +
  1867. ((interface % MAX_PATH) * TDM_PORT_MAX) + channel;
  1868. if (!config) {
  1869. pr_err("%s: tdm config is NULL\n", __func__);
  1870. return -EINVAL;
  1871. }
  1872. slot_offset = config->tdm_slot_offset;
  1873. if (!slot_offset) {
  1874. pr_err("%s: slot offset is NULL\n", __func__);
  1875. return -EINVAL;
  1876. }
  1877. max_slot_offset = TDM_SLOT_WIDTH_BYTES * (pdata->tdm_max_slots - 1);
  1878. for (slot_index = 0; slot_index < pdata->tdm_max_slots; slot_index++) {
  1879. offset_val = ucontrol->value.integer.value[MAX_PATH +
  1880. slot_index];
  1881. /* Offset value can only be 0, 4, 8, .. */
  1882. if (offset_val % 4 == 0 && offset_val <= max_slot_offset)
  1883. slot_offset[slot_index] = offset_val;
  1884. pr_debug("%s: slot offset[%d] = %d\n", __func__,
  1885. slot_index, slot_offset[slot_index]);
  1886. }
  1887. return 0;
  1888. }
  1889. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1890. {
  1891. int idx = 0;
  1892. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1893. sizeof("PRIM_AUX_PCM"))) {
  1894. idx = PRIM_AUX_PCM;
  1895. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1896. sizeof("SEC_AUX_PCM"))) {
  1897. idx = SEC_AUX_PCM;
  1898. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1899. sizeof("TERT_AUX_PCM"))) {
  1900. idx = TERT_AUX_PCM;
  1901. } else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  1902. sizeof("QUAT_AUX_PCM"))) {
  1903. idx = QUAT_AUX_PCM;
  1904. } else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  1905. sizeof("QUIN_AUX_PCM"))) {
  1906. idx = QUIN_AUX_PCM;
  1907. } else if (strnstr(kcontrol->id.name, "SEN_AUX_PCM",
  1908. sizeof("SEN_AUX_PCM"))) {
  1909. idx = SEN_AUX_PCM;
  1910. } else {
  1911. pr_err("%s: unsupported port: %s\n",
  1912. __func__, kcontrol->id.name);
  1913. idx = -EINVAL;
  1914. }
  1915. return idx;
  1916. }
  1917. static int aux_pcm_get_sample_rate(int value)
  1918. {
  1919. int sample_rate = 0;
  1920. switch (value) {
  1921. case 1:
  1922. sample_rate = SAMPLING_RATE_16KHZ;
  1923. break;
  1924. case 0:
  1925. default:
  1926. sample_rate = SAMPLING_RATE_8KHZ;
  1927. break;
  1928. }
  1929. return sample_rate;
  1930. }
  1931. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1932. {
  1933. int sample_rate_val = 0;
  1934. switch (sample_rate) {
  1935. case SAMPLING_RATE_16KHZ:
  1936. sample_rate_val = 1;
  1937. break;
  1938. case SAMPLING_RATE_8KHZ:
  1939. default:
  1940. sample_rate_val = 0;
  1941. break;
  1942. }
  1943. return sample_rate_val;
  1944. }
  1945. static int mi2s_auxpcm_get_format(int value)
  1946. {
  1947. int format = 0;
  1948. switch (value) {
  1949. case 0:
  1950. format = SNDRV_PCM_FORMAT_S16_LE;
  1951. break;
  1952. case 1:
  1953. format = SNDRV_PCM_FORMAT_S24_LE;
  1954. break;
  1955. case 2:
  1956. format = SNDRV_PCM_FORMAT_S24_3LE;
  1957. break;
  1958. case 3:
  1959. format = SNDRV_PCM_FORMAT_S32_LE;
  1960. break;
  1961. default:
  1962. format = SNDRV_PCM_FORMAT_S16_LE;
  1963. break;
  1964. }
  1965. return format;
  1966. }
  1967. static int mi2s_auxpcm_get_format_value(int format)
  1968. {
  1969. int value = 0;
  1970. switch (format) {
  1971. case SNDRV_PCM_FORMAT_S16_LE:
  1972. value = 0;
  1973. break;
  1974. case SNDRV_PCM_FORMAT_S24_LE:
  1975. value = 1;
  1976. break;
  1977. case SNDRV_PCM_FORMAT_S24_3LE:
  1978. value = 2;
  1979. break;
  1980. case SNDRV_PCM_FORMAT_S32_LE:
  1981. value = 3;
  1982. break;
  1983. default:
  1984. value = 0;
  1985. break;
  1986. }
  1987. return value;
  1988. }
  1989. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1990. struct snd_ctl_elem_value *ucontrol)
  1991. {
  1992. int idx = aux_pcm_get_port_idx(kcontrol);
  1993. if (idx < 0)
  1994. return idx;
  1995. ucontrol->value.enumerated.item[0] =
  1996. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1997. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1998. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1999. ucontrol->value.enumerated.item[0]);
  2000. return 0;
  2001. }
  2002. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2003. struct snd_ctl_elem_value *ucontrol)
  2004. {
  2005. int idx = aux_pcm_get_port_idx(kcontrol);
  2006. if (idx < 0)
  2007. return idx;
  2008. aux_pcm_rx_cfg[idx].sample_rate =
  2009. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2010. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2011. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2012. ucontrol->value.enumerated.item[0]);
  2013. return 0;
  2014. }
  2015. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2016. struct snd_ctl_elem_value *ucontrol)
  2017. {
  2018. int idx = aux_pcm_get_port_idx(kcontrol);
  2019. if (idx < 0)
  2020. return idx;
  2021. ucontrol->value.enumerated.item[0] =
  2022. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  2023. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2024. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2025. ucontrol->value.enumerated.item[0]);
  2026. return 0;
  2027. }
  2028. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2029. struct snd_ctl_elem_value *ucontrol)
  2030. {
  2031. int idx = aux_pcm_get_port_idx(kcontrol);
  2032. if (idx < 0)
  2033. return idx;
  2034. aux_pcm_tx_cfg[idx].sample_rate =
  2035. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2036. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2037. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2038. ucontrol->value.enumerated.item[0]);
  2039. return 0;
  2040. }
  2041. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  2042. struct snd_ctl_elem_value *ucontrol)
  2043. {
  2044. int idx = aux_pcm_get_port_idx(kcontrol);
  2045. if (idx < 0)
  2046. return idx;
  2047. ucontrol->value.enumerated.item[0] =
  2048. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  2049. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2050. idx, aux_pcm_rx_cfg[idx].bit_format,
  2051. ucontrol->value.enumerated.item[0]);
  2052. return 0;
  2053. }
  2054. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  2055. struct snd_ctl_elem_value *ucontrol)
  2056. {
  2057. int idx = aux_pcm_get_port_idx(kcontrol);
  2058. if (idx < 0)
  2059. return idx;
  2060. aux_pcm_rx_cfg[idx].bit_format =
  2061. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2062. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2063. idx, aux_pcm_rx_cfg[idx].bit_format,
  2064. ucontrol->value.enumerated.item[0]);
  2065. return 0;
  2066. }
  2067. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  2068. struct snd_ctl_elem_value *ucontrol)
  2069. {
  2070. int idx = aux_pcm_get_port_idx(kcontrol);
  2071. if (idx < 0)
  2072. return idx;
  2073. ucontrol->value.enumerated.item[0] =
  2074. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  2075. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2076. idx, aux_pcm_tx_cfg[idx].bit_format,
  2077. ucontrol->value.enumerated.item[0]);
  2078. return 0;
  2079. }
  2080. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  2081. struct snd_ctl_elem_value *ucontrol)
  2082. {
  2083. int idx = aux_pcm_get_port_idx(kcontrol);
  2084. if (idx < 0)
  2085. return idx;
  2086. aux_pcm_tx_cfg[idx].bit_format =
  2087. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2088. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2089. idx, aux_pcm_tx_cfg[idx].bit_format,
  2090. ucontrol->value.enumerated.item[0]);
  2091. return 0;
  2092. }
  2093. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2094. {
  2095. int idx = 0;
  2096. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  2097. sizeof("PRIM_MI2S_RX"))) {
  2098. idx = PRIM_MI2S;
  2099. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  2100. sizeof("SEC_MI2S_RX"))) {
  2101. idx = SEC_MI2S;
  2102. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  2103. sizeof("TERT_MI2S_RX"))) {
  2104. idx = TERT_MI2S;
  2105. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  2106. sizeof("QUAT_MI2S_RX"))) {
  2107. idx = QUAT_MI2S;
  2108. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  2109. sizeof("QUIN_MI2S_RX"))) {
  2110. idx = QUIN_MI2S;
  2111. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_RX",
  2112. sizeof("SEN_MI2S_RX"))) {
  2113. idx = SEN_MI2S;
  2114. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  2115. sizeof("PRIM_MI2S_TX"))) {
  2116. idx = PRIM_MI2S;
  2117. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  2118. sizeof("SEC_MI2S_TX"))) {
  2119. idx = SEC_MI2S;
  2120. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  2121. sizeof("TERT_MI2S_TX"))) {
  2122. idx = TERT_MI2S;
  2123. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  2124. sizeof("QUAT_MI2S_TX"))) {
  2125. idx = QUAT_MI2S;
  2126. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  2127. sizeof("QUIN_MI2S_TX"))) {
  2128. idx = QUIN_MI2S;
  2129. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_TX",
  2130. sizeof("SEN_MI2S_TX"))) {
  2131. idx = SEN_MI2S;
  2132. } else {
  2133. pr_err("%s: unsupported channel: %s\n",
  2134. __func__, kcontrol->id.name);
  2135. idx = -EINVAL;
  2136. }
  2137. return idx;
  2138. }
  2139. static int mi2s_get_sample_rate(int value)
  2140. {
  2141. int sample_rate = 0;
  2142. switch (value) {
  2143. case 0:
  2144. sample_rate = SAMPLING_RATE_8KHZ;
  2145. break;
  2146. case 1:
  2147. sample_rate = SAMPLING_RATE_11P025KHZ;
  2148. break;
  2149. case 2:
  2150. sample_rate = SAMPLING_RATE_16KHZ;
  2151. break;
  2152. case 3:
  2153. sample_rate = SAMPLING_RATE_22P05KHZ;
  2154. break;
  2155. case 4:
  2156. sample_rate = SAMPLING_RATE_32KHZ;
  2157. break;
  2158. case 5:
  2159. sample_rate = SAMPLING_RATE_44P1KHZ;
  2160. break;
  2161. case 6:
  2162. sample_rate = SAMPLING_RATE_48KHZ;
  2163. break;
  2164. case 7:
  2165. sample_rate = SAMPLING_RATE_88P2KHZ;
  2166. break;
  2167. case 8:
  2168. sample_rate = SAMPLING_RATE_96KHZ;
  2169. break;
  2170. case 9:
  2171. sample_rate = SAMPLING_RATE_176P4KHZ;
  2172. break;
  2173. case 10:
  2174. sample_rate = SAMPLING_RATE_192KHZ;
  2175. break;
  2176. case 11:
  2177. sample_rate = SAMPLING_RATE_352P8KHZ;
  2178. break;
  2179. case 12:
  2180. sample_rate = SAMPLING_RATE_384KHZ;
  2181. break;
  2182. default:
  2183. sample_rate = SAMPLING_RATE_48KHZ;
  2184. break;
  2185. }
  2186. return sample_rate;
  2187. }
  2188. static int mi2s_get_sample_rate_val(int sample_rate)
  2189. {
  2190. int sample_rate_val = 0;
  2191. switch (sample_rate) {
  2192. case SAMPLING_RATE_8KHZ:
  2193. sample_rate_val = 0;
  2194. break;
  2195. case SAMPLING_RATE_11P025KHZ:
  2196. sample_rate_val = 1;
  2197. break;
  2198. case SAMPLING_RATE_16KHZ:
  2199. sample_rate_val = 2;
  2200. break;
  2201. case SAMPLING_RATE_22P05KHZ:
  2202. sample_rate_val = 3;
  2203. break;
  2204. case SAMPLING_RATE_32KHZ:
  2205. sample_rate_val = 4;
  2206. break;
  2207. case SAMPLING_RATE_44P1KHZ:
  2208. sample_rate_val = 5;
  2209. break;
  2210. case SAMPLING_RATE_48KHZ:
  2211. sample_rate_val = 6;
  2212. break;
  2213. case SAMPLING_RATE_88P2KHZ:
  2214. sample_rate_val = 7;
  2215. break;
  2216. case SAMPLING_RATE_96KHZ:
  2217. sample_rate_val = 8;
  2218. break;
  2219. case SAMPLING_RATE_176P4KHZ:
  2220. sample_rate_val = 9;
  2221. break;
  2222. case SAMPLING_RATE_192KHZ:
  2223. sample_rate_val = 10;
  2224. break;
  2225. case SAMPLING_RATE_352P8KHZ:
  2226. sample_rate_val = 11;
  2227. break;
  2228. case SAMPLING_RATE_384KHZ:
  2229. sample_rate_val = 12;
  2230. break;
  2231. default:
  2232. sample_rate_val = 6;
  2233. break;
  2234. }
  2235. return sample_rate_val;
  2236. }
  2237. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2238. struct snd_ctl_elem_value *ucontrol)
  2239. {
  2240. int idx = mi2s_get_port_idx(kcontrol);
  2241. if (idx < 0)
  2242. return idx;
  2243. ucontrol->value.enumerated.item[0] =
  2244. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  2245. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2246. idx, mi2s_rx_cfg[idx].sample_rate,
  2247. ucontrol->value.enumerated.item[0]);
  2248. return 0;
  2249. }
  2250. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2251. struct snd_ctl_elem_value *ucontrol)
  2252. {
  2253. int idx = mi2s_get_port_idx(kcontrol);
  2254. if (idx < 0)
  2255. return idx;
  2256. mi2s_rx_cfg[idx].sample_rate =
  2257. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2258. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2259. idx, mi2s_rx_cfg[idx].sample_rate,
  2260. ucontrol->value.enumerated.item[0]);
  2261. return 0;
  2262. }
  2263. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2264. struct snd_ctl_elem_value *ucontrol)
  2265. {
  2266. int idx = mi2s_get_port_idx(kcontrol);
  2267. if (idx < 0)
  2268. return idx;
  2269. ucontrol->value.enumerated.item[0] =
  2270. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  2271. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2272. idx, mi2s_tx_cfg[idx].sample_rate,
  2273. ucontrol->value.enumerated.item[0]);
  2274. return 0;
  2275. }
  2276. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2277. struct snd_ctl_elem_value *ucontrol)
  2278. {
  2279. int idx = mi2s_get_port_idx(kcontrol);
  2280. if (idx < 0)
  2281. return idx;
  2282. mi2s_tx_cfg[idx].sample_rate =
  2283. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2284. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2285. idx, mi2s_tx_cfg[idx].sample_rate,
  2286. ucontrol->value.enumerated.item[0]);
  2287. return 0;
  2288. }
  2289. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2290. struct snd_ctl_elem_value *ucontrol)
  2291. {
  2292. int idx = mi2s_get_port_idx(kcontrol);
  2293. if (idx < 0)
  2294. return idx;
  2295. ucontrol->value.enumerated.item[0] =
  2296. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  2297. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2298. idx, mi2s_rx_cfg[idx].bit_format,
  2299. ucontrol->value.enumerated.item[0]);
  2300. return 0;
  2301. }
  2302. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2303. struct snd_ctl_elem_value *ucontrol)
  2304. {
  2305. int idx = mi2s_get_port_idx(kcontrol);
  2306. if (idx < 0)
  2307. return idx;
  2308. mi2s_rx_cfg[idx].bit_format =
  2309. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2310. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2311. idx, mi2s_rx_cfg[idx].bit_format,
  2312. ucontrol->value.enumerated.item[0]);
  2313. return 0;
  2314. }
  2315. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  2316. struct snd_ctl_elem_value *ucontrol)
  2317. {
  2318. int idx = mi2s_get_port_idx(kcontrol);
  2319. if (idx < 0)
  2320. return idx;
  2321. ucontrol->value.enumerated.item[0] =
  2322. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2323. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2324. idx, mi2s_tx_cfg[idx].bit_format,
  2325. ucontrol->value.enumerated.item[0]);
  2326. return 0;
  2327. }
  2328. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2329. struct snd_ctl_elem_value *ucontrol)
  2330. {
  2331. int idx = mi2s_get_port_idx(kcontrol);
  2332. if (idx < 0)
  2333. return idx;
  2334. mi2s_tx_cfg[idx].bit_format =
  2335. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2336. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2337. idx, mi2s_tx_cfg[idx].bit_format,
  2338. ucontrol->value.enumerated.item[0]);
  2339. return 0;
  2340. }
  2341. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2342. struct snd_ctl_elem_value *ucontrol)
  2343. {
  2344. int idx = mi2s_get_port_idx(kcontrol);
  2345. if (idx < 0)
  2346. return idx;
  2347. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2348. idx, mi2s_rx_cfg[idx].channels);
  2349. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2350. return 0;
  2351. }
  2352. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2353. struct snd_ctl_elem_value *ucontrol)
  2354. {
  2355. int idx = mi2s_get_port_idx(kcontrol);
  2356. if (idx < 0)
  2357. return idx;
  2358. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2359. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2360. idx, mi2s_rx_cfg[idx].channels);
  2361. return 1;
  2362. }
  2363. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2364. struct snd_ctl_elem_value *ucontrol)
  2365. {
  2366. int idx = mi2s_get_port_idx(kcontrol);
  2367. if (idx < 0)
  2368. return idx;
  2369. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2370. idx, mi2s_tx_cfg[idx].channels);
  2371. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2372. return 0;
  2373. }
  2374. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2375. struct snd_ctl_elem_value *ucontrol)
  2376. {
  2377. int idx = mi2s_get_port_idx(kcontrol);
  2378. if (idx < 0)
  2379. return idx;
  2380. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2381. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2382. idx, mi2s_tx_cfg[idx].channels);
  2383. return 1;
  2384. }
  2385. static int msm_get_port_id(int be_id)
  2386. {
  2387. int afe_port_id = 0;
  2388. switch (be_id) {
  2389. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  2390. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  2391. break;
  2392. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  2393. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  2394. break;
  2395. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  2396. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  2397. break;
  2398. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  2399. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  2400. break;
  2401. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  2402. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  2403. break;
  2404. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  2405. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  2406. break;
  2407. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  2408. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  2409. break;
  2410. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  2411. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  2412. break;
  2413. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  2414. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  2415. break;
  2416. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  2417. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  2418. break;
  2419. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  2420. afe_port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  2421. break;
  2422. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  2423. afe_port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  2424. break;
  2425. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2426. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_0;
  2427. break;
  2428. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2429. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_1;
  2430. break;
  2431. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2432. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_2;
  2433. break;
  2434. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2435. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0;
  2436. break;
  2437. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2438. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0;
  2439. break;
  2440. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2441. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1;
  2442. break;
  2443. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2444. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1;
  2445. break;
  2446. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2447. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2;
  2448. break;
  2449. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2450. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_0;
  2451. break;
  2452. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2453. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_0;
  2454. break;
  2455. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2456. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_1;
  2457. break;
  2458. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_1:
  2459. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_1;
  2460. break;
  2461. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2462. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_2;
  2463. break;
  2464. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_2:
  2465. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_2;
  2466. break;
  2467. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2468. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_3;
  2469. break;
  2470. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2471. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_3;
  2472. break;
  2473. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  2474. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_4;
  2475. break;
  2476. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2477. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_4;
  2478. break;
  2479. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2480. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_5;
  2481. break;
  2482. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_5:
  2483. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_5;
  2484. break;
  2485. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  2486. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_6;
  2487. break;
  2488. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_7:
  2489. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_7;
  2490. break;
  2491. default:
  2492. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  2493. afe_port_id = -EINVAL;
  2494. }
  2495. return afe_port_id;
  2496. }
  2497. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  2498. {
  2499. u32 bit_per_sample = 0;
  2500. switch (bit_format) {
  2501. case SNDRV_PCM_FORMAT_S32_LE:
  2502. case SNDRV_PCM_FORMAT_S24_3LE:
  2503. case SNDRV_PCM_FORMAT_S24_LE:
  2504. bit_per_sample = 32;
  2505. break;
  2506. case SNDRV_PCM_FORMAT_S16_LE:
  2507. default:
  2508. bit_per_sample = 16;
  2509. break;
  2510. }
  2511. return bit_per_sample;
  2512. }
  2513. static void update_mi2s_clk_val(int dai_id, int stream)
  2514. {
  2515. u32 bit_per_sample = 0;
  2516. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  2517. bit_per_sample =
  2518. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  2519. mi2s_clk[dai_id].clk_freq_in_hz =
  2520. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2521. } else {
  2522. bit_per_sample =
  2523. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  2524. mi2s_clk[dai_id].clk_freq_in_hz =
  2525. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2526. }
  2527. }
  2528. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  2529. {
  2530. int ret = 0;
  2531. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2532. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2533. int port_id = 0;
  2534. int index = cpu_dai->id;
  2535. port_id = msm_get_port_id(rtd->dai_link->id);
  2536. if (port_id < 0) {
  2537. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  2538. ret = port_id;
  2539. goto err;
  2540. }
  2541. if (enable) {
  2542. update_mi2s_clk_val(index, substream->stream);
  2543. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  2544. mi2s_clk[index].clk_freq_in_hz);
  2545. }
  2546. mi2s_clk[index].enable = enable;
  2547. ret = afe_set_lpass_clock_v2(port_id,
  2548. &mi2s_clk[index]);
  2549. if (ret < 0) {
  2550. dev_err(rtd->card->dev,
  2551. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  2552. __func__, port_id, ret);
  2553. goto err;
  2554. }
  2555. err:
  2556. return ret;
  2557. }
  2558. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  2559. {
  2560. int idx = 0;
  2561. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  2562. sizeof("WSA_CDC_DMA_RX_0")))
  2563. idx = WSA_CDC_DMA_RX_0;
  2564. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  2565. sizeof("WSA_CDC_DMA_RX_0")))
  2566. idx = WSA_CDC_DMA_RX_1;
  2567. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  2568. sizeof("RX_CDC_DMA_RX_0")))
  2569. idx = RX_CDC_DMA_RX_0;
  2570. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  2571. sizeof("RX_CDC_DMA_RX_1")))
  2572. idx = RX_CDC_DMA_RX_1;
  2573. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  2574. sizeof("RX_CDC_DMA_RX_2")))
  2575. idx = RX_CDC_DMA_RX_2;
  2576. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  2577. sizeof("RX_CDC_DMA_RX_3")))
  2578. idx = RX_CDC_DMA_RX_3;
  2579. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  2580. sizeof("RX_CDC_DMA_RX_5")))
  2581. idx = RX_CDC_DMA_RX_5;
  2582. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_6",
  2583. sizeof("RX_CDC_DMA_RX_6")))
  2584. idx = RX_CDC_DMA_RX_6;
  2585. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  2586. sizeof("WSA_CDC_DMA_TX_0")))
  2587. idx = WSA_CDC_DMA_TX_0;
  2588. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  2589. sizeof("WSA_CDC_DMA_TX_1")))
  2590. idx = WSA_CDC_DMA_TX_1;
  2591. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  2592. sizeof("WSA_CDC_DMA_TX_2")))
  2593. idx = WSA_CDC_DMA_TX_2;
  2594. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  2595. sizeof("TX_CDC_DMA_TX_0")))
  2596. idx = TX_CDC_DMA_TX_0;
  2597. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  2598. sizeof("TX_CDC_DMA_TX_3")))
  2599. idx = TX_CDC_DMA_TX_3;
  2600. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  2601. sizeof("TX_CDC_DMA_TX_4")))
  2602. idx = TX_CDC_DMA_TX_4;
  2603. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  2604. sizeof("VA_CDC_DMA_TX_0")))
  2605. idx = VA_CDC_DMA_TX_0;
  2606. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  2607. sizeof("VA_CDC_DMA_TX_1")))
  2608. idx = VA_CDC_DMA_TX_1;
  2609. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  2610. sizeof("VA_CDC_DMA_TX_2")))
  2611. idx = VA_CDC_DMA_TX_2;
  2612. else {
  2613. pr_err("%s: unsupported channel: %s\n",
  2614. __func__, kcontrol->id.name);
  2615. return -EINVAL;
  2616. }
  2617. return idx;
  2618. }
  2619. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  2620. struct snd_ctl_elem_value *ucontrol)
  2621. {
  2622. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2623. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2624. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2625. return ch_num;
  2626. }
  2627. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2628. cdc_dma_rx_cfg[ch_num].channels - 1);
  2629. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  2630. return 0;
  2631. }
  2632. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  2633. struct snd_ctl_elem_value *ucontrol)
  2634. {
  2635. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2636. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2637. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2638. return ch_num;
  2639. }
  2640. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2641. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2642. cdc_dma_rx_cfg[ch_num].channels);
  2643. return 1;
  2644. }
  2645. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2646. struct snd_ctl_elem_value *ucontrol)
  2647. {
  2648. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2649. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2650. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2651. return ch_num;
  2652. }
  2653. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2654. case SNDRV_PCM_FORMAT_S32_LE:
  2655. ucontrol->value.integer.value[0] = 3;
  2656. break;
  2657. case SNDRV_PCM_FORMAT_S24_3LE:
  2658. ucontrol->value.integer.value[0] = 2;
  2659. break;
  2660. case SNDRV_PCM_FORMAT_S24_LE:
  2661. ucontrol->value.integer.value[0] = 1;
  2662. break;
  2663. case SNDRV_PCM_FORMAT_S16_LE:
  2664. default:
  2665. ucontrol->value.integer.value[0] = 0;
  2666. break;
  2667. }
  2668. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2669. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2670. ucontrol->value.integer.value[0]);
  2671. return 0;
  2672. }
  2673. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2674. struct snd_ctl_elem_value *ucontrol)
  2675. {
  2676. int rc = 0;
  2677. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2678. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2679. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2680. return ch_num;
  2681. }
  2682. switch (ucontrol->value.integer.value[0]) {
  2683. case 3:
  2684. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2685. break;
  2686. case 2:
  2687. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2688. break;
  2689. case 1:
  2690. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2691. break;
  2692. case 0:
  2693. default:
  2694. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2695. break;
  2696. }
  2697. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2698. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2699. ucontrol->value.integer.value[0]);
  2700. return rc;
  2701. }
  2702. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2703. {
  2704. int sample_rate_val = 0;
  2705. switch (sample_rate) {
  2706. case SAMPLING_RATE_8KHZ:
  2707. sample_rate_val = 0;
  2708. break;
  2709. case SAMPLING_RATE_11P025KHZ:
  2710. sample_rate_val = 1;
  2711. break;
  2712. case SAMPLING_RATE_16KHZ:
  2713. sample_rate_val = 2;
  2714. break;
  2715. case SAMPLING_RATE_22P05KHZ:
  2716. sample_rate_val = 3;
  2717. break;
  2718. case SAMPLING_RATE_32KHZ:
  2719. sample_rate_val = 4;
  2720. break;
  2721. case SAMPLING_RATE_44P1KHZ:
  2722. sample_rate_val = 5;
  2723. break;
  2724. case SAMPLING_RATE_48KHZ:
  2725. sample_rate_val = 6;
  2726. break;
  2727. case SAMPLING_RATE_88P2KHZ:
  2728. sample_rate_val = 7;
  2729. break;
  2730. case SAMPLING_RATE_96KHZ:
  2731. sample_rate_val = 8;
  2732. break;
  2733. case SAMPLING_RATE_176P4KHZ:
  2734. sample_rate_val = 9;
  2735. break;
  2736. case SAMPLING_RATE_192KHZ:
  2737. sample_rate_val = 10;
  2738. break;
  2739. case SAMPLING_RATE_352P8KHZ:
  2740. sample_rate_val = 11;
  2741. break;
  2742. case SAMPLING_RATE_384KHZ:
  2743. sample_rate_val = 12;
  2744. break;
  2745. default:
  2746. sample_rate_val = 6;
  2747. break;
  2748. }
  2749. return sample_rate_val;
  2750. }
  2751. static int cdc_dma_get_sample_rate(int value)
  2752. {
  2753. int sample_rate = 0;
  2754. switch (value) {
  2755. case 0:
  2756. sample_rate = SAMPLING_RATE_8KHZ;
  2757. break;
  2758. case 1:
  2759. sample_rate = SAMPLING_RATE_11P025KHZ;
  2760. break;
  2761. case 2:
  2762. sample_rate = SAMPLING_RATE_16KHZ;
  2763. break;
  2764. case 3:
  2765. sample_rate = SAMPLING_RATE_22P05KHZ;
  2766. break;
  2767. case 4:
  2768. sample_rate = SAMPLING_RATE_32KHZ;
  2769. break;
  2770. case 5:
  2771. sample_rate = SAMPLING_RATE_44P1KHZ;
  2772. break;
  2773. case 6:
  2774. sample_rate = SAMPLING_RATE_48KHZ;
  2775. break;
  2776. case 7:
  2777. sample_rate = SAMPLING_RATE_88P2KHZ;
  2778. break;
  2779. case 8:
  2780. sample_rate = SAMPLING_RATE_96KHZ;
  2781. break;
  2782. case 9:
  2783. sample_rate = SAMPLING_RATE_176P4KHZ;
  2784. break;
  2785. case 10:
  2786. sample_rate = SAMPLING_RATE_192KHZ;
  2787. break;
  2788. case 11:
  2789. sample_rate = SAMPLING_RATE_352P8KHZ;
  2790. break;
  2791. case 12:
  2792. sample_rate = SAMPLING_RATE_384KHZ;
  2793. break;
  2794. default:
  2795. sample_rate = SAMPLING_RATE_48KHZ;
  2796. break;
  2797. }
  2798. return sample_rate;
  2799. }
  2800. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2801. struct snd_ctl_elem_value *ucontrol)
  2802. {
  2803. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2804. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2805. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2806. return ch_num;
  2807. }
  2808. ucontrol->value.enumerated.item[0] =
  2809. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2810. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2811. cdc_dma_rx_cfg[ch_num].sample_rate);
  2812. return 0;
  2813. }
  2814. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2815. struct snd_ctl_elem_value *ucontrol)
  2816. {
  2817. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2818. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2819. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2820. return ch_num;
  2821. }
  2822. cdc_dma_rx_cfg[ch_num].sample_rate =
  2823. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2824. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2825. __func__, ucontrol->value.enumerated.item[0],
  2826. cdc_dma_rx_cfg[ch_num].sample_rate);
  2827. return 0;
  2828. }
  2829. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2830. struct snd_ctl_elem_value *ucontrol)
  2831. {
  2832. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2833. if (ch_num < 0) {
  2834. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2835. return ch_num;
  2836. }
  2837. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2838. cdc_dma_tx_cfg[ch_num].channels);
  2839. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2840. return 0;
  2841. }
  2842. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2843. struct snd_ctl_elem_value *ucontrol)
  2844. {
  2845. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2846. if (ch_num < 0) {
  2847. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2848. return ch_num;
  2849. }
  2850. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2851. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2852. cdc_dma_tx_cfg[ch_num].channels);
  2853. return 1;
  2854. }
  2855. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2856. struct snd_ctl_elem_value *ucontrol)
  2857. {
  2858. int sample_rate_val;
  2859. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2860. if (ch_num < 0) {
  2861. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2862. return ch_num;
  2863. }
  2864. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2865. case SAMPLING_RATE_384KHZ:
  2866. sample_rate_val = 12;
  2867. break;
  2868. case SAMPLING_RATE_352P8KHZ:
  2869. sample_rate_val = 11;
  2870. break;
  2871. case SAMPLING_RATE_192KHZ:
  2872. sample_rate_val = 10;
  2873. break;
  2874. case SAMPLING_RATE_176P4KHZ:
  2875. sample_rate_val = 9;
  2876. break;
  2877. case SAMPLING_RATE_96KHZ:
  2878. sample_rate_val = 8;
  2879. break;
  2880. case SAMPLING_RATE_88P2KHZ:
  2881. sample_rate_val = 7;
  2882. break;
  2883. case SAMPLING_RATE_48KHZ:
  2884. sample_rate_val = 6;
  2885. break;
  2886. case SAMPLING_RATE_44P1KHZ:
  2887. sample_rate_val = 5;
  2888. break;
  2889. case SAMPLING_RATE_32KHZ:
  2890. sample_rate_val = 4;
  2891. break;
  2892. case SAMPLING_RATE_22P05KHZ:
  2893. sample_rate_val = 3;
  2894. break;
  2895. case SAMPLING_RATE_16KHZ:
  2896. sample_rate_val = 2;
  2897. break;
  2898. case SAMPLING_RATE_11P025KHZ:
  2899. sample_rate_val = 1;
  2900. break;
  2901. case SAMPLING_RATE_8KHZ:
  2902. sample_rate_val = 0;
  2903. break;
  2904. default:
  2905. sample_rate_val = 6;
  2906. break;
  2907. }
  2908. ucontrol->value.integer.value[0] = sample_rate_val;
  2909. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2910. cdc_dma_tx_cfg[ch_num].sample_rate);
  2911. return 0;
  2912. }
  2913. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2914. struct snd_ctl_elem_value *ucontrol)
  2915. {
  2916. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2917. if (ch_num < 0) {
  2918. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2919. return ch_num;
  2920. }
  2921. switch (ucontrol->value.integer.value[0]) {
  2922. case 12:
  2923. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2924. break;
  2925. case 11:
  2926. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2927. break;
  2928. case 10:
  2929. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2930. break;
  2931. case 9:
  2932. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2933. break;
  2934. case 8:
  2935. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2936. break;
  2937. case 7:
  2938. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2939. break;
  2940. case 6:
  2941. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2942. break;
  2943. case 5:
  2944. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2945. break;
  2946. case 4:
  2947. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2948. break;
  2949. case 3:
  2950. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2951. break;
  2952. case 2:
  2953. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2954. break;
  2955. case 1:
  2956. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2957. break;
  2958. case 0:
  2959. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2960. break;
  2961. default:
  2962. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2963. break;
  2964. }
  2965. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2966. __func__, ucontrol->value.integer.value[0],
  2967. cdc_dma_tx_cfg[ch_num].sample_rate);
  2968. return 0;
  2969. }
  2970. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2971. struct snd_ctl_elem_value *ucontrol)
  2972. {
  2973. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2974. if (ch_num < 0) {
  2975. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2976. return ch_num;
  2977. }
  2978. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2979. case SNDRV_PCM_FORMAT_S32_LE:
  2980. ucontrol->value.integer.value[0] = 3;
  2981. break;
  2982. case SNDRV_PCM_FORMAT_S24_3LE:
  2983. ucontrol->value.integer.value[0] = 2;
  2984. break;
  2985. case SNDRV_PCM_FORMAT_S24_LE:
  2986. ucontrol->value.integer.value[0] = 1;
  2987. break;
  2988. case SNDRV_PCM_FORMAT_S16_LE:
  2989. default:
  2990. ucontrol->value.integer.value[0] = 0;
  2991. break;
  2992. }
  2993. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2994. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2995. ucontrol->value.integer.value[0]);
  2996. return 0;
  2997. }
  2998. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2999. struct snd_ctl_elem_value *ucontrol)
  3000. {
  3001. int rc = 0;
  3002. int ch_num = cdc_dma_get_port_idx(kcontrol);
  3003. if (ch_num < 0) {
  3004. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  3005. return ch_num;
  3006. }
  3007. switch (ucontrol->value.integer.value[0]) {
  3008. case 3:
  3009. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  3010. break;
  3011. case 2:
  3012. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  3013. break;
  3014. case 1:
  3015. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  3016. break;
  3017. case 0:
  3018. default:
  3019. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  3020. break;
  3021. }
  3022. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  3023. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  3024. ucontrol->value.integer.value[0]);
  3025. return rc;
  3026. }
  3027. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  3028. {
  3029. int idx = 0;
  3030. switch (be_id) {
  3031. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3032. idx = WSA_CDC_DMA_RX_0;
  3033. break;
  3034. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3035. idx = WSA_CDC_DMA_TX_0;
  3036. break;
  3037. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3038. idx = WSA_CDC_DMA_RX_1;
  3039. break;
  3040. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3041. idx = WSA_CDC_DMA_TX_1;
  3042. break;
  3043. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3044. idx = WSA_CDC_DMA_TX_2;
  3045. break;
  3046. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3047. idx = RX_CDC_DMA_RX_0;
  3048. break;
  3049. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3050. idx = RX_CDC_DMA_RX_1;
  3051. break;
  3052. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3053. idx = RX_CDC_DMA_RX_2;
  3054. break;
  3055. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3056. idx = RX_CDC_DMA_RX_3;
  3057. break;
  3058. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  3059. idx = RX_CDC_DMA_RX_5;
  3060. break;
  3061. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  3062. idx = RX_CDC_DMA_RX_6;
  3063. break;
  3064. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3065. idx = TX_CDC_DMA_TX_0;
  3066. break;
  3067. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3068. idx = TX_CDC_DMA_TX_3;
  3069. break;
  3070. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3071. idx = TX_CDC_DMA_TX_4;
  3072. break;
  3073. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3074. idx = VA_CDC_DMA_TX_0;
  3075. break;
  3076. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3077. idx = VA_CDC_DMA_TX_1;
  3078. break;
  3079. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3080. idx = VA_CDC_DMA_TX_2;
  3081. break;
  3082. default:
  3083. idx = RX_CDC_DMA_RX_0;
  3084. break;
  3085. }
  3086. return idx;
  3087. }
  3088. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  3089. struct snd_ctl_elem_value *ucontrol)
  3090. {
  3091. /*
  3092. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  3093. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  3094. * value.
  3095. */
  3096. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  3097. case SAMPLING_RATE_96KHZ:
  3098. ucontrol->value.integer.value[0] = 5;
  3099. break;
  3100. case SAMPLING_RATE_88P2KHZ:
  3101. ucontrol->value.integer.value[0] = 4;
  3102. break;
  3103. case SAMPLING_RATE_48KHZ:
  3104. ucontrol->value.integer.value[0] = 3;
  3105. break;
  3106. case SAMPLING_RATE_44P1KHZ:
  3107. ucontrol->value.integer.value[0] = 2;
  3108. break;
  3109. case SAMPLING_RATE_16KHZ:
  3110. ucontrol->value.integer.value[0] = 1;
  3111. break;
  3112. case SAMPLING_RATE_8KHZ:
  3113. default:
  3114. ucontrol->value.integer.value[0] = 0;
  3115. break;
  3116. }
  3117. pr_debug("%s: sample rate = %d\n", __func__,
  3118. slim_rx_cfg[SLIM_RX_7].sample_rate);
  3119. return 0;
  3120. }
  3121. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  3122. struct snd_ctl_elem_value *ucontrol)
  3123. {
  3124. switch (ucontrol->value.integer.value[0]) {
  3125. case 1:
  3126. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3127. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3128. break;
  3129. case 2:
  3130. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3131. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3132. break;
  3133. case 3:
  3134. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3135. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3136. break;
  3137. case 4:
  3138. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3139. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3140. break;
  3141. case 5:
  3142. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3143. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3144. break;
  3145. case 0:
  3146. default:
  3147. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3148. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3149. break;
  3150. }
  3151. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  3152. __func__,
  3153. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3154. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3155. ucontrol->value.enumerated.item[0]);
  3156. return 0;
  3157. }
  3158. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  3159. struct snd_ctl_elem_value *ucontrol)
  3160. {
  3161. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  3162. case SAMPLING_RATE_96KHZ:
  3163. ucontrol->value.integer.value[0] = 5;
  3164. break;
  3165. case SAMPLING_RATE_88P2KHZ:
  3166. ucontrol->value.integer.value[0] = 4;
  3167. break;
  3168. case SAMPLING_RATE_48KHZ:
  3169. ucontrol->value.integer.value[0] = 3;
  3170. break;
  3171. case SAMPLING_RATE_44P1KHZ:
  3172. ucontrol->value.integer.value[0] = 2;
  3173. break;
  3174. case SAMPLING_RATE_16KHZ:
  3175. ucontrol->value.integer.value[0] = 1;
  3176. break;
  3177. case SAMPLING_RATE_8KHZ:
  3178. default:
  3179. ucontrol->value.integer.value[0] = 0;
  3180. break;
  3181. }
  3182. pr_debug("%s: sample rate rx = %d\n", __func__,
  3183. slim_rx_cfg[SLIM_RX_7].sample_rate);
  3184. return 0;
  3185. }
  3186. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  3187. struct snd_ctl_elem_value *ucontrol)
  3188. {
  3189. switch (ucontrol->value.integer.value[0]) {
  3190. case 1:
  3191. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3192. break;
  3193. case 2:
  3194. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3195. break;
  3196. case 3:
  3197. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3198. break;
  3199. case 4:
  3200. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3201. break;
  3202. case 5:
  3203. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3204. break;
  3205. case 0:
  3206. default:
  3207. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3208. break;
  3209. }
  3210. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  3211. __func__,
  3212. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3213. ucontrol->value.enumerated.item[0]);
  3214. return 0;
  3215. }
  3216. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  3217. struct snd_ctl_elem_value *ucontrol)
  3218. {
  3219. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  3220. case SAMPLING_RATE_96KHZ:
  3221. ucontrol->value.integer.value[0] = 5;
  3222. break;
  3223. case SAMPLING_RATE_88P2KHZ:
  3224. ucontrol->value.integer.value[0] = 4;
  3225. break;
  3226. case SAMPLING_RATE_48KHZ:
  3227. ucontrol->value.integer.value[0] = 3;
  3228. break;
  3229. case SAMPLING_RATE_44P1KHZ:
  3230. ucontrol->value.integer.value[0] = 2;
  3231. break;
  3232. case SAMPLING_RATE_16KHZ:
  3233. ucontrol->value.integer.value[0] = 1;
  3234. break;
  3235. case SAMPLING_RATE_8KHZ:
  3236. default:
  3237. ucontrol->value.integer.value[0] = 0;
  3238. break;
  3239. }
  3240. pr_debug("%s: sample rate tx = %d\n", __func__,
  3241. slim_tx_cfg[SLIM_TX_7].sample_rate);
  3242. return 0;
  3243. }
  3244. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  3245. struct snd_ctl_elem_value *ucontrol)
  3246. {
  3247. switch (ucontrol->value.integer.value[0]) {
  3248. case 1:
  3249. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3250. break;
  3251. case 2:
  3252. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3253. break;
  3254. case 3:
  3255. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3256. break;
  3257. case 4:
  3258. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3259. break;
  3260. case 5:
  3261. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3262. break;
  3263. case 0:
  3264. default:
  3265. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3266. break;
  3267. }
  3268. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  3269. __func__,
  3270. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3271. ucontrol->value.enumerated.item[0]);
  3272. return 0;
  3273. }
  3274. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  3275. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  3276. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3277. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  3278. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3279. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  3280. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3281. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  3282. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3283. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  3284. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3285. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  3286. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3287. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  3288. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3289. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Channels", rx_cdc_dma_rx_6_chs,
  3290. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3291. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  3292. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3293. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  3294. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3295. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  3296. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3297. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  3298. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3299. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  3300. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3301. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  3302. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3303. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  3304. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3305. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  3306. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3307. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  3308. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3309. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  3310. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3311. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  3312. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3313. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  3314. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3315. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  3316. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3317. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  3318. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3319. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  3320. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3321. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  3322. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3323. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  3324. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3325. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  3326. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3327. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  3328. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3329. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  3330. wsa_cdc_dma_rx_0_sample_rate,
  3331. cdc_dma_rx_sample_rate_get,
  3332. cdc_dma_rx_sample_rate_put),
  3333. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  3334. wsa_cdc_dma_rx_1_sample_rate,
  3335. cdc_dma_rx_sample_rate_get,
  3336. cdc_dma_rx_sample_rate_put),
  3337. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  3338. wsa_cdc_dma_tx_0_sample_rate,
  3339. cdc_dma_tx_sample_rate_get,
  3340. cdc_dma_tx_sample_rate_put),
  3341. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  3342. wsa_cdc_dma_tx_1_sample_rate,
  3343. cdc_dma_tx_sample_rate_get,
  3344. cdc_dma_tx_sample_rate_put),
  3345. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  3346. wsa_cdc_dma_tx_2_sample_rate,
  3347. cdc_dma_tx_sample_rate_get,
  3348. cdc_dma_tx_sample_rate_put),
  3349. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  3350. tx_cdc_dma_tx_0_sample_rate,
  3351. cdc_dma_tx_sample_rate_get,
  3352. cdc_dma_tx_sample_rate_put),
  3353. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  3354. tx_cdc_dma_tx_3_sample_rate,
  3355. cdc_dma_tx_sample_rate_get,
  3356. cdc_dma_tx_sample_rate_put),
  3357. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  3358. tx_cdc_dma_tx_4_sample_rate,
  3359. cdc_dma_tx_sample_rate_get,
  3360. cdc_dma_tx_sample_rate_put),
  3361. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  3362. va_cdc_dma_tx_0_sample_rate,
  3363. cdc_dma_tx_sample_rate_get,
  3364. cdc_dma_tx_sample_rate_put),
  3365. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  3366. va_cdc_dma_tx_1_sample_rate,
  3367. cdc_dma_tx_sample_rate_get,
  3368. cdc_dma_tx_sample_rate_put),
  3369. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  3370. va_cdc_dma_tx_2_sample_rate,
  3371. cdc_dma_tx_sample_rate_get,
  3372. cdc_dma_tx_sample_rate_put),
  3373. };
  3374. static const struct snd_kcontrol_new msm_int_wcd9380_snd_controls[] = {
  3375. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc80_dma_rx_0_format,
  3376. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3377. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc80_dma_rx_1_format,
  3378. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3379. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc80_dma_rx_2_format,
  3380. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3381. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc80_dma_rx_3_format,
  3382. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3383. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc80_dma_rx_5_format,
  3384. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3385. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Format", rx_cdc80_dma_rx_6_format,
  3386. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3387. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3388. rx_cdc80_dma_rx_0_sample_rate,
  3389. cdc_dma_rx_sample_rate_get,
  3390. cdc_dma_rx_sample_rate_put),
  3391. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3392. rx_cdc80_dma_rx_1_sample_rate,
  3393. cdc_dma_rx_sample_rate_get,
  3394. cdc_dma_rx_sample_rate_put),
  3395. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3396. rx_cdc80_dma_rx_2_sample_rate,
  3397. cdc_dma_rx_sample_rate_get,
  3398. cdc_dma_rx_sample_rate_put),
  3399. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3400. rx_cdc80_dma_rx_3_sample_rate,
  3401. cdc_dma_rx_sample_rate_get,
  3402. cdc_dma_rx_sample_rate_put),
  3403. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3404. rx_cdc80_dma_rx_5_sample_rate,
  3405. cdc_dma_rx_sample_rate_get,
  3406. cdc_dma_rx_sample_rate_put),
  3407. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 SampleRate",
  3408. rx_cdc80_dma_rx_6_sample_rate,
  3409. cdc_dma_rx_sample_rate_get,
  3410. cdc_dma_rx_sample_rate_put),
  3411. };
  3412. static const struct snd_kcontrol_new msm_int_wcd9385_snd_controls[] = {
  3413. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc85_dma_rx_0_format,
  3414. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3415. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc85_dma_rx_1_format,
  3416. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3417. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc85_dma_rx_2_format,
  3418. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3419. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc85_dma_rx_3_format,
  3420. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3421. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc85_dma_rx_5_format,
  3422. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3423. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Format", rx_cdc85_dma_rx_6_format,
  3424. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3425. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3426. rx_cdc85_dma_rx_0_sample_rate,
  3427. cdc_dma_rx_sample_rate_get,
  3428. cdc_dma_rx_sample_rate_put),
  3429. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3430. rx_cdc85_dma_rx_1_sample_rate,
  3431. cdc_dma_rx_sample_rate_get,
  3432. cdc_dma_rx_sample_rate_put),
  3433. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3434. rx_cdc85_dma_rx_2_sample_rate,
  3435. cdc_dma_rx_sample_rate_get,
  3436. cdc_dma_rx_sample_rate_put),
  3437. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3438. rx_cdc85_dma_rx_3_sample_rate,
  3439. cdc_dma_rx_sample_rate_get,
  3440. cdc_dma_rx_sample_rate_put),
  3441. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3442. rx_cdc85_dma_rx_5_sample_rate,
  3443. cdc_dma_rx_sample_rate_get,
  3444. cdc_dma_rx_sample_rate_put),
  3445. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 SampleRate",
  3446. rx_cdc85_dma_rx_6_sample_rate,
  3447. cdc_dma_rx_sample_rate_get,
  3448. cdc_dma_rx_sample_rate_put),
  3449. };
  3450. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  3451. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3452. usb_audio_rx_sample_rate_get,
  3453. usb_audio_rx_sample_rate_put),
  3454. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3455. usb_audio_tx_sample_rate_get,
  3456. usb_audio_tx_sample_rate_put),
  3457. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3458. tdm_rx_sample_rate_get,
  3459. tdm_rx_sample_rate_put),
  3460. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3461. tdm_rx_sample_rate_get,
  3462. tdm_rx_sample_rate_put),
  3463. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3464. tdm_rx_sample_rate_get,
  3465. tdm_rx_sample_rate_put),
  3466. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3467. tdm_rx_sample_rate_get,
  3468. tdm_rx_sample_rate_put),
  3469. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3470. tdm_rx_sample_rate_get,
  3471. tdm_rx_sample_rate_put),
  3472. SOC_ENUM_EXT("SEN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3473. tdm_rx_sample_rate_get,
  3474. tdm_rx_sample_rate_put),
  3475. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3476. tdm_tx_sample_rate_get,
  3477. tdm_tx_sample_rate_put),
  3478. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3479. tdm_tx_sample_rate_get,
  3480. tdm_tx_sample_rate_put),
  3481. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3482. tdm_tx_sample_rate_get,
  3483. tdm_tx_sample_rate_put),
  3484. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3485. tdm_tx_sample_rate_get,
  3486. tdm_tx_sample_rate_put),
  3487. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3488. tdm_tx_sample_rate_get,
  3489. tdm_tx_sample_rate_put),
  3490. SOC_ENUM_EXT("SEN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3491. tdm_tx_sample_rate_get,
  3492. tdm_tx_sample_rate_put),
  3493. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3494. aux_pcm_rx_sample_rate_get,
  3495. aux_pcm_rx_sample_rate_put),
  3496. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3497. aux_pcm_rx_sample_rate_get,
  3498. aux_pcm_rx_sample_rate_put),
  3499. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3500. aux_pcm_rx_sample_rate_get,
  3501. aux_pcm_rx_sample_rate_put),
  3502. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3503. aux_pcm_rx_sample_rate_get,
  3504. aux_pcm_rx_sample_rate_put),
  3505. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3506. aux_pcm_rx_sample_rate_get,
  3507. aux_pcm_rx_sample_rate_put),
  3508. SOC_ENUM_EXT("SEN_AUX_PCM_RX SampleRate", sen_aux_pcm_rx_sample_rate,
  3509. aux_pcm_rx_sample_rate_get,
  3510. aux_pcm_rx_sample_rate_put),
  3511. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3512. aux_pcm_tx_sample_rate_get,
  3513. aux_pcm_tx_sample_rate_put),
  3514. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3515. aux_pcm_tx_sample_rate_get,
  3516. aux_pcm_tx_sample_rate_put),
  3517. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3518. aux_pcm_tx_sample_rate_get,
  3519. aux_pcm_tx_sample_rate_put),
  3520. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3521. aux_pcm_tx_sample_rate_get,
  3522. aux_pcm_tx_sample_rate_put),
  3523. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3524. aux_pcm_tx_sample_rate_get,
  3525. aux_pcm_tx_sample_rate_put),
  3526. SOC_ENUM_EXT("SEN_AUX_PCM_TX SampleRate", sen_aux_pcm_tx_sample_rate,
  3527. aux_pcm_tx_sample_rate_get,
  3528. aux_pcm_tx_sample_rate_put),
  3529. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3530. mi2s_rx_sample_rate_get,
  3531. mi2s_rx_sample_rate_put),
  3532. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3533. mi2s_rx_sample_rate_get,
  3534. mi2s_rx_sample_rate_put),
  3535. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3536. mi2s_rx_sample_rate_get,
  3537. mi2s_rx_sample_rate_put),
  3538. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3539. mi2s_rx_sample_rate_get,
  3540. mi2s_rx_sample_rate_put),
  3541. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3542. mi2s_rx_sample_rate_get,
  3543. mi2s_rx_sample_rate_put),
  3544. SOC_ENUM_EXT("SEN_MI2S_RX SampleRate", sen_mi2s_rx_sample_rate,
  3545. mi2s_rx_sample_rate_get,
  3546. mi2s_rx_sample_rate_put),
  3547. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3548. mi2s_tx_sample_rate_get,
  3549. mi2s_tx_sample_rate_put),
  3550. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3551. mi2s_tx_sample_rate_get,
  3552. mi2s_tx_sample_rate_put),
  3553. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3554. mi2s_tx_sample_rate_get,
  3555. mi2s_tx_sample_rate_put),
  3556. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3557. mi2s_tx_sample_rate_get,
  3558. mi2s_tx_sample_rate_put),
  3559. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3560. mi2s_tx_sample_rate_get,
  3561. mi2s_tx_sample_rate_put),
  3562. SOC_ENUM_EXT("SEN_MI2S_TX SampleRate", sen_mi2s_tx_sample_rate,
  3563. mi2s_tx_sample_rate_get,
  3564. mi2s_tx_sample_rate_put),
  3565. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3566. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3567. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3568. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3569. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3570. tdm_rx_format_get,
  3571. tdm_rx_format_put),
  3572. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3573. tdm_rx_format_get,
  3574. tdm_rx_format_put),
  3575. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3576. tdm_rx_format_get,
  3577. tdm_rx_format_put),
  3578. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3579. tdm_rx_format_get,
  3580. tdm_rx_format_put),
  3581. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3582. tdm_rx_format_get,
  3583. tdm_rx_format_put),
  3584. SOC_ENUM_EXT("SEN_TDM_RX_0 Format", tdm_rx_format,
  3585. tdm_rx_format_get,
  3586. tdm_rx_format_put),
  3587. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3588. tdm_tx_format_get,
  3589. tdm_tx_format_put),
  3590. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3591. tdm_tx_format_get,
  3592. tdm_tx_format_put),
  3593. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3594. tdm_tx_format_get,
  3595. tdm_tx_format_put),
  3596. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3597. tdm_tx_format_get,
  3598. tdm_tx_format_put),
  3599. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3600. tdm_tx_format_get,
  3601. tdm_tx_format_put),
  3602. SOC_ENUM_EXT("SEN_TDM_TX_0 Format", tdm_tx_format,
  3603. tdm_tx_format_get,
  3604. tdm_tx_format_put),
  3605. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3606. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3607. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3608. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3609. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3610. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3611. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3612. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3613. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3614. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3615. SOC_ENUM_EXT("SEN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3616. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3617. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3618. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3619. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3620. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3621. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3622. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3623. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3624. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3625. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3626. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3627. SOC_ENUM_EXT("SEN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3628. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3629. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3630. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3631. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3632. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3633. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3634. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3635. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3636. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3637. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3638. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3639. SOC_ENUM_EXT("SEN_MI2S_RX Format", mi2s_rx_format,
  3640. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3641. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3642. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3643. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3644. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3645. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3646. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3647. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3648. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3649. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3650. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3651. SOC_ENUM_EXT("SEN_MI2S_TX Format", mi2s_tx_format,
  3652. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3653. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3654. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3655. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3656. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3657. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3658. proxy_rx_ch_get, proxy_rx_ch_put),
  3659. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3660. tdm_rx_ch_get,
  3661. tdm_rx_ch_put),
  3662. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3663. tdm_rx_ch_get,
  3664. tdm_rx_ch_put),
  3665. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3666. tdm_rx_ch_get,
  3667. tdm_rx_ch_put),
  3668. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3669. tdm_rx_ch_get,
  3670. tdm_rx_ch_put),
  3671. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3672. tdm_rx_ch_get,
  3673. tdm_rx_ch_put),
  3674. SOC_ENUM_EXT("SEN_TDM_RX_0 Channels", tdm_rx_chs,
  3675. tdm_rx_ch_get,
  3676. tdm_rx_ch_put),
  3677. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3678. tdm_tx_ch_get,
  3679. tdm_tx_ch_put),
  3680. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3681. tdm_tx_ch_get,
  3682. tdm_tx_ch_put),
  3683. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3684. tdm_tx_ch_get,
  3685. tdm_tx_ch_put),
  3686. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3687. tdm_tx_ch_get,
  3688. tdm_tx_ch_put),
  3689. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3690. tdm_tx_ch_get,
  3691. tdm_tx_ch_put),
  3692. SOC_ENUM_EXT("SEN_TDM_TX_0 Channels", tdm_tx_chs,
  3693. tdm_tx_ch_get,
  3694. tdm_tx_ch_put),
  3695. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3696. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3697. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3698. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3699. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3700. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3701. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3702. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3703. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3704. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3705. SOC_ENUM_EXT("SEN_MI2S_RX Channels", sen_mi2s_rx_chs,
  3706. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3707. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3708. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3709. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3710. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3711. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3712. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3713. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3714. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3715. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3716. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3717. SOC_ENUM_EXT("SEN_MI2S_TX Channels", sen_mi2s_tx_chs,
  3718. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3719. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  3720. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3721. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  3722. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3723. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  3724. ext_disp_rx_sample_rate_get,
  3725. ext_disp_rx_sample_rate_put),
  3726. SOC_ENUM_EXT("Display Port1 RX Channels", ext_disp_rx_chs,
  3727. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3728. SOC_ENUM_EXT("Display Port1 RX Bit Format", ext_disp_rx_format,
  3729. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3730. SOC_ENUM_EXT("Display Port1 RX SampleRate", ext_disp_rx_sample_rate,
  3731. ext_disp_rx_sample_rate_get,
  3732. ext_disp_rx_sample_rate_put),
  3733. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3734. msm_bt_sample_rate_get,
  3735. msm_bt_sample_rate_put),
  3736. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  3737. msm_bt_sample_rate_rx_get,
  3738. msm_bt_sample_rate_rx_put),
  3739. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  3740. msm_bt_sample_rate_tx_get,
  3741. msm_bt_sample_rate_tx_put),
  3742. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_loopback_tx_chs,
  3743. afe_loopback_tx_ch_get, afe_loopback_tx_ch_put),
  3744. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3745. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3746. SOC_SINGLE_MULTI_EXT("TDM Slot Map", SND_SOC_NOPM, 0, 255, 0,
  3747. TDM_MAX_SLOTS + MAX_PATH, NULL, tdm_slot_map_put),
  3748. };
  3749. static const struct snd_kcontrol_new msm_snd_controls[] = {
  3750. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3751. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3752. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3753. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3754. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3755. aux_pcm_rx_sample_rate_get,
  3756. aux_pcm_rx_sample_rate_put),
  3757. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3758. aux_pcm_tx_sample_rate_get,
  3759. aux_pcm_tx_sample_rate_put),
  3760. };
  3761. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  3762. {
  3763. int idx;
  3764. switch (be_id) {
  3765. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3766. idx = EXT_DISP_RX_IDX_DP;
  3767. break;
  3768. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3769. idx = EXT_DISP_RX_IDX_DP1;
  3770. break;
  3771. default:
  3772. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  3773. idx = -EINVAL;
  3774. break;
  3775. }
  3776. return idx;
  3777. }
  3778. static int lahaina_send_island_va_config(int32_t be_id)
  3779. {
  3780. int rc = 0;
  3781. int port_id = 0xFFFF;
  3782. port_id = msm_get_port_id(be_id);
  3783. if (port_id < 0) {
  3784. pr_err("%s: Invalid island interface, be_id: %d\n",
  3785. __func__, be_id);
  3786. rc = -EINVAL;
  3787. } else {
  3788. /*
  3789. * send island mode config
  3790. * This should be the first configuration
  3791. */
  3792. rc = afe_send_port_island_mode(port_id);
  3793. if (rc)
  3794. pr_err("%s: afe send island mode failed %d\n",
  3795. __func__, rc);
  3796. }
  3797. return rc;
  3798. }
  3799. static int lahaina_send_power_mode(int32_t be_id)
  3800. {
  3801. int rc = 0;
  3802. int port_id = 0xFFFF;
  3803. port_id = msm_get_port_id(be_id);
  3804. if (port_id < 0) {
  3805. pr_err("%s: Invalid power interface, be_id: %d\n",
  3806. __func__, be_id);
  3807. rc = -EINVAL;
  3808. } else {
  3809. /*
  3810. * send island mode config
  3811. * This should be the first configuration
  3812. *
  3813. */
  3814. rc = afe_send_port_island_mode(port_id);
  3815. if (rc)
  3816. pr_err("%s: afe send island mode failed %d\n",
  3817. __func__, rc);
  3818. /*
  3819. * send power mode config
  3820. * This should be set after island configuration
  3821. */
  3822. rc = afe_send_port_power_mode(port_id);
  3823. if (rc)
  3824. pr_err("%s: afe send power mode failed %d\n",
  3825. __func__, rc);
  3826. }
  3827. return rc;
  3828. }
  3829. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  3830. struct snd_pcm_hw_params *params)
  3831. {
  3832. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3833. struct snd_interval *rate = hw_param_interval(params,
  3834. SNDRV_PCM_HW_PARAM_RATE);
  3835. struct snd_interval *channels = hw_param_interval(params,
  3836. SNDRV_PCM_HW_PARAM_CHANNELS);
  3837. int idx = 0, rc = 0;
  3838. pr_debug("%s: dai_id= %d, format = %d, rate = %d\n",
  3839. __func__, dai_link->id, params_format(params),
  3840. params_rate(params));
  3841. switch (dai_link->id) {
  3842. case MSM_BACKEND_DAI_USB_RX:
  3843. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3844. usb_rx_cfg.bit_format);
  3845. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3846. channels->min = channels->max = usb_rx_cfg.channels;
  3847. break;
  3848. case MSM_BACKEND_DAI_USB_TX:
  3849. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3850. usb_tx_cfg.bit_format);
  3851. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3852. channels->min = channels->max = usb_tx_cfg.channels;
  3853. break;
  3854. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3855. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3856. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3857. if (idx < 0) {
  3858. pr_err("%s: Incorrect ext disp idx %d\n",
  3859. __func__, idx);
  3860. rc = idx;
  3861. goto done;
  3862. }
  3863. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3864. ext_disp_rx_cfg[idx].bit_format);
  3865. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3866. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3867. break;
  3868. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3869. channels->min = channels->max = proxy_rx_cfg.channels;
  3870. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3871. break;
  3872. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3873. channels->min = channels->max =
  3874. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3875. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3876. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3877. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3878. break;
  3879. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3880. channels->min = channels->max =
  3881. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3882. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3883. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3884. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3885. break;
  3886. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3887. channels->min = channels->max =
  3888. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3889. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3890. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3891. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3892. break;
  3893. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3894. channels->min = channels->max =
  3895. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3896. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3897. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3898. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3899. break;
  3900. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3901. channels->min = channels->max =
  3902. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3903. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3904. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3905. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3906. break;
  3907. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3908. channels->min = channels->max =
  3909. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3910. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3911. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3912. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3913. break;
  3914. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  3915. channels->min = channels->max =
  3916. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3917. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3918. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  3919. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3920. break;
  3921. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  3922. channels->min = channels->max =
  3923. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3924. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3925. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  3926. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3927. break;
  3928. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  3929. channels->min = channels->max =
  3930. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3931. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3932. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  3933. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3934. break;
  3935. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  3936. channels->min = channels->max =
  3937. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3938. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3939. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  3940. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3941. break;
  3942. case MSM_BACKEND_DAI_SEN_TDM_RX_0:
  3943. channels->min = channels->max =
  3944. tdm_rx_cfg[TDM_SEN][TDM_0].channels;
  3945. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3946. tdm_rx_cfg[TDM_SEN][TDM_0].bit_format);
  3947. rate->min = rate->max = tdm_rx_cfg[TDM_SEN][TDM_0].sample_rate;
  3948. break;
  3949. case MSM_BACKEND_DAI_SEN_TDM_TX_0:
  3950. channels->min = channels->max =
  3951. tdm_tx_cfg[TDM_SEN][TDM_0].channels;
  3952. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3953. tdm_tx_cfg[TDM_SEN][TDM_0].bit_format);
  3954. rate->min = rate->max = tdm_tx_cfg[TDM_SEN][TDM_0].sample_rate;
  3955. break;
  3956. case MSM_BACKEND_DAI_AUXPCM_RX:
  3957. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3958. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3959. rate->min = rate->max =
  3960. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3961. channels->min = channels->max =
  3962. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3963. break;
  3964. case MSM_BACKEND_DAI_AUXPCM_TX:
  3965. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3966. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3967. rate->min = rate->max =
  3968. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3969. channels->min = channels->max =
  3970. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3971. break;
  3972. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3973. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3974. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3975. rate->min = rate->max =
  3976. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3977. channels->min = channels->max =
  3978. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3979. break;
  3980. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3981. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3982. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3983. rate->min = rate->max =
  3984. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3985. channels->min = channels->max =
  3986. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3987. break;
  3988. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3989. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3990. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3991. rate->min = rate->max =
  3992. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3993. channels->min = channels->max =
  3994. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3995. break;
  3996. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3997. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3998. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3999. rate->min = rate->max =
  4000. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  4001. channels->min = channels->max =
  4002. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  4003. break;
  4004. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  4005. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4006. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  4007. rate->min = rate->max =
  4008. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  4009. channels->min = channels->max =
  4010. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  4011. break;
  4012. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  4013. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4014. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  4015. rate->min = rate->max =
  4016. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  4017. channels->min = channels->max =
  4018. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  4019. break;
  4020. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  4021. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4022. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  4023. rate->min = rate->max =
  4024. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  4025. channels->min = channels->max =
  4026. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  4027. break;
  4028. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  4029. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4030. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  4031. rate->min = rate->max =
  4032. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  4033. channels->min = channels->max =
  4034. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  4035. break;
  4036. case MSM_BACKEND_DAI_SEN_AUXPCM_RX:
  4037. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4038. aux_pcm_rx_cfg[SEN_AUX_PCM].bit_format);
  4039. rate->min = rate->max =
  4040. aux_pcm_rx_cfg[SEN_AUX_PCM].sample_rate;
  4041. channels->min = channels->max =
  4042. aux_pcm_rx_cfg[SEN_AUX_PCM].channels;
  4043. break;
  4044. case MSM_BACKEND_DAI_SEN_AUXPCM_TX:
  4045. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4046. aux_pcm_tx_cfg[SEN_AUX_PCM].bit_format);
  4047. rate->min = rate->max =
  4048. aux_pcm_tx_cfg[SEN_AUX_PCM].sample_rate;
  4049. channels->min = channels->max =
  4050. aux_pcm_tx_cfg[SEN_AUX_PCM].channels;
  4051. break;
  4052. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  4053. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4054. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  4055. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  4056. channels->min = channels->max =
  4057. mi2s_rx_cfg[PRIM_MI2S].channels;
  4058. break;
  4059. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  4060. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4061. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  4062. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  4063. channels->min = channels->max =
  4064. mi2s_tx_cfg[PRIM_MI2S].channels;
  4065. break;
  4066. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  4067. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4068. mi2s_rx_cfg[SEC_MI2S].bit_format);
  4069. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  4070. channels->min = channels->max =
  4071. mi2s_rx_cfg[SEC_MI2S].channels;
  4072. break;
  4073. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  4074. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4075. mi2s_tx_cfg[SEC_MI2S].bit_format);
  4076. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  4077. channels->min = channels->max =
  4078. mi2s_tx_cfg[SEC_MI2S].channels;
  4079. break;
  4080. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  4081. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4082. mi2s_rx_cfg[TERT_MI2S].bit_format);
  4083. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  4084. channels->min = channels->max =
  4085. mi2s_rx_cfg[TERT_MI2S].channels;
  4086. break;
  4087. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  4088. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4089. mi2s_tx_cfg[TERT_MI2S].bit_format);
  4090. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  4091. channels->min = channels->max =
  4092. mi2s_tx_cfg[TERT_MI2S].channels;
  4093. break;
  4094. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  4095. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4096. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  4097. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  4098. channels->min = channels->max =
  4099. mi2s_rx_cfg[QUAT_MI2S].channels;
  4100. break;
  4101. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  4102. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4103. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  4104. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  4105. channels->min = channels->max =
  4106. mi2s_tx_cfg[QUAT_MI2S].channels;
  4107. break;
  4108. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  4109. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4110. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  4111. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  4112. channels->min = channels->max =
  4113. mi2s_rx_cfg[QUIN_MI2S].channels;
  4114. break;
  4115. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  4116. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4117. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  4118. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  4119. channels->min = channels->max =
  4120. mi2s_tx_cfg[QUIN_MI2S].channels;
  4121. break;
  4122. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  4123. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4124. mi2s_rx_cfg[SEN_MI2S].bit_format);
  4125. rate->min = rate->max = mi2s_rx_cfg[SEN_MI2S].sample_rate;
  4126. channels->min = channels->max =
  4127. mi2s_rx_cfg[SEN_MI2S].channels;
  4128. break;
  4129. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  4130. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4131. mi2s_tx_cfg[SEN_MI2S].bit_format);
  4132. rate->min = rate->max = mi2s_tx_cfg[SEN_MI2S].sample_rate;
  4133. channels->min = channels->max =
  4134. mi2s_tx_cfg[SEN_MI2S].channels;
  4135. break;
  4136. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4137. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4138. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4139. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4140. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4141. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4142. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4143. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  4144. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4145. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4146. cdc_dma_rx_cfg[idx].bit_format);
  4147. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  4148. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  4149. break;
  4150. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4151. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4152. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4153. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4154. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4155. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4156. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4157. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4158. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4159. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4160. cdc_dma_tx_cfg[idx].bit_format);
  4161. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4162. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  4163. break;
  4164. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4165. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4166. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4167. SNDRV_PCM_FORMAT_S32_LE);
  4168. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4169. channels->min = channels->max = msm_vi_feed_tx_ch;
  4170. break;
  4171. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  4172. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4173. slim_rx_cfg[SLIM_RX_7].bit_format);
  4174. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  4175. channels->min = channels->max =
  4176. slim_rx_cfg[SLIM_RX_7].channels;
  4177. break;
  4178. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  4179. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4180. slim_tx_cfg[SLIM_TX_7].bit_format);
  4181. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  4182. channels->min = channels->max =
  4183. slim_tx_cfg[SLIM_TX_7].channels;
  4184. break;
  4185. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  4186. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  4187. channels->min = channels->max =
  4188. slim_tx_cfg[SLIM_TX_8].channels;
  4189. break;
  4190. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  4191. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4192. afe_loopback_tx_cfg[idx].bit_format);
  4193. rate->min = rate->max = afe_loopback_tx_cfg[idx].sample_rate;
  4194. channels->min = channels->max =
  4195. afe_loopback_tx_cfg[idx].channels;
  4196. break;
  4197. default:
  4198. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4199. break;
  4200. }
  4201. done:
  4202. return rc;
  4203. }
  4204. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4205. {
  4206. struct snd_soc_card *card = component->card;
  4207. struct msm_asoc_mach_data *pdata =
  4208. snd_soc_card_get_drvdata(card);
  4209. if (!pdata->fsa_handle)
  4210. return false;
  4211. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  4212. }
  4213. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4214. {
  4215. int value = 0;
  4216. bool ret = false;
  4217. struct snd_soc_card *card;
  4218. struct msm_asoc_mach_data *pdata;
  4219. if (!component) {
  4220. pr_err("%s component is NULL\n", __func__);
  4221. return false;
  4222. }
  4223. card = component->card;
  4224. pdata = snd_soc_card_get_drvdata(card);
  4225. if (!pdata)
  4226. return false;
  4227. if (wcd_mbhc_cfg.enable_usbc_analog)
  4228. return msm_usbc_swap_gnd_mic(component, active);
  4229. /* if usbc is not defined, swap using us_euro_gpio_p */
  4230. if (pdata->us_euro_gpio_p) {
  4231. value = msm_cdc_pinctrl_get_state(
  4232. pdata->us_euro_gpio_p);
  4233. if (value)
  4234. msm_cdc_pinctrl_select_sleep_state(
  4235. pdata->us_euro_gpio_p);
  4236. else
  4237. msm_cdc_pinctrl_select_active_state(
  4238. pdata->us_euro_gpio_p);
  4239. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  4240. __func__, value, !value);
  4241. ret = true;
  4242. }
  4243. return ret;
  4244. }
  4245. static int lahaina_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  4246. struct snd_pcm_hw_params *params)
  4247. {
  4248. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4249. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4250. int ret = 0;
  4251. int slot_width = TDM_SLOT_WIDTH_BITS;
  4252. int channels, slots;
  4253. unsigned int slot_mask, rate, clk_freq;
  4254. unsigned int *slot_offset;
  4255. struct tdm_dev_config *config;
  4256. unsigned int path_dir = 0, interface = 0, channel_interface = 0;
  4257. struct msm_asoc_mach_data *pdata = NULL;
  4258. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  4259. pdata = snd_soc_card_get_drvdata(rtd->card);
  4260. slots = pdata->tdm_max_slots;
  4261. if (cpu_dai->id < AFE_PORT_ID_TDM_PORT_RANGE_START) {
  4262. pr_err("%s: dai id 0x%x not supported\n",
  4263. __func__, cpu_dai->id);
  4264. return -EINVAL;
  4265. }
  4266. /* RX or TX */
  4267. path_dir = cpu_dai->id % MAX_PATH;
  4268. /* PRI, SEC, TERT, QUAT, QUIN, ... */
  4269. interface = (cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START)
  4270. / (MAX_PATH * TDM_PORT_MAX);
  4271. /* 0, 1, 2, .. 7 */
  4272. channel_interface =
  4273. ((cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START) / MAX_PATH)
  4274. % TDM_PORT_MAX;
  4275. pr_debug("%s: path dir: %u, interface %u, channel interface %u\n",
  4276. __func__, path_dir, interface, channel_interface);
  4277. config = ((struct tdm_dev_config *) tdm_cfg[interface]) +
  4278. (path_dir * TDM_PORT_MAX) + channel_interface;
  4279. if (!config) {
  4280. pr_err("%s: tdm config is NULL\n", __func__);
  4281. return -EINVAL;
  4282. }
  4283. slot_offset = config->tdm_slot_offset;
  4284. if (!slot_offset) {
  4285. pr_err("%s: slot offset is NULL\n", __func__);
  4286. return -EINVAL;
  4287. }
  4288. if (path_dir)
  4289. channels = tdm_tx_cfg[interface][channel_interface].channels;
  4290. else
  4291. channels = tdm_rx_cfg[interface][channel_interface].channels;
  4292. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4293. /*2 slot config - bits 0 and 1 set for the first two slots */
  4294. slot_mask = 0x0000FFFF >> (16 - slots);
  4295. pr_debug("%s: tdm rx slot_width %d slots %d slot_mask %x\n",
  4296. __func__, slot_width, slots, slot_mask);
  4297. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  4298. slots, slot_width);
  4299. if (ret < 0) {
  4300. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  4301. __func__, ret);
  4302. goto end;
  4303. }
  4304. pr_debug("%s: tdm rx channels: %d\n", __func__, channels);
  4305. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4306. 0, NULL, channels, slot_offset);
  4307. if (ret < 0) {
  4308. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  4309. __func__, ret);
  4310. goto end;
  4311. }
  4312. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4313. /*2 slot config - bits 0 and 1 set for the first two slots */
  4314. slot_mask = 0x0000FFFF >> (16 - slots);
  4315. pr_debug("%s: tdm tx slot_width %d slots %d slot_mask %x\n",
  4316. __func__, slot_width, slots, slot_mask);
  4317. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  4318. slots, slot_width);
  4319. if (ret < 0) {
  4320. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  4321. __func__, ret);
  4322. goto end;
  4323. }
  4324. pr_debug("%s: tdm tx channels: %d\n", __func__, channels);
  4325. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4326. channels, slot_offset, 0, NULL);
  4327. if (ret < 0) {
  4328. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  4329. __func__, ret);
  4330. goto end;
  4331. }
  4332. } else {
  4333. ret = -EINVAL;
  4334. pr_err("%s: invalid use case, err:%d\n",
  4335. __func__, ret);
  4336. goto end;
  4337. }
  4338. rate = params_rate(params);
  4339. clk_freq = rate * slot_width * slots;
  4340. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  4341. if (ret < 0)
  4342. pr_err("%s: failed to set tdm clk, err:%d\n",
  4343. __func__, ret);
  4344. end:
  4345. return ret;
  4346. }
  4347. static int msm_get_tdm_mode(u32 port_id)
  4348. {
  4349. int tdm_mode;
  4350. switch (port_id) {
  4351. case AFE_PORT_ID_PRIMARY_TDM_RX:
  4352. case AFE_PORT_ID_PRIMARY_TDM_TX:
  4353. tdm_mode = TDM_PRI;
  4354. break;
  4355. case AFE_PORT_ID_SECONDARY_TDM_RX:
  4356. case AFE_PORT_ID_SECONDARY_TDM_TX:
  4357. tdm_mode = TDM_SEC;
  4358. break;
  4359. case AFE_PORT_ID_TERTIARY_TDM_RX:
  4360. case AFE_PORT_ID_TERTIARY_TDM_TX:
  4361. tdm_mode = TDM_TERT;
  4362. break;
  4363. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  4364. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  4365. tdm_mode = TDM_QUAT;
  4366. break;
  4367. case AFE_PORT_ID_QUINARY_TDM_RX:
  4368. case AFE_PORT_ID_QUINARY_TDM_TX:
  4369. tdm_mode = TDM_QUIN;
  4370. break;
  4371. case AFE_PORT_ID_SENARY_TDM_RX:
  4372. case AFE_PORT_ID_SENARY_TDM_TX:
  4373. tdm_mode = TDM_SEN;
  4374. break;
  4375. default:
  4376. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  4377. tdm_mode = -EINVAL;
  4378. }
  4379. return tdm_mode;
  4380. }
  4381. static int lahaina_tdm_snd_startup(struct snd_pcm_substream *substream)
  4382. {
  4383. int ret = 0;
  4384. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4385. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4386. struct snd_soc_card *card = rtd->card;
  4387. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4388. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4389. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4390. ret = -EINVAL;
  4391. pr_err("%s: Invalid TDM interface %d\n",
  4392. __func__, ret);
  4393. return ret;
  4394. }
  4395. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4396. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4397. == 0) {
  4398. ret = msm_cdc_pinctrl_select_active_state(
  4399. pdata->mi2s_gpio_p[tdm_mode]);
  4400. if (ret) {
  4401. pr_err("%s: TDM GPIO pinctrl set active failed with %d\n",
  4402. __func__, ret);
  4403. goto done;
  4404. }
  4405. }
  4406. atomic_inc(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4407. }
  4408. done:
  4409. return ret;
  4410. }
  4411. static void lahaina_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  4412. {
  4413. int ret = 0;
  4414. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4415. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4416. struct snd_soc_card *card = rtd->card;
  4417. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4418. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4419. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4420. ret = -EINVAL;
  4421. pr_err("%s: Invalid TDM interface %d\n",
  4422. __func__, ret);
  4423. return;
  4424. }
  4425. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4426. atomic_dec(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4427. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4428. == 0) {
  4429. ret = msm_cdc_pinctrl_select_sleep_state(
  4430. pdata->mi2s_gpio_p[tdm_mode]);
  4431. if (ret)
  4432. pr_err("%s: TDM GPIO pinctrl set sleep failed with %d\n",
  4433. __func__, ret);
  4434. }
  4435. }
  4436. }
  4437. static int lahaina_aux_snd_startup(struct snd_pcm_substream *substream)
  4438. {
  4439. int ret = 0;
  4440. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4441. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4442. struct snd_soc_card *card = rtd->card;
  4443. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4444. u32 aux_mode = cpu_dai->id - 1;
  4445. if (aux_mode >= AUX_PCM_MAX) {
  4446. ret = -EINVAL;
  4447. pr_err("%s: Invalid AUX interface %d\n",
  4448. __func__, ret);
  4449. return ret;
  4450. }
  4451. if (pdata->mi2s_gpio_p[aux_mode]) {
  4452. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4453. == 0) {
  4454. ret = msm_cdc_pinctrl_select_active_state(
  4455. pdata->mi2s_gpio_p[aux_mode]);
  4456. if (ret) {
  4457. pr_err("%s: AUX GPIO pinctrl set active failed with %d\n",
  4458. __func__, ret);
  4459. goto done;
  4460. }
  4461. }
  4462. atomic_inc(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4463. }
  4464. done:
  4465. return ret;
  4466. }
  4467. static void lahaina_aux_snd_shutdown(struct snd_pcm_substream *substream)
  4468. {
  4469. int ret = 0;
  4470. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4471. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4472. struct snd_soc_card *card = rtd->card;
  4473. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4474. u32 aux_mode = cpu_dai->id - 1;
  4475. if (aux_mode >= AUX_PCM_MAX) {
  4476. pr_err("%s: Invalid AUX interface %d\n",
  4477. __func__, ret);
  4478. return;
  4479. }
  4480. if (pdata->mi2s_gpio_p[aux_mode]) {
  4481. atomic_dec(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4482. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4483. == 0) {
  4484. ret = msm_cdc_pinctrl_select_sleep_state(
  4485. pdata->mi2s_gpio_p[aux_mode]);
  4486. if (ret)
  4487. pr_err("%s: AUX GPIO pinctrl set sleep failed with %d\n",
  4488. __func__, ret);
  4489. }
  4490. }
  4491. }
  4492. static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream)
  4493. {
  4494. int ret = 0;
  4495. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4496. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4497. switch (dai_link->id) {
  4498. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4499. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4500. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4501. ret = lahaina_send_island_va_config(dai_link->id);
  4502. if (ret)
  4503. pr_err("%s: send island va cfg failed, err: %d\n",
  4504. __func__, ret);
  4505. break;
  4506. default:
  4507. ret = lahaina_send_power_mode(dai_link->id);
  4508. if (ret)
  4509. pr_err("%s: send power mode failed, err: %d\n",
  4510. __func__, ret);
  4511. break;
  4512. }
  4513. return ret;
  4514. }
  4515. static void set_cps_config(struct snd_soc_pcm_runtime *rtd,
  4516. u32 num_ch, u32 ch_mask)
  4517. {
  4518. int i = 0;
  4519. int val = 0;
  4520. u8 dev_num = 0;
  4521. int ch_configured = 0;
  4522. char wsa_cdc_name[DEV_NAME_STR_LEN];
  4523. struct snd_soc_component *component = NULL;
  4524. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4525. struct msm_asoc_mach_data *pdata =
  4526. snd_soc_card_get_drvdata(rtd->card);
  4527. if (!pdata) {
  4528. pr_err("%s: pdata is NULL\n", __func__);
  4529. return;
  4530. }
  4531. if (!num_ch) {
  4532. pr_err("%s: channel count is 0\n", __func__);
  4533. return;
  4534. }
  4535. if (!pdata->get_wsa_dev_num) {
  4536. pr_err("%s: get_wsa_dev_num is NULL\n", __func__);
  4537. return;
  4538. }
  4539. if (!pdata->cps_config.spkr_dep_cfg) {
  4540. pr_err("%s: spkr_dep_cfg is NULL\n", __func__);
  4541. return;
  4542. }
  4543. if (!pdata->cps_config.hw_reg_cfg.lpass_wr_cmd_reg_phy_addr ||
  4544. !pdata->cps_config.hw_reg_cfg.lpass_rd_cmd_reg_phy_addr ||
  4545. !pdata->cps_config.hw_reg_cfg.lpass_rd_fifo_reg_phy_addr) {
  4546. pr_err("%s: cps static configuration is not set\n", __func__);
  4547. return;
  4548. }
  4549. pdata->cps_config.lpass_hw_intf_cfg_mode = 1;
  4550. while (ch_configured < num_ch) {
  4551. if (!(ch_mask & (1 << i))) {
  4552. i++;
  4553. continue;
  4554. }
  4555. snprintf(wsa_cdc_name, sizeof(wsa_cdc_name), "wsa-codec.%d",
  4556. i+1);
  4557. component = snd_soc_rtdcom_lookup(rtd, wsa_cdc_name);
  4558. if (!component) {
  4559. pr_err("%s: %s component is NULL\n", __func__,
  4560. wsa_cdc_name);
  4561. return;
  4562. }
  4563. dev_num = pdata->get_wsa_dev_num(component);
  4564. if (dev_num < 0 || dev_num > SWR_MAX_SLAVE_DEVICES) {
  4565. pr_err("%s: invalid slave dev num : %d\n", __func__,
  4566. dev_num);
  4567. return;
  4568. }
  4569. /* Clear stale dev num info */
  4570. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr &= 0xFFFF;
  4571. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr &= 0xFFFF;
  4572. val = 0;
  4573. /* bits 20:23 carry swr device number */
  4574. val |= dev_num << 20;
  4575. /* bits 24:27 carry read length in bytes */
  4576. val |= 1 << 24;
  4577. /* Update dev num in packed reg addr */
  4578. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr |= val;
  4579. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr |= val;
  4580. i++;
  4581. ch_configured++;
  4582. }
  4583. afe_set_cps_config(msm_get_port_id(dai_link->id),
  4584. &pdata->cps_config, ch_mask);
  4585. }
  4586. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4587. struct snd_pcm_hw_params *params)
  4588. {
  4589. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4590. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4591. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4592. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4593. int ret = 0;
  4594. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4595. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4596. u32 user_set_tx_ch = 0;
  4597. u32 user_set_rx_ch = 0;
  4598. u32 ch_id;
  4599. ret = snd_soc_dai_get_channel_map(codec_dai,
  4600. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4601. &rx_ch_cdc_dma);
  4602. if (ret < 0) {
  4603. pr_err("%s: failed to get codec chan map, err:%d\n",
  4604. __func__, ret);
  4605. goto err;
  4606. }
  4607. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4608. switch (dai_link->id) {
  4609. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4610. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4611. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4612. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4613. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4614. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4615. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  4616. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4617. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  4618. {
  4619. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4620. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4621. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4622. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4623. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4624. user_set_rx_ch, &rx_ch_cdc_dma);
  4625. if (ret < 0) {
  4626. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4627. __func__, ret);
  4628. goto err;
  4629. }
  4630. if (dai_link->id == MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0 ||
  4631. dai_link->id == MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1) {
  4632. set_cps_config(rtd, user_set_rx_ch,
  4633. rx_ch_cdc_dma);
  4634. }
  4635. }
  4636. break;
  4637. }
  4638. } else {
  4639. switch (dai_link->id) {
  4640. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4641. {
  4642. user_set_tx_ch = msm_vi_feed_tx_ch;
  4643. }
  4644. break;
  4645. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4646. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4647. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4648. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4649. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4650. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4651. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4652. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4653. {
  4654. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4655. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4656. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4657. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4658. }
  4659. break;
  4660. }
  4661. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4662. &tx_ch_cdc_dma, 0, 0);
  4663. if (ret < 0) {
  4664. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4665. __func__, ret);
  4666. goto err;
  4667. }
  4668. }
  4669. err:
  4670. return ret;
  4671. }
  4672. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  4673. {
  4674. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  4675. pm_qos_remove_request(&substream->latency_pm_qos_req);
  4676. qos_client_active_cnt++;
  4677. if (qos_client_active_cnt == 1)
  4678. msm_audio_update_qos_request(MSM_LL_QOS_VALUE);
  4679. return 0;
  4680. }
  4681. static void msm_fe_qos_shutdown(struct snd_pcm_substream *substream)
  4682. {
  4683. (void)substream;
  4684. if (qos_client_active_cnt > 0)
  4685. qos_client_active_cnt--;
  4686. if (qos_client_active_cnt == 0)
  4687. msm_audio_update_qos_request(PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE);
  4688. }
  4689. void mi2s_disable_audio_vote(struct snd_pcm_substream *substream)
  4690. {
  4691. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4692. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4693. int index = cpu_dai->id;
  4694. struct snd_soc_card *card = rtd->card;
  4695. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4696. int sample_rate = 0;
  4697. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4698. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4699. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4700. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4701. } else {
  4702. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4703. return;
  4704. }
  4705. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4706. if (pdata->lpass_audio_hw_vote != NULL) {
  4707. if (--pdata->core_audio_vote_count == 0) {
  4708. clk_disable_unprepare(
  4709. pdata->lpass_audio_hw_vote);
  4710. } else if (pdata->core_audio_vote_count < 0) {
  4711. pr_err("%s: audio vote mismatch\n", __func__);
  4712. pdata->core_audio_vote_count = 0;
  4713. }
  4714. } else {
  4715. pr_err("%s: Invalid lpass audio hw node\n", __func__);
  4716. }
  4717. }
  4718. }
  4719. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  4720. {
  4721. int ret = 0;
  4722. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4723. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4724. int index = cpu_dai->id;
  4725. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  4726. struct snd_soc_card *card = rtd->card;
  4727. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4728. int sample_rate = 0;
  4729. dev_dbg(rtd->card->dev,
  4730. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  4731. __func__, substream->name, substream->stream,
  4732. cpu_dai->name, cpu_dai->id);
  4733. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4734. ret = -EINVAL;
  4735. dev_err(rtd->card->dev,
  4736. "%s: CPU DAI id (%d) out of range\n",
  4737. __func__, cpu_dai->id);
  4738. goto err;
  4739. }
  4740. /*
  4741. * Mutex protection in case the same MI2S
  4742. * interface using for both TX and RX so
  4743. * that the same clock won't be enable twice.
  4744. */
  4745. mutex_lock(&mi2s_intf_conf[index].lock);
  4746. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4747. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4748. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4749. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4750. } else {
  4751. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4752. ret = -EINVAL;
  4753. goto vote_err;
  4754. }
  4755. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4756. if (pdata->lpass_audio_hw_vote == NULL) {
  4757. dev_err(rtd->card->dev, "%s: Invalid lpass audio hw node\n",
  4758. __func__);
  4759. ret = -EINVAL;
  4760. goto vote_err;
  4761. }
  4762. if (pdata->core_audio_vote_count == 0) {
  4763. ret = clk_prepare_enable(pdata->lpass_audio_hw_vote);
  4764. if (ret < 0) {
  4765. dev_err(rtd->card->dev, "%s: audio vote error\n",
  4766. __func__);
  4767. goto vote_err;
  4768. }
  4769. }
  4770. pdata->core_audio_vote_count++;
  4771. }
  4772. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  4773. /* Check if msm needs to provide the clock to the interface */
  4774. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  4775. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  4776. fmt = SND_SOC_DAIFMT_CBM_CFM;
  4777. }
  4778. ret = msm_mi2s_set_sclk(substream, true);
  4779. if (ret < 0) {
  4780. dev_err(rtd->card->dev,
  4781. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  4782. __func__, ret);
  4783. goto clean_up;
  4784. }
  4785. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  4786. if (ret < 0) {
  4787. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  4788. __func__, index, ret);
  4789. goto clk_off;
  4790. }
  4791. if (pdata->mi2s_gpio_p[index]) {
  4792. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4793. == 0) {
  4794. ret = msm_cdc_pinctrl_select_active_state(
  4795. pdata->mi2s_gpio_p[index]);
  4796. if (ret) {
  4797. pr_err("%s: MI2S GPIO pinctrl set active failed with %d\n",
  4798. __func__, ret);
  4799. goto clk_off;
  4800. }
  4801. }
  4802. atomic_inc(&(pdata->mi2s_gpio_ref_count[index]));
  4803. }
  4804. }
  4805. clk_off:
  4806. if (ret < 0)
  4807. msm_mi2s_set_sclk(substream, false);
  4808. clean_up:
  4809. if (ret < 0) {
  4810. mi2s_intf_conf[index].ref_cnt--;
  4811. mi2s_disable_audio_vote(substream);
  4812. }
  4813. vote_err:
  4814. mutex_unlock(&mi2s_intf_conf[index].lock);
  4815. err:
  4816. return ret;
  4817. }
  4818. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  4819. {
  4820. int ret = 0;
  4821. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4822. int index = rtd->cpu_dai->id;
  4823. struct snd_soc_card *card = rtd->card;
  4824. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4825. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  4826. substream->name, substream->stream);
  4827. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4828. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  4829. return;
  4830. }
  4831. mutex_lock(&mi2s_intf_conf[index].lock);
  4832. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  4833. if (pdata->mi2s_gpio_p[index]) {
  4834. atomic_dec(&(pdata->mi2s_gpio_ref_count[index]));
  4835. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4836. == 0) {
  4837. ret = msm_cdc_pinctrl_select_sleep_state(
  4838. pdata->mi2s_gpio_p[index]);
  4839. if (ret)
  4840. pr_err("%s: MI2S GPIO pinctrl set sleep failed with %d\n",
  4841. __func__, ret);
  4842. }
  4843. }
  4844. ret = msm_mi2s_set_sclk(substream, false);
  4845. if (ret < 0)
  4846. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  4847. __func__, index, ret);
  4848. }
  4849. mi2s_disable_audio_vote(substream);
  4850. mutex_unlock(&mi2s_intf_conf[index].lock);
  4851. }
  4852. static int msm_wcn_hw_params_lito(struct snd_pcm_substream *substream,
  4853. struct snd_pcm_hw_params *params)
  4854. {
  4855. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4856. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4857. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4858. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4859. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO];
  4860. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4861. int ret = 0;
  4862. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4863. codec_dai->name, codec_dai->id);
  4864. ret = snd_soc_dai_get_channel_map(codec_dai,
  4865. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4866. if (ret) {
  4867. dev_err(rtd->dev,
  4868. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4869. __func__, ret);
  4870. goto err;
  4871. }
  4872. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4873. __func__, tx_ch_cnt, dai_link->id);
  4874. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4875. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4876. if (ret)
  4877. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4878. __func__, ret);
  4879. err:
  4880. return ret;
  4881. }
  4882. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4883. struct snd_pcm_hw_params *params)
  4884. {
  4885. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4886. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4887. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4888. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4889. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4890. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4891. int ret = 0;
  4892. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4893. codec_dai->name, codec_dai->id);
  4894. ret = snd_soc_dai_get_channel_map(codec_dai,
  4895. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4896. if (ret) {
  4897. dev_err(rtd->dev,
  4898. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4899. __func__, ret);
  4900. goto err;
  4901. }
  4902. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4903. __func__, tx_ch_cnt, dai_link->id);
  4904. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4905. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4906. if (ret)
  4907. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4908. __func__, ret);
  4909. err:
  4910. return ret;
  4911. }
  4912. static struct snd_soc_ops lahaina_aux_be_ops = {
  4913. .startup = lahaina_aux_snd_startup,
  4914. .shutdown = lahaina_aux_snd_shutdown
  4915. };
  4916. static struct snd_soc_ops lahaina_tdm_be_ops = {
  4917. .hw_params = lahaina_tdm_snd_hw_params,
  4918. .startup = lahaina_tdm_snd_startup,
  4919. .shutdown = lahaina_tdm_snd_shutdown
  4920. };
  4921. static struct snd_soc_ops msm_mi2s_be_ops = {
  4922. .startup = msm_mi2s_snd_startup,
  4923. .shutdown = msm_mi2s_snd_shutdown,
  4924. };
  4925. static struct snd_soc_ops msm_fe_qos_ops = {
  4926. .prepare = msm_fe_qos_prepare,
  4927. .shutdown = msm_fe_qos_shutdown,
  4928. };
  4929. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  4930. .startup = msm_snd_cdc_dma_startup,
  4931. .hw_params = msm_snd_cdc_dma_hw_params,
  4932. };
  4933. static struct snd_soc_ops msm_wcn_ops = {
  4934. .hw_params = msm_wcn_hw_params,
  4935. };
  4936. static struct snd_soc_ops msm_wcn_ops_lito = {
  4937. .hw_params = msm_wcn_hw_params_lito,
  4938. };
  4939. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  4940. struct snd_kcontrol *kcontrol, int event)
  4941. {
  4942. struct msm_asoc_mach_data *pdata = NULL;
  4943. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  4944. int ret = 0;
  4945. u32 dmic_idx;
  4946. int *dmic_gpio_cnt;
  4947. struct device_node *dmic_gpio;
  4948. char *wname;
  4949. wname = strpbrk(w->name, "012345");
  4950. if (!wname) {
  4951. dev_err(component->dev, "%s: widget not found\n", __func__);
  4952. return -EINVAL;
  4953. }
  4954. ret = kstrtouint(wname, 10, &dmic_idx);
  4955. if (ret < 0) {
  4956. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  4957. __func__);
  4958. return -EINVAL;
  4959. }
  4960. pdata = snd_soc_card_get_drvdata(component->card);
  4961. switch (dmic_idx) {
  4962. case 0:
  4963. case 1:
  4964. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  4965. dmic_gpio = pdata->dmic01_gpio_p;
  4966. break;
  4967. case 2:
  4968. case 3:
  4969. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  4970. dmic_gpio = pdata->dmic23_gpio_p;
  4971. break;
  4972. case 4:
  4973. case 5:
  4974. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  4975. dmic_gpio = pdata->dmic45_gpio_p;
  4976. break;
  4977. default:
  4978. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  4979. __func__);
  4980. return -EINVAL;
  4981. }
  4982. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  4983. __func__, event, dmic_idx, *dmic_gpio_cnt);
  4984. switch (event) {
  4985. case SND_SOC_DAPM_PRE_PMU:
  4986. (*dmic_gpio_cnt)++;
  4987. if (*dmic_gpio_cnt == 1) {
  4988. ret = msm_cdc_pinctrl_select_active_state(
  4989. dmic_gpio);
  4990. if (ret < 0) {
  4991. pr_err("%s: gpio set cannot be activated %sd",
  4992. __func__, "dmic_gpio");
  4993. return ret;
  4994. }
  4995. }
  4996. break;
  4997. case SND_SOC_DAPM_POST_PMD:
  4998. (*dmic_gpio_cnt)--;
  4999. if (*dmic_gpio_cnt == 0) {
  5000. ret = msm_cdc_pinctrl_select_sleep_state(
  5001. dmic_gpio);
  5002. if (ret < 0) {
  5003. pr_err("%s: gpio set cannot be de-activated %sd",
  5004. __func__, "dmic_gpio");
  5005. return ret;
  5006. }
  5007. }
  5008. break;
  5009. default:
  5010. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  5011. return -EINVAL;
  5012. }
  5013. return 0;
  5014. }
  5015. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  5016. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  5017. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  5018. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  5019. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  5020. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  5021. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  5022. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  5023. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  5024. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  5025. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  5026. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  5027. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  5028. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  5029. };
  5030. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  5031. {
  5032. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  5033. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  5034. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  5035. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  5036. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  5037. }
  5038. static int msm_wcn_init_lito(struct snd_soc_pcm_runtime *rtd)
  5039. {
  5040. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  5041. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO] = {159, 160, 161};
  5042. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  5043. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  5044. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  5045. }
  5046. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  5047. const char *name,
  5048. struct snd_info_entry *parent)
  5049. {
  5050. struct snd_info_entry *entry;
  5051. entry = snd_info_create_module_entry(mod, name, parent);
  5052. if (!entry)
  5053. return NULL;
  5054. entry->mode = S_IFDIR | 0555;
  5055. if (snd_info_register(entry) < 0) {
  5056. snd_info_free_entry(entry);
  5057. return NULL;
  5058. }
  5059. return entry;
  5060. }
  5061. static void *def_wcd_mbhc_cal(void)
  5062. {
  5063. void *wcd_mbhc_cal;
  5064. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  5065. u16 *btn_high;
  5066. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  5067. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  5068. if (!wcd_mbhc_cal)
  5069. return NULL;
  5070. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  5071. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  5072. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  5073. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  5074. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  5075. btn_high[0] = 75;
  5076. btn_high[1] = 150;
  5077. btn_high[2] = 237;
  5078. btn_high[3] = 500;
  5079. btn_high[4] = 500;
  5080. btn_high[5] = 500;
  5081. btn_high[6] = 500;
  5082. btn_high[7] = 500;
  5083. return wcd_mbhc_cal;
  5084. }
  5085. /* Digital audio interface glue - connects codec <---> CPU */
  5086. static struct snd_soc_dai_link msm_common_dai_links[] = {
  5087. /* FrontEnd DAI Links */
  5088. {/* hw:x,0 */
  5089. .name = MSM_DAILINK_NAME(Media1),
  5090. .stream_name = "MultiMedia1",
  5091. .dynamic = 1,
  5092. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5093. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5094. #endif /* CONFIG_AUDIO_QGKI */
  5095. .dpcm_playback = 1,
  5096. .dpcm_capture = 1,
  5097. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5098. SND_SOC_DPCM_TRIGGER_POST},
  5099. .ignore_suspend = 1,
  5100. /* this dainlink has playback support */
  5101. .ignore_pmdown_time = 1,
  5102. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  5103. SND_SOC_DAILINK_REG(multimedia1),
  5104. },
  5105. {/* hw:x,1 */
  5106. .name = MSM_DAILINK_NAME(Media2),
  5107. .stream_name = "MultiMedia2",
  5108. .dynamic = 1,
  5109. .dpcm_playback = 1,
  5110. .dpcm_capture = 1,
  5111. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5112. SND_SOC_DPCM_TRIGGER_POST},
  5113. .ignore_suspend = 1,
  5114. /* this dainlink has playback support */
  5115. .ignore_pmdown_time = 1,
  5116. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  5117. SND_SOC_DAILINK_REG(multimedia2),
  5118. },
  5119. {/* hw:x,2 */
  5120. .name = "VoiceMMode1",
  5121. .stream_name = "VoiceMMode1",
  5122. .dynamic = 1,
  5123. .dpcm_playback = 1,
  5124. .dpcm_capture = 1,
  5125. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5126. SND_SOC_DPCM_TRIGGER_POST},
  5127. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5128. .ignore_suspend = 1,
  5129. .ignore_pmdown_time = 1,
  5130. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  5131. SND_SOC_DAILINK_REG(voicemmode1),
  5132. },
  5133. {/* hw:x,3 */
  5134. .name = "MSM VoIP",
  5135. .stream_name = "VoIP",
  5136. .dynamic = 1,
  5137. .dpcm_playback = 1,
  5138. .dpcm_capture = 1,
  5139. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5140. SND_SOC_DPCM_TRIGGER_POST},
  5141. .ignore_suspend = 1,
  5142. /* this dainlink has playback support */
  5143. .ignore_pmdown_time = 1,
  5144. .id = MSM_FRONTEND_DAI_VOIP,
  5145. SND_SOC_DAILINK_REG(msmvoip),
  5146. },
  5147. {/* hw:x,4 */
  5148. .name = MSM_DAILINK_NAME(ULL),
  5149. .stream_name = "MultiMedia3",
  5150. .dynamic = 1,
  5151. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5152. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5153. #endif /* CONFIG_AUDIO_QGKI */
  5154. .dpcm_playback = 1,
  5155. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5156. SND_SOC_DPCM_TRIGGER_POST},
  5157. .ignore_suspend = 1,
  5158. /* this dainlink has playback support */
  5159. .ignore_pmdown_time = 1,
  5160. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  5161. SND_SOC_DAILINK_REG(multimedia3),
  5162. },
  5163. {/* hw:x,5 */
  5164. .name = "MSM AFE-PCM RX",
  5165. .stream_name = "AFE-PROXY RX",
  5166. .dpcm_playback = 1,
  5167. .ignore_suspend = 1,
  5168. /* this dainlink has playback support */
  5169. .ignore_pmdown_time = 1,
  5170. SND_SOC_DAILINK_REG(afepcm_rx),
  5171. },
  5172. {/* hw:x,6 */
  5173. .name = "MSM AFE-PCM TX",
  5174. .stream_name = "AFE-PROXY TX",
  5175. .dpcm_capture = 1,
  5176. .ignore_suspend = 1,
  5177. SND_SOC_DAILINK_REG(afepcm_tx),
  5178. },
  5179. {/* hw:x,7 */
  5180. .name = MSM_DAILINK_NAME(Compress1),
  5181. .stream_name = "Compress1",
  5182. .dynamic = 1,
  5183. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5184. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  5185. #endif /* CONFIG_AUDIO_QGKI */
  5186. .dpcm_playback = 1,
  5187. .dpcm_capture = 1,
  5188. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5189. SND_SOC_DPCM_TRIGGER_POST},
  5190. .ignore_suspend = 1,
  5191. .ignore_pmdown_time = 1,
  5192. /* this dainlink has playback support */
  5193. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  5194. SND_SOC_DAILINK_REG(multimedia4),
  5195. },
  5196. /* Hostless PCM purpose */
  5197. {/* hw:x,8 */
  5198. .name = "AUXPCM Hostless",
  5199. .stream_name = "AUXPCM Hostless",
  5200. .dynamic = 1,
  5201. .dpcm_playback = 1,
  5202. .dpcm_capture = 1,
  5203. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5204. SND_SOC_DPCM_TRIGGER_POST},
  5205. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5206. .ignore_suspend = 1,
  5207. /* this dainlink has playback support */
  5208. .ignore_pmdown_time = 1,
  5209. SND_SOC_DAILINK_REG(auxpcm_hostless),
  5210. },
  5211. {/* hw:x,9 */
  5212. .name = MSM_DAILINK_NAME(LowLatency),
  5213. .stream_name = "MultiMedia5",
  5214. .dynamic = 1,
  5215. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5216. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5217. #endif /* CONFIG_AUDIO_QGKI */
  5218. .dpcm_playback = 1,
  5219. .dpcm_capture = 1,
  5220. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5221. SND_SOC_DPCM_TRIGGER_POST},
  5222. .ignore_suspend = 1,
  5223. /* this dainlink has playback support */
  5224. .ignore_pmdown_time = 1,
  5225. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  5226. .ops = &msm_fe_qos_ops,
  5227. SND_SOC_DAILINK_REG(multimedia5),
  5228. },
  5229. {/* hw:x,10 */
  5230. .name = "Listen 1 Audio Service",
  5231. .stream_name = "Listen 1 Audio Service",
  5232. .dynamic = 1,
  5233. .dpcm_capture = 1,
  5234. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5235. SND_SOC_DPCM_TRIGGER_POST },
  5236. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5237. .ignore_suspend = 1,
  5238. .id = MSM_FRONTEND_DAI_LSM1,
  5239. SND_SOC_DAILINK_REG(listen1),
  5240. },
  5241. /* Multiple Tunnel instances */
  5242. {/* hw:x,11 */
  5243. .name = MSM_DAILINK_NAME(Compress2),
  5244. .stream_name = "Compress2",
  5245. .dynamic = 1,
  5246. .dpcm_playback = 1,
  5247. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5248. SND_SOC_DPCM_TRIGGER_POST},
  5249. .ignore_suspend = 1,
  5250. .ignore_pmdown_time = 1,
  5251. /* this dainlink has playback support */
  5252. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  5253. SND_SOC_DAILINK_REG(multimedia7),
  5254. },
  5255. {/* hw:x,12 */
  5256. .name = MSM_DAILINK_NAME(MultiMedia10),
  5257. .stream_name = "MultiMedia10",
  5258. .dynamic = 1,
  5259. .dpcm_playback = 1,
  5260. .dpcm_capture = 1,
  5261. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5262. SND_SOC_DPCM_TRIGGER_POST},
  5263. .ignore_suspend = 1,
  5264. .ignore_pmdown_time = 1,
  5265. /* this dainlink has playback support */
  5266. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5267. SND_SOC_DAILINK_REG(multimedia10),
  5268. },
  5269. {/* hw:x,13 */
  5270. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  5271. .stream_name = "MM_NOIRQ",
  5272. .dynamic = 1,
  5273. .dpcm_playback = 1,
  5274. .dpcm_capture = 1,
  5275. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5276. SND_SOC_DPCM_TRIGGER_POST},
  5277. .ignore_suspend = 1,
  5278. .ignore_pmdown_time = 1,
  5279. /* this dainlink has playback support */
  5280. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  5281. .ops = &msm_fe_qos_ops,
  5282. SND_SOC_DAILINK_REG(multimedia8),
  5283. },
  5284. /* HDMI Hostless */
  5285. {/* hw:x,14 */
  5286. .name = "HDMI_RX_HOSTLESS",
  5287. .stream_name = "HDMI_RX_HOSTLESS",
  5288. .dynamic = 1,
  5289. .dpcm_playback = 1,
  5290. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5291. SND_SOC_DPCM_TRIGGER_POST},
  5292. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5293. .ignore_suspend = 1,
  5294. .ignore_pmdown_time = 1,
  5295. SND_SOC_DAILINK_REG(hdmi_rx_hostless),
  5296. },
  5297. {/* hw:x,15 */
  5298. .name = "VoiceMMode2",
  5299. .stream_name = "VoiceMMode2",
  5300. .dynamic = 1,
  5301. .dpcm_playback = 1,
  5302. .dpcm_capture = 1,
  5303. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5304. SND_SOC_DPCM_TRIGGER_POST},
  5305. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5306. .ignore_suspend = 1,
  5307. .ignore_pmdown_time = 1,
  5308. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  5309. SND_SOC_DAILINK_REG(voicemmode2),
  5310. },
  5311. /* LSM FE */
  5312. {/* hw:x,16 */
  5313. .name = "Listen 2 Audio Service",
  5314. .stream_name = "Listen 2 Audio Service",
  5315. .dynamic = 1,
  5316. .dpcm_capture = 1,
  5317. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5318. SND_SOC_DPCM_TRIGGER_POST },
  5319. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5320. .ignore_suspend = 1,
  5321. .id = MSM_FRONTEND_DAI_LSM2,
  5322. SND_SOC_DAILINK_REG(listen2),
  5323. },
  5324. {/* hw:x,17 */
  5325. .name = "Listen 3 Audio Service",
  5326. .stream_name = "Listen 3 Audio Service",
  5327. .dynamic = 1,
  5328. .dpcm_capture = 1,
  5329. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5330. SND_SOC_DPCM_TRIGGER_POST },
  5331. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5332. .ignore_suspend = 1,
  5333. .id = MSM_FRONTEND_DAI_LSM3,
  5334. SND_SOC_DAILINK_REG(listen3),
  5335. },
  5336. {/* hw:x,18 */
  5337. .name = "Listen 4 Audio Service",
  5338. .stream_name = "Listen 4 Audio Service",
  5339. .dynamic = 1,
  5340. .dpcm_capture = 1,
  5341. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5342. SND_SOC_DPCM_TRIGGER_POST },
  5343. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5344. .ignore_suspend = 1,
  5345. .id = MSM_FRONTEND_DAI_LSM4,
  5346. SND_SOC_DAILINK_REG(listen4),
  5347. },
  5348. {/* hw:x,19 */
  5349. .name = "Listen 5 Audio Service",
  5350. .stream_name = "Listen 5 Audio Service",
  5351. .dynamic = 1,
  5352. .dpcm_capture = 1,
  5353. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5354. SND_SOC_DPCM_TRIGGER_POST },
  5355. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5356. .ignore_suspend = 1,
  5357. .id = MSM_FRONTEND_DAI_LSM5,
  5358. SND_SOC_DAILINK_REG(listen5),
  5359. },
  5360. {/* hw:x,20 */
  5361. .name = "Listen 6 Audio Service",
  5362. .stream_name = "Listen 6 Audio Service",
  5363. .dynamic = 1,
  5364. .dpcm_capture = 1,
  5365. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5366. SND_SOC_DPCM_TRIGGER_POST },
  5367. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5368. .ignore_suspend = 1,
  5369. .id = MSM_FRONTEND_DAI_LSM6,
  5370. SND_SOC_DAILINK_REG(listen6),
  5371. },
  5372. {/* hw:x,21 */
  5373. .name = "Listen 7 Audio Service",
  5374. .stream_name = "Listen 7 Audio Service",
  5375. .dynamic = 1,
  5376. .dpcm_capture = 1,
  5377. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5378. SND_SOC_DPCM_TRIGGER_POST },
  5379. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5380. .ignore_suspend = 1,
  5381. .id = MSM_FRONTEND_DAI_LSM7,
  5382. SND_SOC_DAILINK_REG(listen7),
  5383. },
  5384. {/* hw:x,22 */
  5385. .name = "Listen 8 Audio Service",
  5386. .stream_name = "Listen 8 Audio Service",
  5387. .dynamic = 1,
  5388. .dpcm_capture = 1,
  5389. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5390. SND_SOC_DPCM_TRIGGER_POST },
  5391. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5392. .ignore_suspend = 1,
  5393. .id = MSM_FRONTEND_DAI_LSM8,
  5394. SND_SOC_DAILINK_REG(listen8),
  5395. },
  5396. {/* hw:x,23 */
  5397. .name = MSM_DAILINK_NAME(Media9),
  5398. .stream_name = "MultiMedia9",
  5399. .dynamic = 1,
  5400. .dpcm_playback = 1,
  5401. .dpcm_capture = 1,
  5402. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5403. SND_SOC_DPCM_TRIGGER_POST},
  5404. .ignore_suspend = 1,
  5405. /* this dainlink has playback support */
  5406. .ignore_pmdown_time = 1,
  5407. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  5408. SND_SOC_DAILINK_REG(multimedia9),
  5409. },
  5410. {/* hw:x,24 */
  5411. .name = MSM_DAILINK_NAME(Compress4),
  5412. .stream_name = "Compress4",
  5413. .dynamic = 1,
  5414. .dpcm_playback = 1,
  5415. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5416. SND_SOC_DPCM_TRIGGER_POST},
  5417. .ignore_suspend = 1,
  5418. .ignore_pmdown_time = 1,
  5419. /* this dainlink has playback support */
  5420. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  5421. SND_SOC_DAILINK_REG(multimedia11),
  5422. },
  5423. {/* hw:x,25 */
  5424. .name = MSM_DAILINK_NAME(Compress5),
  5425. .stream_name = "Compress5",
  5426. .dynamic = 1,
  5427. .dpcm_playback = 1,
  5428. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5429. SND_SOC_DPCM_TRIGGER_POST},
  5430. .ignore_suspend = 1,
  5431. .ignore_pmdown_time = 1,
  5432. /* this dainlink has playback support */
  5433. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  5434. SND_SOC_DAILINK_REG(multimedia12),
  5435. },
  5436. {/* hw:x,26 */
  5437. .name = MSM_DAILINK_NAME(Compress6),
  5438. .stream_name = "Compress6",
  5439. .dynamic = 1,
  5440. .dpcm_playback = 1,
  5441. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5442. SND_SOC_DPCM_TRIGGER_POST},
  5443. .ignore_suspend = 1,
  5444. .ignore_pmdown_time = 1,
  5445. /* this dainlink has playback support */
  5446. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  5447. SND_SOC_DAILINK_REG(multimedia13),
  5448. },
  5449. {/* hw:x,27 */
  5450. .name = MSM_DAILINK_NAME(Compress7),
  5451. .stream_name = "Compress7",
  5452. .dynamic = 1,
  5453. .dpcm_playback = 1,
  5454. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5455. SND_SOC_DPCM_TRIGGER_POST},
  5456. .ignore_suspend = 1,
  5457. .ignore_pmdown_time = 1,
  5458. /* this dainlink has playback support */
  5459. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  5460. SND_SOC_DAILINK_REG(multimedia14),
  5461. },
  5462. {/* hw:x,28 */
  5463. .name = MSM_DAILINK_NAME(Compress8),
  5464. .stream_name = "Compress8",
  5465. .dynamic = 1,
  5466. .dpcm_playback = 1,
  5467. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5468. SND_SOC_DPCM_TRIGGER_POST},
  5469. .ignore_suspend = 1,
  5470. .ignore_pmdown_time = 1,
  5471. /* this dainlink has playback support */
  5472. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  5473. SND_SOC_DAILINK_REG(multimedia15),
  5474. },
  5475. {/* hw:x,29 */
  5476. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  5477. .stream_name = "MM_NOIRQ_2",
  5478. .dynamic = 1,
  5479. .dpcm_playback = 1,
  5480. .dpcm_capture = 1,
  5481. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5482. SND_SOC_DPCM_TRIGGER_POST},
  5483. .ignore_suspend = 1,
  5484. .ignore_pmdown_time = 1,
  5485. /* this dainlink has playback support */
  5486. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  5487. .ops = &msm_fe_qos_ops,
  5488. SND_SOC_DAILINK_REG(multimedia16),
  5489. },
  5490. {/* hw:x,30 */
  5491. .name = "CDC_DMA Hostless",
  5492. .stream_name = "CDC_DMA Hostless",
  5493. .dynamic = 1,
  5494. .dpcm_playback = 1,
  5495. .dpcm_capture = 1,
  5496. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5497. SND_SOC_DPCM_TRIGGER_POST},
  5498. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5499. .ignore_suspend = 1,
  5500. /* this dailink has playback support */
  5501. .ignore_pmdown_time = 1,
  5502. SND_SOC_DAILINK_REG(cdcdma_hostless),
  5503. },
  5504. {/* hw:x,31 */
  5505. .name = "TX3_CDC_DMA Hostless",
  5506. .stream_name = "TX3_CDC_DMA Hostless",
  5507. .dynamic = 1,
  5508. .dpcm_capture = 1,
  5509. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5510. SND_SOC_DPCM_TRIGGER_POST},
  5511. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5512. .ignore_suspend = 1,
  5513. SND_SOC_DAILINK_REG(tx3_cdcdma_hostless),
  5514. },
  5515. {/* hw:x,32 */
  5516. .name = "Tertiary MI2S TX_Hostless",
  5517. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  5518. .dynamic = 1,
  5519. .dpcm_capture = 1,
  5520. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5521. SND_SOC_DPCM_TRIGGER_POST},
  5522. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5523. .ignore_suspend = 1,
  5524. .ignore_pmdown_time = 1,
  5525. SND_SOC_DAILINK_REG(tert_mi2s_tx_hostless),
  5526. },
  5527. };
  5528. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  5529. {/* hw:x,33 */
  5530. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5531. .stream_name = "WSA CDC DMA0 Capture",
  5532. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5533. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5534. .ignore_suspend = 1,
  5535. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5536. .ops = &msm_cdc_dma_be_ops,
  5537. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture),
  5538. },
  5539. };
  5540. static struct snd_soc_dai_link msm_bolero_fe_stub_dai_links[] = {
  5541. {/* hw:x,33 */
  5542. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5543. .stream_name = "WSA CDC DMA0 Capture",
  5544. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5545. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5546. .ignore_suspend = 1,
  5547. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5548. .ops = &msm_cdc_dma_be_ops,
  5549. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture_stub),
  5550. },
  5551. };
  5552. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  5553. {/* hw:x,34 */
  5554. .name = MSM_DAILINK_NAME(ASM Loopback),
  5555. .stream_name = "MultiMedia6",
  5556. .dynamic = 1,
  5557. .dpcm_playback = 1,
  5558. .dpcm_capture = 1,
  5559. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5560. SND_SOC_DPCM_TRIGGER_POST},
  5561. .ignore_suspend = 1,
  5562. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5563. .ignore_pmdown_time = 1,
  5564. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  5565. SND_SOC_DAILINK_REG(multimedia6),
  5566. },
  5567. {/* hw:x,35 */
  5568. .name = "USB Audio Hostless",
  5569. .stream_name = "USB Audio Hostless",
  5570. .dynamic = 1,
  5571. .dpcm_playback = 1,
  5572. .dpcm_capture = 1,
  5573. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5574. SND_SOC_DPCM_TRIGGER_POST},
  5575. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5576. .ignore_suspend = 1,
  5577. .ignore_pmdown_time = 1,
  5578. SND_SOC_DAILINK_REG(usbaudio_hostless),
  5579. },
  5580. {/* hw:x,36 */
  5581. .name = "SLIMBUS_7 Hostless",
  5582. .stream_name = "SLIMBUS_7 Hostless",
  5583. .dynamic = 1,
  5584. .dpcm_capture = 1,
  5585. .dpcm_playback = 1,
  5586. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5587. SND_SOC_DPCM_TRIGGER_POST},
  5588. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5589. .ignore_suspend = 1,
  5590. .ignore_pmdown_time = 1,
  5591. SND_SOC_DAILINK_REG(slimbus7_hostless),
  5592. },
  5593. {/* hw:x,37 */
  5594. .name = "Compress Capture",
  5595. .stream_name = "Compress9",
  5596. .dynamic = 1,
  5597. .dpcm_capture = 1,
  5598. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5599. SND_SOC_DPCM_TRIGGER_POST},
  5600. .ignore_suspend = 1,
  5601. .ignore_pmdown_time = 1,
  5602. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5603. SND_SOC_DAILINK_REG(multimedia17),
  5604. },
  5605. {/* hw:x,38 */
  5606. .name = "SLIMBUS_8 Hostless",
  5607. .stream_name = "SLIMBUS_8 Hostless",
  5608. .dynamic = 1,
  5609. .dpcm_capture = 1,
  5610. .dpcm_playback = 1,
  5611. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5612. SND_SOC_DPCM_TRIGGER_POST},
  5613. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5614. .ignore_suspend = 1,
  5615. .ignore_pmdown_time = 1,
  5616. SND_SOC_DAILINK_REG(slimbus8_hostless),
  5617. },
  5618. {/* hw:x,39 */
  5619. .name = LPASS_BE_TX_CDC_DMA_TX_5,
  5620. .stream_name = "TX CDC DMA5 Capture",
  5621. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_5,
  5622. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5623. .ignore_suspend = 1,
  5624. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5625. .ops = &msm_cdc_dma_be_ops,
  5626. SND_SOC_DAILINK_REG(tx_cdcdma5_tx),
  5627. },
  5628. {/* hw:x,40 */
  5629. .name = MSM_DAILINK_NAME(Media31),
  5630. .stream_name = "MultiMedia31",
  5631. .dynamic = 1,
  5632. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5633. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5634. #endif /* CONFIG_AUDIO_QGKI */
  5635. .dpcm_playback = 1,
  5636. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5637. SND_SOC_DPCM_TRIGGER_POST},
  5638. .ignore_suspend = 1,
  5639. /* this dainlink has playback support */
  5640. .ignore_pmdown_time = 1,
  5641. .id = MSM_FRONTEND_DAI_MULTIMEDIA31,
  5642. SND_SOC_DAILINK_REG(multimedia31),
  5643. },
  5644. {/* hw:x,41 */
  5645. .name = MSM_DAILINK_NAME(Media32),
  5646. .stream_name = "MultiMedia32",
  5647. .dynamic = 1,
  5648. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5649. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5650. #endif /* CONFIG_AUDIO_QGKI */
  5651. .dpcm_playback = 1,
  5652. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5653. SND_SOC_DPCM_TRIGGER_POST},
  5654. .ignore_suspend = 1,
  5655. /* this dainlink has playback support */
  5656. .ignore_pmdown_time = 1,
  5657. .id = MSM_FRONTEND_DAI_MULTIMEDIA32,
  5658. SND_SOC_DAILINK_REG(multimedia32),
  5659. },
  5660. {/* hw:x,42 */
  5661. .name = "MSM AFE-PCM TX1",
  5662. .stream_name = "AFE-PROXY TX1",
  5663. .dpcm_capture = 1,
  5664. .ignore_suspend = 1,
  5665. SND_SOC_DAILINK_REG(afepcm_tx1),
  5666. },
  5667. {/* hw:x,43 */
  5668. .name = MSM_DAILINK_NAME(Compress3),
  5669. .stream_name = "Compress3",
  5670. .dynamic = 1,
  5671. .dpcm_playback = 1,
  5672. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5673. SND_SOC_DPCM_TRIGGER_POST},
  5674. .ignore_suspend = 1,
  5675. .ignore_pmdown_time = 1,
  5676. /* this dainlink has playback support */
  5677. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5678. SND_SOC_DAILINK_REG(multimedia10),
  5679. },
  5680. };
  5681. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  5682. /* Backend AFE DAI Links */
  5683. {
  5684. .name = LPASS_BE_AFE_PCM_RX,
  5685. .stream_name = "AFE Playback",
  5686. .no_pcm = 1,
  5687. .dpcm_playback = 1,
  5688. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  5689. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5690. /* this dainlink has playback support */
  5691. .ignore_pmdown_time = 1,
  5692. .ignore_suspend = 1,
  5693. SND_SOC_DAILINK_REG(afe_pcm_rx),
  5694. },
  5695. {
  5696. .name = LPASS_BE_AFE_PCM_TX,
  5697. .stream_name = "AFE Capture",
  5698. .no_pcm = 1,
  5699. .dpcm_capture = 1,
  5700. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  5701. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5702. .ignore_suspend = 1,
  5703. SND_SOC_DAILINK_REG(afe_pcm_tx),
  5704. },
  5705. /* Incall Record Uplink BACK END DAI Link */
  5706. {
  5707. .name = LPASS_BE_INCALL_RECORD_TX,
  5708. .stream_name = "Voice Uplink Capture",
  5709. .no_pcm = 1,
  5710. .dpcm_capture = 1,
  5711. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  5712. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5713. .ignore_suspend = 1,
  5714. SND_SOC_DAILINK_REG(incall_record_tx),
  5715. },
  5716. /* Incall Record Downlink BACK END DAI Link */
  5717. {
  5718. .name = LPASS_BE_INCALL_RECORD_RX,
  5719. .stream_name = "Voice Downlink Capture",
  5720. .no_pcm = 1,
  5721. .dpcm_capture = 1,
  5722. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  5723. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5724. .ignore_suspend = 1,
  5725. SND_SOC_DAILINK_REG(incall_record_rx),
  5726. },
  5727. /* Incall Music BACK END DAI Link */
  5728. {
  5729. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  5730. .stream_name = "Voice Farend Playback",
  5731. .no_pcm = 1,
  5732. .dpcm_playback = 1,
  5733. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  5734. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5735. .ignore_suspend = 1,
  5736. .ignore_pmdown_time = 1,
  5737. SND_SOC_DAILINK_REG(voice_playback_tx),
  5738. },
  5739. /* Incall Music 2 BACK END DAI Link */
  5740. {
  5741. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  5742. .stream_name = "Voice2 Farend Playback",
  5743. .no_pcm = 1,
  5744. .dpcm_playback = 1,
  5745. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  5746. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5747. .ignore_suspend = 1,
  5748. .ignore_pmdown_time = 1,
  5749. SND_SOC_DAILINK_REG(voice2_playback_tx),
  5750. },
  5751. /* Proxy Tx BACK END DAI Link */
  5752. {
  5753. .name = LPASS_BE_PROXY_TX,
  5754. .stream_name = "Proxy Capture",
  5755. .no_pcm = 1,
  5756. .dpcm_capture = 1,
  5757. .id = MSM_BACKEND_DAI_PROXY_TX,
  5758. .ignore_suspend = 1,
  5759. SND_SOC_DAILINK_REG(proxy_tx),
  5760. },
  5761. /* Proxy Rx BACK END DAI Link */
  5762. {
  5763. .name = LPASS_BE_PROXY_RX,
  5764. .stream_name = "Proxy Playback",
  5765. .no_pcm = 1,
  5766. .dpcm_playback = 1,
  5767. .id = MSM_BACKEND_DAI_PROXY_RX,
  5768. .ignore_pmdown_time = 1,
  5769. .ignore_suspend = 1,
  5770. SND_SOC_DAILINK_REG(proxy_rx),
  5771. },
  5772. {
  5773. .name = LPASS_BE_USB_AUDIO_RX,
  5774. .stream_name = "USB Audio Playback",
  5775. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5776. .dynamic_be = 1,
  5777. #endif /* CONFIG_AUDIO_QGKI */
  5778. .no_pcm = 1,
  5779. .dpcm_playback = 1,
  5780. .id = MSM_BACKEND_DAI_USB_RX,
  5781. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5782. .ignore_pmdown_time = 1,
  5783. .ignore_suspend = 1,
  5784. SND_SOC_DAILINK_REG(usb_audio_rx),
  5785. },
  5786. {
  5787. .name = LPASS_BE_USB_AUDIO_TX,
  5788. .stream_name = "USB Audio Capture",
  5789. .no_pcm = 1,
  5790. .dpcm_capture = 1,
  5791. .id = MSM_BACKEND_DAI_USB_TX,
  5792. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5793. .ignore_suspend = 1,
  5794. SND_SOC_DAILINK_REG(usb_audio_tx),
  5795. },
  5796. {
  5797. .name = LPASS_BE_PRI_TDM_RX_0,
  5798. .stream_name = "Primary TDM0 Playback",
  5799. .no_pcm = 1,
  5800. .dpcm_playback = 1,
  5801. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  5802. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5803. .ops = &lahaina_tdm_be_ops,
  5804. .ignore_suspend = 1,
  5805. .ignore_pmdown_time = 1,
  5806. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  5807. },
  5808. {
  5809. .name = LPASS_BE_PRI_TDM_TX_0,
  5810. .stream_name = "Primary TDM0 Capture",
  5811. .no_pcm = 1,
  5812. .dpcm_capture = 1,
  5813. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  5814. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5815. .ops = &lahaina_tdm_be_ops,
  5816. .ignore_suspend = 1,
  5817. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  5818. },
  5819. {
  5820. .name = LPASS_BE_SEC_TDM_RX_0,
  5821. .stream_name = "Secondary TDM0 Playback",
  5822. .no_pcm = 1,
  5823. .dpcm_playback = 1,
  5824. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  5825. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5826. .ops = &lahaina_tdm_be_ops,
  5827. .ignore_suspend = 1,
  5828. .ignore_pmdown_time = 1,
  5829. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  5830. },
  5831. {
  5832. .name = LPASS_BE_SEC_TDM_TX_0,
  5833. .stream_name = "Secondary TDM0 Capture",
  5834. .no_pcm = 1,
  5835. .dpcm_capture = 1,
  5836. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  5837. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5838. .ops = &lahaina_tdm_be_ops,
  5839. .ignore_suspend = 1,
  5840. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  5841. },
  5842. {
  5843. .name = LPASS_BE_TERT_TDM_RX_0,
  5844. .stream_name = "Tertiary TDM0 Playback",
  5845. .no_pcm = 1,
  5846. .dpcm_playback = 1,
  5847. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  5848. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5849. .ops = &lahaina_tdm_be_ops,
  5850. .ignore_suspend = 1,
  5851. .ignore_pmdown_time = 1,
  5852. SND_SOC_DAILINK_REG(tert_tdm_rx_0),
  5853. },
  5854. {
  5855. .name = LPASS_BE_TERT_TDM_TX_0,
  5856. .stream_name = "Tertiary TDM0 Capture",
  5857. .no_pcm = 1,
  5858. .dpcm_capture = 1,
  5859. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  5860. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5861. .ops = &lahaina_tdm_be_ops,
  5862. .ignore_suspend = 1,
  5863. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  5864. },
  5865. {
  5866. .name = LPASS_BE_QUAT_TDM_RX_0,
  5867. .stream_name = "Quaternary TDM0 Playback",
  5868. .no_pcm = 1,
  5869. .dpcm_playback = 1,
  5870. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  5871. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5872. .ops = &lahaina_tdm_be_ops,
  5873. .ignore_suspend = 1,
  5874. .ignore_pmdown_time = 1,
  5875. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  5876. },
  5877. {
  5878. .name = LPASS_BE_QUAT_TDM_TX_0,
  5879. .stream_name = "Quaternary TDM0 Capture",
  5880. .no_pcm = 1,
  5881. .dpcm_capture = 1,
  5882. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  5883. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5884. .ops = &lahaina_tdm_be_ops,
  5885. .ignore_suspend = 1,
  5886. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  5887. },
  5888. {
  5889. .name = LPASS_BE_QUIN_TDM_RX_0,
  5890. .stream_name = "Quinary TDM0 Playback",
  5891. .no_pcm = 1,
  5892. .dpcm_playback = 1,
  5893. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  5894. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5895. .ops = &lahaina_tdm_be_ops,
  5896. .ignore_suspend = 1,
  5897. .ignore_pmdown_time = 1,
  5898. SND_SOC_DAILINK_REG(quin_tdm_rx_0),
  5899. },
  5900. {
  5901. .name = LPASS_BE_QUIN_TDM_TX_0,
  5902. .stream_name = "Quinary TDM0 Capture",
  5903. .no_pcm = 1,
  5904. .dpcm_capture = 1,
  5905. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  5906. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5907. .ops = &lahaina_tdm_be_ops,
  5908. .ignore_suspend = 1,
  5909. SND_SOC_DAILINK_REG(quin_tdm_tx_0),
  5910. },
  5911. {
  5912. .name = LPASS_BE_SEN_TDM_RX_0,
  5913. .stream_name = "Senary TDM0 Playback",
  5914. .no_pcm = 1,
  5915. .dpcm_playback = 1,
  5916. .id = MSM_BACKEND_DAI_SEN_TDM_RX_0,
  5917. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5918. .ops = &lahaina_tdm_be_ops,
  5919. .ignore_suspend = 1,
  5920. .ignore_pmdown_time = 1,
  5921. SND_SOC_DAILINK_REG(sen_tdm_rx_0),
  5922. },
  5923. {
  5924. .name = LPASS_BE_SEN_TDM_TX_0,
  5925. .stream_name = "Senary TDM0 Capture",
  5926. .no_pcm = 1,
  5927. .dpcm_capture = 1,
  5928. .id = MSM_BACKEND_DAI_SEN_TDM_TX_0,
  5929. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5930. .ops = &lahaina_tdm_be_ops,
  5931. .ignore_suspend = 1,
  5932. SND_SOC_DAILINK_REG(sen_tdm_tx_0),
  5933. },
  5934. };
  5935. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  5936. {
  5937. .name = LPASS_BE_SLIMBUS_7_RX,
  5938. .stream_name = "Slimbus7 Playback",
  5939. .no_pcm = 1,
  5940. .dpcm_playback = 1,
  5941. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5942. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5943. .init = &msm_wcn_init,
  5944. .ops = &msm_wcn_ops,
  5945. /* dai link has playback support */
  5946. .ignore_pmdown_time = 1,
  5947. .ignore_suspend = 1,
  5948. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5949. },
  5950. {
  5951. .name = LPASS_BE_SLIMBUS_7_TX,
  5952. .stream_name = "Slimbus7 Capture",
  5953. .no_pcm = 1,
  5954. .dpcm_capture = 1,
  5955. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5956. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5957. .ops = &msm_wcn_ops,
  5958. .ignore_suspend = 1,
  5959. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5960. },
  5961. };
  5962. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  5963. {
  5964. .name = LPASS_BE_SLIMBUS_7_RX,
  5965. .stream_name = "Slimbus7 Playback",
  5966. .no_pcm = 1,
  5967. .dpcm_playback = 1,
  5968. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5969. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5970. .init = &msm_wcn_init_lito,
  5971. .ops = &msm_wcn_ops_lito,
  5972. /* dai link has playback support */
  5973. .ignore_pmdown_time = 1,
  5974. .ignore_suspend = 1,
  5975. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5976. },
  5977. {
  5978. .name = LPASS_BE_SLIMBUS_7_TX,
  5979. .stream_name = "Slimbus7 Capture",
  5980. .no_pcm = 1,
  5981. .dpcm_capture = 1,
  5982. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5983. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5984. .ops = &msm_wcn_ops_lito,
  5985. .ignore_suspend = 1,
  5986. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5987. },
  5988. {
  5989. .name = LPASS_BE_SLIMBUS_8_TX,
  5990. .stream_name = "Slimbus8 Capture",
  5991. .no_pcm = 1,
  5992. .dpcm_capture = 1,
  5993. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  5994. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5995. .ops = &msm_wcn_ops_lito,
  5996. .ignore_suspend = 1,
  5997. SND_SOC_DAILINK_REG(slimbus_8_tx),
  5998. },
  5999. };
  6000. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6001. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  6002. /* DISP PORT BACK END DAI Link */
  6003. {
  6004. .name = LPASS_BE_DISPLAY_PORT,
  6005. .stream_name = "Display Port Playback",
  6006. .no_pcm = 1,
  6007. .dpcm_playback = 1,
  6008. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  6009. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6010. .ignore_pmdown_time = 1,
  6011. .ignore_suspend = 1,
  6012. SND_SOC_DAILINK_REG(display_port),
  6013. },
  6014. /* DISP PORT 1 BACK END DAI Link */
  6015. {
  6016. .name = LPASS_BE_DISPLAY_PORT1,
  6017. .stream_name = "Display Port1 Playback",
  6018. .no_pcm = 1,
  6019. .dpcm_playback = 1,
  6020. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  6021. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6022. .ignore_pmdown_time = 1,
  6023. .ignore_suspend = 1,
  6024. SND_SOC_DAILINK_REG(display_port1),
  6025. },
  6026. };
  6027. #endif
  6028. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  6029. {
  6030. .name = LPASS_BE_PRI_MI2S_RX,
  6031. .stream_name = "Primary MI2S Playback",
  6032. .no_pcm = 1,
  6033. .dpcm_playback = 1,
  6034. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  6035. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6036. .ops = &msm_mi2s_be_ops,
  6037. .ignore_suspend = 1,
  6038. .ignore_pmdown_time = 1,
  6039. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  6040. },
  6041. {
  6042. .name = LPASS_BE_PRI_MI2S_TX,
  6043. .stream_name = "Primary MI2S Capture",
  6044. .no_pcm = 1,
  6045. .dpcm_capture = 1,
  6046. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  6047. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6048. .ops = &msm_mi2s_be_ops,
  6049. .ignore_suspend = 1,
  6050. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  6051. },
  6052. {
  6053. .name = LPASS_BE_SEC_MI2S_RX,
  6054. .stream_name = "Secondary MI2S Playback",
  6055. .no_pcm = 1,
  6056. .dpcm_playback = 1,
  6057. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  6058. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6059. .ops = &msm_mi2s_be_ops,
  6060. .ignore_suspend = 1,
  6061. .ignore_pmdown_time = 1,
  6062. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  6063. },
  6064. {
  6065. .name = LPASS_BE_SEC_MI2S_TX,
  6066. .stream_name = "Secondary MI2S Capture",
  6067. .no_pcm = 1,
  6068. .dpcm_capture = 1,
  6069. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  6070. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6071. .ops = &msm_mi2s_be_ops,
  6072. .ignore_suspend = 1,
  6073. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  6074. },
  6075. {
  6076. .name = LPASS_BE_TERT_MI2S_RX,
  6077. .stream_name = "Tertiary MI2S Playback",
  6078. .no_pcm = 1,
  6079. .dpcm_playback = 1,
  6080. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  6081. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6082. .ops = &msm_mi2s_be_ops,
  6083. .ignore_suspend = 1,
  6084. .ignore_pmdown_time = 1,
  6085. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  6086. },
  6087. {
  6088. .name = LPASS_BE_TERT_MI2S_TX,
  6089. .stream_name = "Tertiary MI2S Capture",
  6090. .no_pcm = 1,
  6091. .dpcm_capture = 1,
  6092. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  6093. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6094. .ops = &msm_mi2s_be_ops,
  6095. .ignore_suspend = 1,
  6096. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  6097. },
  6098. {
  6099. .name = LPASS_BE_QUAT_MI2S_RX,
  6100. .stream_name = "Quaternary MI2S Playback",
  6101. .no_pcm = 1,
  6102. .dpcm_playback = 1,
  6103. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  6104. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6105. .ops = &msm_mi2s_be_ops,
  6106. .ignore_suspend = 1,
  6107. .ignore_pmdown_time = 1,
  6108. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  6109. },
  6110. {
  6111. .name = LPASS_BE_QUAT_MI2S_TX,
  6112. .stream_name = "Quaternary MI2S Capture",
  6113. .no_pcm = 1,
  6114. .dpcm_capture = 1,
  6115. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  6116. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6117. .ops = &msm_mi2s_be_ops,
  6118. .ignore_suspend = 1,
  6119. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  6120. },
  6121. {
  6122. .name = LPASS_BE_QUIN_MI2S_RX,
  6123. .stream_name = "Quinary MI2S Playback",
  6124. .no_pcm = 1,
  6125. .dpcm_playback = 1,
  6126. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  6127. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6128. .ops = &msm_mi2s_be_ops,
  6129. .ignore_suspend = 1,
  6130. .ignore_pmdown_time = 1,
  6131. SND_SOC_DAILINK_REG(quin_mi2s_rx),
  6132. },
  6133. {
  6134. .name = LPASS_BE_QUIN_MI2S_TX,
  6135. .stream_name = "Quinary MI2S Capture",
  6136. .no_pcm = 1,
  6137. .dpcm_capture = 1,
  6138. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  6139. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6140. .ops = &msm_mi2s_be_ops,
  6141. .ignore_suspend = 1,
  6142. SND_SOC_DAILINK_REG(quin_mi2s_tx),
  6143. },
  6144. {
  6145. .name = LPASS_BE_SENARY_MI2S_RX,
  6146. .stream_name = "Senary MI2S Playback",
  6147. .no_pcm = 1,
  6148. .dpcm_playback = 1,
  6149. .id = MSM_BACKEND_DAI_SENARY_MI2S_RX,
  6150. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6151. .ops = &msm_mi2s_be_ops,
  6152. .ignore_suspend = 1,
  6153. .ignore_pmdown_time = 1,
  6154. SND_SOC_DAILINK_REG(sen_mi2s_rx),
  6155. },
  6156. {
  6157. .name = LPASS_BE_SENARY_MI2S_TX,
  6158. .stream_name = "Senary MI2S Capture",
  6159. .no_pcm = 1,
  6160. .dpcm_capture = 1,
  6161. .id = MSM_BACKEND_DAI_SENARY_MI2S_TX,
  6162. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6163. .ops = &msm_mi2s_be_ops,
  6164. .ignore_suspend = 1,
  6165. SND_SOC_DAILINK_REG(sen_mi2s_tx),
  6166. },
  6167. };
  6168. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  6169. /* Primary AUX PCM Backend DAI Links */
  6170. {
  6171. .name = LPASS_BE_AUXPCM_RX,
  6172. .stream_name = "AUX PCM Playback",
  6173. .no_pcm = 1,
  6174. .dpcm_playback = 1,
  6175. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6176. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6177. .ops = &lahaina_aux_be_ops,
  6178. .ignore_pmdown_time = 1,
  6179. .ignore_suspend = 1,
  6180. SND_SOC_DAILINK_REG(auxpcm_rx),
  6181. },
  6182. {
  6183. .name = LPASS_BE_AUXPCM_TX,
  6184. .stream_name = "AUX PCM Capture",
  6185. .no_pcm = 1,
  6186. .dpcm_capture = 1,
  6187. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6188. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6189. .ops = &lahaina_aux_be_ops,
  6190. .ignore_suspend = 1,
  6191. SND_SOC_DAILINK_REG(auxpcm_tx),
  6192. },
  6193. /* Secondary AUX PCM Backend DAI Links */
  6194. {
  6195. .name = LPASS_BE_SEC_AUXPCM_RX,
  6196. .stream_name = "Sec AUX PCM Playback",
  6197. .no_pcm = 1,
  6198. .dpcm_playback = 1,
  6199. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  6200. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6201. .ops = &lahaina_aux_be_ops,
  6202. .ignore_pmdown_time = 1,
  6203. .ignore_suspend = 1,
  6204. SND_SOC_DAILINK_REG(sec_auxpcm_rx),
  6205. },
  6206. {
  6207. .name = LPASS_BE_SEC_AUXPCM_TX,
  6208. .stream_name = "Sec AUX PCM Capture",
  6209. .no_pcm = 1,
  6210. .dpcm_capture = 1,
  6211. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  6212. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6213. .ops = &lahaina_aux_be_ops,
  6214. .ignore_suspend = 1,
  6215. SND_SOC_DAILINK_REG(sec_auxpcm_tx),
  6216. },
  6217. /* Tertiary AUX PCM Backend DAI Links */
  6218. {
  6219. .name = LPASS_BE_TERT_AUXPCM_RX,
  6220. .stream_name = "Tert AUX PCM Playback",
  6221. .no_pcm = 1,
  6222. .dpcm_playback = 1,
  6223. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  6224. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6225. .ops = &lahaina_aux_be_ops,
  6226. .ignore_suspend = 1,
  6227. SND_SOC_DAILINK_REG(tert_auxpcm_rx),
  6228. },
  6229. {
  6230. .name = LPASS_BE_TERT_AUXPCM_TX,
  6231. .stream_name = "Tert AUX PCM Capture",
  6232. .no_pcm = 1,
  6233. .dpcm_capture = 1,
  6234. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  6235. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6236. .ops = &lahaina_aux_be_ops,
  6237. .ignore_suspend = 1,
  6238. SND_SOC_DAILINK_REG(tert_auxpcm_tx),
  6239. },
  6240. /* Quaternary AUX PCM Backend DAI Links */
  6241. {
  6242. .name = LPASS_BE_QUAT_AUXPCM_RX,
  6243. .stream_name = "Quat AUX PCM Playback",
  6244. .no_pcm = 1,
  6245. .dpcm_playback = 1,
  6246. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  6247. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6248. .ops = &lahaina_aux_be_ops,
  6249. .ignore_suspend = 1,
  6250. SND_SOC_DAILINK_REG(quat_auxpcm_rx),
  6251. },
  6252. {
  6253. .name = LPASS_BE_QUAT_AUXPCM_TX,
  6254. .stream_name = "Quat AUX PCM Capture",
  6255. .no_pcm = 1,
  6256. .dpcm_capture = 1,
  6257. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  6258. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6259. .ops = &lahaina_aux_be_ops,
  6260. .ignore_suspend = 1,
  6261. SND_SOC_DAILINK_REG(quat_auxpcm_tx),
  6262. },
  6263. /* Quinary AUX PCM Backend DAI Links */
  6264. {
  6265. .name = LPASS_BE_QUIN_AUXPCM_RX,
  6266. .stream_name = "Quin AUX PCM Playback",
  6267. .no_pcm = 1,
  6268. .dpcm_playback = 1,
  6269. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  6270. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6271. .ops = &lahaina_aux_be_ops,
  6272. .ignore_suspend = 1,
  6273. SND_SOC_DAILINK_REG(quin_auxpcm_rx),
  6274. },
  6275. {
  6276. .name = LPASS_BE_QUIN_AUXPCM_TX,
  6277. .stream_name = "Quin AUX PCM Capture",
  6278. .no_pcm = 1,
  6279. .dpcm_capture = 1,
  6280. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  6281. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6282. .ops = &lahaina_aux_be_ops,
  6283. .ignore_suspend = 1,
  6284. SND_SOC_DAILINK_REG(quin_auxpcm_tx),
  6285. },
  6286. /* Senary AUX PCM Backend DAI Links */
  6287. {
  6288. .name = LPASS_BE_SEN_AUXPCM_RX,
  6289. .stream_name = "Sen AUX PCM Playback",
  6290. .no_pcm = 1,
  6291. .dpcm_playback = 1,
  6292. .id = MSM_BACKEND_DAI_SEN_AUXPCM_RX,
  6293. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6294. .ops = &lahaina_aux_be_ops,
  6295. .ignore_suspend = 1,
  6296. SND_SOC_DAILINK_REG(sen_auxpcm_rx),
  6297. },
  6298. {
  6299. .name = LPASS_BE_SEN_AUXPCM_TX,
  6300. .stream_name = "Sen AUX PCM Capture",
  6301. .no_pcm = 1,
  6302. .dpcm_capture = 1,
  6303. .id = MSM_BACKEND_DAI_SEN_AUXPCM_TX,
  6304. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6305. .ops = &lahaina_aux_be_ops,
  6306. .ignore_suspend = 1,
  6307. SND_SOC_DAILINK_REG(sen_auxpcm_tx),
  6308. },
  6309. };
  6310. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  6311. /* WSA CDC DMA Backend DAI Links */
  6312. {
  6313. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  6314. .stream_name = "WSA CDC DMA0 Playback",
  6315. .no_pcm = 1,
  6316. .dpcm_playback = 1,
  6317. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  6318. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6319. .ignore_pmdown_time = 1,
  6320. .ignore_suspend = 1,
  6321. .ops = &msm_cdc_dma_be_ops,
  6322. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  6323. .init = &msm_int_audrx_init,
  6324. },
  6325. {
  6326. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  6327. .stream_name = "WSA CDC DMA1 Playback",
  6328. .no_pcm = 1,
  6329. .dpcm_playback = 1,
  6330. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  6331. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6332. .ignore_pmdown_time = 1,
  6333. .ignore_suspend = 1,
  6334. .ops = &msm_cdc_dma_be_ops,
  6335. SND_SOC_DAILINK_REG(wsa_dma_rx1),
  6336. },
  6337. {
  6338. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  6339. .stream_name = "WSA CDC DMA1 Capture",
  6340. .no_pcm = 1,
  6341. .dpcm_capture = 1,
  6342. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  6343. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6344. .ignore_suspend = 1,
  6345. .ops = &msm_cdc_dma_be_ops,
  6346. SND_SOC_DAILINK_REG(wsa_dma_tx1),
  6347. },
  6348. {
  6349. .name = LPASS_BE_WSA_CDC_DMA_TX_0_VI,
  6350. .stream_name = "WSA CDC DMA0 Capture",
  6351. .no_pcm = 1,
  6352. .dpcm_capture = 1,
  6353. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  6354. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6355. .ops = &msm_cdc_dma_be_ops,
  6356. .ignore_suspend = 1,
  6357. SND_SOC_DAILINK_REG(wsa_dma_tx0_vi),
  6358. },
  6359. };
  6360. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  6361. /* RX CDC DMA Backend DAI Links */
  6362. {
  6363. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  6364. .stream_name = "RX CDC DMA0 Playback",
  6365. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6366. .dynamic_be = 1,
  6367. #endif /* CONFIG_AUDIO_QGKI */
  6368. .no_pcm = 1,
  6369. .dpcm_playback = 1,
  6370. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  6371. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6372. .ignore_pmdown_time = 1,
  6373. .ignore_suspend = 1,
  6374. .ops = &msm_cdc_dma_be_ops,
  6375. SND_SOC_DAILINK_REG(rx_dma_rx0),
  6376. .init = &msm_aux_codec_init,
  6377. },
  6378. {
  6379. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  6380. .stream_name = "RX CDC DMA1 Playback",
  6381. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6382. .dynamic_be = 1,
  6383. #endif /* CONFIG_AUDIO_QGKI */
  6384. .no_pcm = 1,
  6385. .dpcm_playback = 1,
  6386. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  6387. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6388. .ignore_pmdown_time = 1,
  6389. .ignore_suspend = 1,
  6390. .ops = &msm_cdc_dma_be_ops,
  6391. SND_SOC_DAILINK_REG(rx_dma_rx1),
  6392. .init = &msm_int_audrx_init,
  6393. },
  6394. {
  6395. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  6396. .stream_name = "RX CDC DMA2 Playback",
  6397. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6398. .dynamic_be = 1,
  6399. #endif /* CONFIG_AUDIO_QGKI */
  6400. .no_pcm = 1,
  6401. .dpcm_playback = 1,
  6402. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  6403. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6404. .ignore_pmdown_time = 1,
  6405. .ignore_suspend = 1,
  6406. .ops = &msm_cdc_dma_be_ops,
  6407. SND_SOC_DAILINK_REG(rx_dma_rx2),
  6408. },
  6409. {
  6410. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  6411. .stream_name = "RX CDC DMA3 Playback",
  6412. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6413. .dynamic_be = 1,
  6414. #endif /* CONFIG_AUDIO_QGKI */
  6415. .no_pcm = 1,
  6416. .dpcm_playback = 1,
  6417. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  6418. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6419. .ignore_pmdown_time = 1,
  6420. .ignore_suspend = 1,
  6421. .ops = &msm_cdc_dma_be_ops,
  6422. SND_SOC_DAILINK_REG(rx_dma_rx3),
  6423. },
  6424. {
  6425. .name = LPASS_BE_RX_CDC_DMA_RX_5,
  6426. .stream_name = "RX CDC DMA5 Playback",
  6427. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6428. .dynamic_be = 1,
  6429. #endif /* CONFIG_AUDIO_QGKI */
  6430. .no_pcm = 1,
  6431. .dpcm_playback = 1,
  6432. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_5,
  6433. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6434. .ignore_pmdown_time = 1,
  6435. .ignore_suspend = 1,
  6436. .ops = &msm_cdc_dma_be_ops,
  6437. SND_SOC_DAILINK_REG(rx_dma_rx5),
  6438. },
  6439. {
  6440. .name = LPASS_BE_RX_CDC_DMA_RX_6,
  6441. .stream_name = "RX CDC DMA6 Playback",
  6442. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6443. .dynamic_be = 1,
  6444. #endif /* CONFIG_AUDIO_QGKI */
  6445. .no_pcm = 1,
  6446. .dpcm_playback = 1,
  6447. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_6,
  6448. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6449. .ignore_pmdown_time = 1,
  6450. .ignore_suspend = 1,
  6451. .ops = &msm_cdc_dma_be_ops,
  6452. SND_SOC_DAILINK_REG(rx_dma_rx6),
  6453. },
  6454. /* TX CDC DMA Backend DAI Links */
  6455. {
  6456. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  6457. .stream_name = "TX CDC DMA3 Capture",
  6458. .no_pcm = 1,
  6459. .dpcm_capture = 1,
  6460. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  6461. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6462. .ignore_suspend = 1,
  6463. .ops = &msm_cdc_dma_be_ops,
  6464. SND_SOC_DAILINK_REG(tx_dma_tx3),
  6465. },
  6466. {
  6467. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  6468. .stream_name = "TX CDC DMA4 Capture",
  6469. .no_pcm = 1,
  6470. .dpcm_capture = 1,
  6471. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  6472. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6473. .ignore_suspend = 1,
  6474. .ops = &msm_cdc_dma_be_ops,
  6475. SND_SOC_DAILINK_REG(tx_dma_tx4),
  6476. },
  6477. };
  6478. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  6479. {
  6480. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  6481. .stream_name = "VA CDC DMA0 Capture",
  6482. .no_pcm = 1,
  6483. .dpcm_capture = 1,
  6484. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  6485. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6486. .ignore_suspend = 1,
  6487. .ops = &msm_cdc_dma_be_ops,
  6488. SND_SOC_DAILINK_REG(va_dma_tx0),
  6489. },
  6490. {
  6491. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  6492. .stream_name = "VA CDC DMA1 Capture",
  6493. .no_pcm = 1,
  6494. .dpcm_capture = 1,
  6495. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  6496. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6497. .ignore_suspend = 1,
  6498. .ops = &msm_cdc_dma_be_ops,
  6499. SND_SOC_DAILINK_REG(va_dma_tx1),
  6500. },
  6501. {
  6502. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  6503. .stream_name = "VA CDC DMA2 Capture",
  6504. .no_pcm = 1,
  6505. .dpcm_capture = 1,
  6506. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  6507. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6508. .ignore_suspend = 1,
  6509. .ops = &msm_cdc_dma_be_ops,
  6510. SND_SOC_DAILINK_REG(va_dma_tx2),
  6511. },
  6512. };
  6513. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  6514. {
  6515. .name = LPASS_BE_AFE_LOOPBACK_TX,
  6516. .stream_name = "AFE Loopback Capture",
  6517. .no_pcm = 1,
  6518. .dpcm_capture = 1,
  6519. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  6520. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6521. .ignore_pmdown_time = 1,
  6522. .ignore_suspend = 1,
  6523. SND_SOC_DAILINK_REG(afe_loopback_tx),
  6524. },
  6525. };
  6526. static struct snd_soc_dai_link msm_lahaina_dai_links[
  6527. ARRAY_SIZE(msm_common_dai_links) +
  6528. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  6529. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6530. ARRAY_SIZE(msm_common_be_dai_links) +
  6531. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6532. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  6533. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  6534. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  6535. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  6536. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6537. ARRAY_SIZE(ext_disp_be_dai_link) +
  6538. #endif
  6539. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6540. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link) +
  6541. ARRAY_SIZE(msm_wcn_btfm_be_dai_links)];
  6542. static int msm_populate_dai_link_component_of_node(
  6543. struct snd_soc_card *card)
  6544. {
  6545. int i, j, index, ret = 0;
  6546. struct device *cdev = card->dev;
  6547. struct snd_soc_dai_link *dai_link = card->dai_link;
  6548. struct device_node *np = NULL;
  6549. int codecs_enabled = 0;
  6550. struct snd_soc_dai_link_component *codecs_comp = NULL;
  6551. if (!cdev) {
  6552. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  6553. return -ENODEV;
  6554. }
  6555. for (i = 0; i < card->num_links; i++) {
  6556. if (dai_link[i].platforms->of_node && dai_link[i].cpus->of_node)
  6557. continue;
  6558. /* populate platform_of_node for snd card dai links */
  6559. if (dai_link[i].platforms->name &&
  6560. !dai_link[i].platforms->of_node) {
  6561. index = of_property_match_string(cdev->of_node,
  6562. "asoc-platform-names",
  6563. dai_link[i].platforms->name);
  6564. if (index < 0) {
  6565. dev_err(cdev, "%s: No match found for platform name: %s\n",
  6566. __func__, dai_link[i].platforms->name);
  6567. ret = index;
  6568. goto err;
  6569. }
  6570. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  6571. index);
  6572. if (!np) {
  6573. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  6574. __func__, dai_link[i].platforms->name,
  6575. index);
  6576. ret = -ENODEV;
  6577. goto err;
  6578. }
  6579. dai_link[i].platforms->of_node = np;
  6580. dai_link[i].platforms->name = NULL;
  6581. }
  6582. /* populate cpu_of_node for snd card dai links */
  6583. if (dai_link[i].cpus->dai_name && !dai_link[i].cpus->of_node) {
  6584. index = of_property_match_string(cdev->of_node,
  6585. "asoc-cpu-names",
  6586. dai_link[i].cpus->dai_name);
  6587. if (index >= 0) {
  6588. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  6589. index);
  6590. if (!np) {
  6591. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  6592. __func__,
  6593. dai_link[i].cpus->dai_name);
  6594. ret = -ENODEV;
  6595. goto err;
  6596. }
  6597. dai_link[i].cpus->of_node = np;
  6598. dai_link[i].cpus->dai_name = NULL;
  6599. }
  6600. }
  6601. /* populate codec_of_node for snd card dai links */
  6602. if (dai_link[i].num_codecs > 0) {
  6603. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6604. if (dai_link[i].codecs[j].of_node ||
  6605. !dai_link[i].codecs[j].name)
  6606. continue;
  6607. index = of_property_match_string(cdev->of_node,
  6608. "asoc-codec-names",
  6609. dai_link[i].codecs[j].name);
  6610. if (index < 0)
  6611. continue;
  6612. np = of_parse_phandle(cdev->of_node,
  6613. "asoc-codec",
  6614. index);
  6615. if (!np) {
  6616. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  6617. __func__,
  6618. dai_link[i].codecs[j].name);
  6619. ret = -ENODEV;
  6620. goto err;
  6621. }
  6622. dai_link[i].codecs[j].of_node = np;
  6623. dai_link[i].codecs[j].name = NULL;
  6624. }
  6625. }
  6626. }
  6627. /* In multi-codec scenario, check if codecs are enabled for this platform */
  6628. for (i = 0; i < card->num_links; i++) {
  6629. codecs_enabled = 0;
  6630. if (dai_link[i].num_codecs > 1) {
  6631. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6632. if (!dai_link[i].codecs[j].of_node)
  6633. continue;
  6634. np = dai_link[i].codecs[j].of_node;
  6635. if (!of_device_is_available(np)) {
  6636. dev_dbg(cdev, "%s: codec is disabled: %s\n",
  6637. __func__,
  6638. np->full_name);
  6639. dai_link[i].codecs[j].of_node = NULL;
  6640. continue;
  6641. }
  6642. codecs_enabled++;
  6643. }
  6644. if (codecs_enabled > 0 &&
  6645. codecs_enabled < dai_link[i].num_codecs) {
  6646. codecs_comp = devm_kzalloc(cdev,
  6647. sizeof(struct snd_soc_dai_link_component)
  6648. * codecs_enabled, GFP_KERNEL);
  6649. if (!codecs_comp) {
  6650. dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
  6651. __func__, dai_link[i].name);
  6652. ret = -ENOMEM;
  6653. goto err;
  6654. }
  6655. index = 0;
  6656. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6657. if(dai_link[i].codecs[j].of_node) {
  6658. codecs_comp[index].of_node =
  6659. dai_link[i].codecs[j].of_node;
  6660. codecs_comp[index].dai_name =
  6661. dai_link[i].codecs[j].dai_name;
  6662. codecs_comp[index].name = NULL;
  6663. index++;
  6664. }
  6665. }
  6666. dai_link[i].codecs = codecs_comp;
  6667. dai_link[i].num_codecs = codecs_enabled;
  6668. }
  6669. }
  6670. }
  6671. err:
  6672. return ret;
  6673. }
  6674. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  6675. {
  6676. int ret = -EINVAL;
  6677. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  6678. if (!component) {
  6679. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  6680. return ret;
  6681. }
  6682. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  6683. ARRAY_SIZE(msm_snd_controls));
  6684. if (ret < 0) {
  6685. dev_err(component->dev,
  6686. "%s: add_codec_controls failed, err = %d\n",
  6687. __func__, ret);
  6688. return ret;
  6689. }
  6690. return ret;
  6691. }
  6692. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  6693. struct snd_pcm_hw_params *params)
  6694. {
  6695. return 0;
  6696. }
  6697. static struct snd_soc_ops msm_stub_be_ops = {
  6698. .hw_params = msm_snd_stub_hw_params,
  6699. };
  6700. struct snd_soc_card snd_soc_card_stub_msm = {
  6701. .name = "lahaina-stub-snd-card",
  6702. };
  6703. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  6704. /* FrontEnd DAI Links */
  6705. {
  6706. .name = "MSMSTUB Media1",
  6707. .stream_name = "MultiMedia1",
  6708. .dynamic = 1,
  6709. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6710. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6711. #endif /* CONFIG_AUDIO_QGKI */
  6712. .dpcm_playback = 1,
  6713. .dpcm_capture = 1,
  6714. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6715. SND_SOC_DPCM_TRIGGER_POST},
  6716. .ignore_suspend = 1,
  6717. /* this dainlink has playback support */
  6718. .ignore_pmdown_time = 1,
  6719. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  6720. SND_SOC_DAILINK_REG(multimedia1),
  6721. },
  6722. };
  6723. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  6724. /* Backend DAI Links */
  6725. {
  6726. .name = LPASS_BE_AUXPCM_RX,
  6727. .stream_name = "AUX PCM Playback",
  6728. .no_pcm = 1,
  6729. .dpcm_playback = 1,
  6730. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6731. .init = &msm_audrx_stub_init,
  6732. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6733. .ignore_pmdown_time = 1,
  6734. .ignore_suspend = 1,
  6735. .ops = &msm_stub_be_ops,
  6736. SND_SOC_DAILINK_REG(auxpcm_rx),
  6737. },
  6738. {
  6739. .name = LPASS_BE_AUXPCM_TX,
  6740. .stream_name = "AUX PCM Capture",
  6741. .no_pcm = 1,
  6742. .dpcm_capture = 1,
  6743. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6744. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6745. .ignore_suspend = 1,
  6746. .ops = &msm_stub_be_ops,
  6747. SND_SOC_DAILINK_REG(auxpcm_tx),
  6748. },
  6749. };
  6750. static struct snd_soc_dai_link msm_stub_dai_links[
  6751. ARRAY_SIZE(msm_stub_fe_dai_links) +
  6752. ARRAY_SIZE(msm_stub_be_dai_links)];
  6753. static const struct of_device_id lahaina_asoc_machine_of_match[] = {
  6754. { .compatible = "qcom,lahaina-asoc-snd",
  6755. .data = "codec"},
  6756. { .compatible = "qcom,lahaina-asoc-snd-stub",
  6757. .data = "stub_codec"},
  6758. {},
  6759. };
  6760. static int msm_snd_card_late_probe(struct snd_soc_card *card)
  6761. {
  6762. struct snd_soc_component *component = NULL;
  6763. const char *be_dl_name = LPASS_BE_RX_CDC_DMA_RX_0;
  6764. struct snd_soc_pcm_runtime *rtd;
  6765. struct msm_asoc_mach_data *pdata;
  6766. int ret = 0;
  6767. void *mbhc_calibration;
  6768. pdata = snd_soc_card_get_drvdata(card);
  6769. if (!pdata)
  6770. return -EINVAL;
  6771. if (pdata->wcd_disabled)
  6772. return 0;
  6773. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  6774. if (!rtd) {
  6775. dev_err(card->dev,
  6776. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  6777. __func__, be_dl_name);
  6778. return -EINVAL;
  6779. }
  6780. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  6781. if (!component) {
  6782. pr_err("%s component is NULL\n", __func__);
  6783. return -EINVAL;
  6784. }
  6785. mbhc_calibration = def_wcd_mbhc_cal();
  6786. if (!mbhc_calibration)
  6787. return -ENOMEM;
  6788. wcd_mbhc_cfg.calibration = mbhc_calibration;
  6789. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  6790. if (ret) {
  6791. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  6792. __func__, ret);
  6793. goto err_hs_detect;
  6794. }
  6795. return 0;
  6796. err_hs_detect:
  6797. kfree(mbhc_calibration);
  6798. return ret;
  6799. }
  6800. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  6801. {
  6802. struct snd_soc_card *card = NULL;
  6803. struct snd_soc_dai_link *dailink = NULL;
  6804. int len_1 = 0;
  6805. int len_2 = 0;
  6806. int total_links = 0;
  6807. int rc = 0;
  6808. u32 mi2s_audio_intf = 0;
  6809. u32 auxpcm_audio_intf = 0;
  6810. u32 val = 0;
  6811. u32 wcn_btfm_intf = 0;
  6812. const struct of_device_id *match;
  6813. u32 wsa_max_devs = 0;
  6814. match = of_match_node(lahaina_asoc_machine_of_match, dev->of_node);
  6815. if (!match) {
  6816. dev_err(dev, "%s: No DT match found for sound card\n",
  6817. __func__);
  6818. return NULL;
  6819. }
  6820. if (!strcmp(match->data, "codec")) {
  6821. card = &snd_soc_card_lahaina_msm;
  6822. memcpy(msm_lahaina_dai_links + total_links,
  6823. msm_common_dai_links,
  6824. sizeof(msm_common_dai_links));
  6825. total_links += ARRAY_SIZE(msm_common_dai_links);
  6826. rc = of_property_read_u32(dev->of_node,
  6827. "qcom,wsa-max-devs", &wsa_max_devs);
  6828. if (rc) {
  6829. dev_info(dev,
  6830. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  6831. __func__, dev->of_node->full_name, rc);
  6832. wsa_max_devs = 0;
  6833. }
  6834. if (!wsa_max_devs) {
  6835. memcpy(msm_lahaina_dai_links + total_links,
  6836. msm_bolero_fe_stub_dai_links,
  6837. sizeof(msm_bolero_fe_stub_dai_links));
  6838. total_links +=
  6839. ARRAY_SIZE(msm_bolero_fe_stub_dai_links);
  6840. } else {
  6841. memcpy(msm_lahaina_dai_links + total_links,
  6842. msm_bolero_fe_dai_links,
  6843. sizeof(msm_bolero_fe_dai_links));
  6844. total_links +=
  6845. ARRAY_SIZE(msm_bolero_fe_dai_links);
  6846. }
  6847. memcpy(msm_lahaina_dai_links + total_links,
  6848. msm_common_misc_fe_dai_links,
  6849. sizeof(msm_common_misc_fe_dai_links));
  6850. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6851. memcpy(msm_lahaina_dai_links + total_links,
  6852. msm_common_be_dai_links,
  6853. sizeof(msm_common_be_dai_links));
  6854. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  6855. memcpy(msm_lahaina_dai_links + total_links,
  6856. msm_rx_tx_cdc_dma_be_dai_links,
  6857. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  6858. total_links +=
  6859. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  6860. if (wsa_max_devs) {
  6861. memcpy(msm_lahaina_dai_links + total_links,
  6862. msm_wsa_cdc_dma_be_dai_links,
  6863. sizeof(msm_wsa_cdc_dma_be_dai_links));
  6864. total_links +=
  6865. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  6866. }
  6867. memcpy(msm_lahaina_dai_links + total_links,
  6868. msm_va_cdc_dma_be_dai_links,
  6869. sizeof(msm_va_cdc_dma_be_dai_links));
  6870. total_links +=
  6871. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  6872. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  6873. &mi2s_audio_intf);
  6874. if (rc) {
  6875. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  6876. __func__);
  6877. } else {
  6878. if (mi2s_audio_intf) {
  6879. memcpy(msm_lahaina_dai_links + total_links,
  6880. msm_mi2s_be_dai_links,
  6881. sizeof(msm_mi2s_be_dai_links));
  6882. total_links +=
  6883. ARRAY_SIZE(msm_mi2s_be_dai_links);
  6884. }
  6885. }
  6886. rc = of_property_read_u32(dev->of_node,
  6887. "qcom,auxpcm-audio-intf",
  6888. &auxpcm_audio_intf);
  6889. if (rc) {
  6890. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  6891. __func__);
  6892. } else {
  6893. if (auxpcm_audio_intf) {
  6894. memcpy(msm_lahaina_dai_links + total_links,
  6895. msm_auxpcm_be_dai_links,
  6896. sizeof(msm_auxpcm_be_dai_links));
  6897. total_links +=
  6898. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6899. }
  6900. }
  6901. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6902. rc = of_property_read_u32(dev->of_node,
  6903. "qcom,ext-disp-audio-rx", &val);
  6904. if (!rc && val) {
  6905. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6906. __func__);
  6907. memcpy(msm_lahaina_dai_links + total_links,
  6908. ext_disp_be_dai_link,
  6909. sizeof(ext_disp_be_dai_link));
  6910. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6911. }
  6912. #endif
  6913. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  6914. if (!rc && val) {
  6915. dev_dbg(dev, "%s(): WCN BT support present\n",
  6916. __func__);
  6917. memcpy(msm_lahaina_dai_links + total_links,
  6918. msm_wcn_be_dai_links,
  6919. sizeof(msm_wcn_be_dai_links));
  6920. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6921. }
  6922. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  6923. &val);
  6924. if (!rc && val) {
  6925. memcpy(msm_lahaina_dai_links + total_links,
  6926. msm_afe_rxtx_lb_be_dai_link,
  6927. sizeof(msm_afe_rxtx_lb_be_dai_link));
  6928. total_links +=
  6929. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  6930. }
  6931. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  6932. &wcn_btfm_intf);
  6933. if (rc) {
  6934. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  6935. __func__);
  6936. } else {
  6937. if (wcn_btfm_intf) {
  6938. memcpy(msm_lahaina_dai_links + total_links,
  6939. msm_wcn_btfm_be_dai_links,
  6940. sizeof(msm_wcn_btfm_be_dai_links));
  6941. total_links +=
  6942. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  6943. }
  6944. }
  6945. dailink = msm_lahaina_dai_links;
  6946. } else if(!strcmp(match->data, "stub_codec")) {
  6947. card = &snd_soc_card_stub_msm;
  6948. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  6949. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  6950. memcpy(msm_stub_dai_links,
  6951. msm_stub_fe_dai_links,
  6952. sizeof(msm_stub_fe_dai_links));
  6953. memcpy(msm_stub_dai_links + len_1,
  6954. msm_stub_be_dai_links,
  6955. sizeof(msm_stub_be_dai_links));
  6956. dailink = msm_stub_dai_links;
  6957. total_links = len_2;
  6958. }
  6959. if (card) {
  6960. card->dai_link = dailink;
  6961. card->num_links = total_links;
  6962. card->late_probe = msm_snd_card_late_probe;
  6963. }
  6964. return card;
  6965. }
  6966. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  6967. {
  6968. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6969. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6970. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  6971. SPKR_L_BOOST, SPKR_L_VI};
  6972. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  6973. SPKR_R_BOOST, SPKR_R_VI};
  6974. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  6975. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  6976. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  6977. struct snd_soc_component *component = NULL;
  6978. struct snd_soc_dapm_context *dapm = NULL;
  6979. struct snd_card *card = NULL;
  6980. struct snd_info_entry *entry = NULL;
  6981. struct msm_asoc_mach_data *pdata =
  6982. snd_soc_card_get_drvdata(rtd->card);
  6983. int ret = 0;
  6984. int wsa_active_devs = 0;
  6985. if (codec_reg_done) {
  6986. return 0;
  6987. }
  6988. if (pdata->wsa_max_devs > 0) {
  6989. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  6990. if (component) {
  6991. dapm = snd_soc_component_get_dapm(component);
  6992. wsa883x_set_channel_map(component, &spkleft_ports[0],
  6993. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  6994. &ch_rate[0], &spkleft_port_types[0]);
  6995. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  6996. component);
  6997. wsa_active_devs++;
  6998. } else {
  6999. pr_info("%s: wsa-codec.1 component is NULL\n", __func__);
  7000. }
  7001. }
  7002. /* If current platform has more than one WSA */
  7003. if (pdata->wsa_max_devs > wsa_active_devs) {
  7004. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  7005. if (!component) {
  7006. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  7007. pr_err("%s: %d WSA is found. Expect %d WSA.",
  7008. __func__, wsa_active_devs, pdata->wsa_max_devs);
  7009. return -EINVAL;
  7010. }
  7011. dapm = snd_soc_component_get_dapm(component);
  7012. wsa883x_set_channel_map(component, &spkright_ports[0],
  7013. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  7014. &ch_rate[0], &spkright_port_types[0]);
  7015. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  7016. component);
  7017. }
  7018. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  7019. if (!component) {
  7020. pr_err("%s: could not find component for bolero_codec\n",
  7021. __func__);
  7022. return ret;
  7023. }
  7024. dapm = snd_soc_component_get_dapm(component);
  7025. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  7026. ARRAY_SIZE(msm_int_snd_controls));
  7027. if (ret < 0) {
  7028. pr_err("%s: add_component_controls failed: %d\n",
  7029. __func__, ret);
  7030. return ret;
  7031. }
  7032. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  7033. ARRAY_SIZE(msm_common_snd_controls));
  7034. if (ret < 0) {
  7035. pr_err("%s: add common snd controls failed: %d\n",
  7036. __func__, ret);
  7037. return ret;
  7038. }
  7039. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  7040. ARRAY_SIZE(msm_int_dapm_widgets));
  7041. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  7042. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  7043. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  7044. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  7045. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  7046. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  7047. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  7048. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  7049. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  7050. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  7051. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  7052. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  7053. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  7054. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  7055. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  7056. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  7057. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  7058. snd_soc_dapm_sync(dapm);
  7059. card = rtd->card->snd_card;
  7060. if (strnstr(rtd->card->name, "shima", 5) != NULL)
  7061. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map_shima),
  7062. sm_port_map_shima);
  7063. else
  7064. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  7065. sm_port_map);
  7066. if (!pdata->codec_root) {
  7067. entry = msm_snd_info_create_subdir(card->module, "codecs",
  7068. card->proc_root);
  7069. if (!entry) {
  7070. pr_debug("%s: Cannot create codecs module entry\n",
  7071. __func__);
  7072. ret = 0;
  7073. goto err;
  7074. }
  7075. pdata->codec_root = entry;
  7076. }
  7077. bolero_info_create_codec_entry(pdata->codec_root, component);
  7078. bolero_register_wake_irq(component, false);
  7079. codec_reg_done = true;
  7080. err:
  7081. return ret;
  7082. }
  7083. static int msm_aux_codec_init(struct snd_soc_pcm_runtime *rtd)
  7084. {
  7085. struct snd_soc_component *component = NULL;
  7086. struct snd_soc_dapm_context *dapm = NULL;
  7087. int ret = 0;
  7088. int codec_variant = -1;
  7089. struct snd_info_entry *entry;
  7090. struct snd_card *card = NULL;
  7091. struct msm_asoc_mach_data *pdata;
  7092. pdata = snd_soc_card_get_drvdata(rtd->card);
  7093. if(!pdata)
  7094. return -EINVAL;
  7095. if (pdata->wcd_disabled)
  7096. return 0;
  7097. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  7098. if (!component) {
  7099. pr_err("%s component is NULL\n", __func__);
  7100. return -EINVAL;
  7101. }
  7102. dapm = snd_soc_component_get_dapm(component);
  7103. card = component->card->snd_card;
  7104. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  7105. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  7106. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  7107. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  7108. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  7109. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  7110. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  7111. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  7112. snd_soc_dapm_sync(dapm);
  7113. if (!pdata->codec_root) {
  7114. entry = msm_snd_info_create_subdir(card->module, "codecs",
  7115. card->proc_root);
  7116. if (!entry) {
  7117. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  7118. __func__);
  7119. return 0;
  7120. }
  7121. pdata->codec_root = entry;
  7122. }
  7123. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  7124. codec_variant = wcd938x_get_codec_variant(component);
  7125. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  7126. if (codec_variant == WCD9380)
  7127. ret = snd_soc_add_component_controls(component,
  7128. msm_int_wcd9380_snd_controls,
  7129. ARRAY_SIZE(msm_int_wcd9380_snd_controls));
  7130. else if (codec_variant == WCD9385)
  7131. ret = snd_soc_add_component_controls(component,
  7132. msm_int_wcd9385_snd_controls,
  7133. ARRAY_SIZE(msm_int_wcd9385_snd_controls));
  7134. if (ret < 0) {
  7135. dev_err(component->dev, "%s: add codec specific snd controls failed: %d\n",
  7136. __func__, ret);
  7137. return ret;
  7138. }
  7139. return 0;
  7140. }
  7141. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  7142. {
  7143. int count = 0;
  7144. u32 mi2s_master_slave[MI2S_MAX];
  7145. int ret = 0;
  7146. for (count = 0; count < MI2S_MAX; count++) {
  7147. mutex_init(&mi2s_intf_conf[count].lock);
  7148. mi2s_intf_conf[count].ref_cnt = 0;
  7149. }
  7150. ret = of_property_read_u32_array(pdev->dev.of_node,
  7151. "qcom,msm-mi2s-master",
  7152. mi2s_master_slave, MI2S_MAX);
  7153. if (ret) {
  7154. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  7155. __func__);
  7156. } else {
  7157. for (count = 0; count < MI2S_MAX; count++) {
  7158. mi2s_intf_conf[count].msm_is_mi2s_master =
  7159. mi2s_master_slave[count];
  7160. }
  7161. }
  7162. }
  7163. static void msm_i2s_auxpcm_deinit(void)
  7164. {
  7165. int count = 0;
  7166. for (count = 0; count < MI2S_MAX; count++) {
  7167. mutex_destroy(&mi2s_intf_conf[count].lock);
  7168. mi2s_intf_conf[count].ref_cnt = 0;
  7169. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  7170. }
  7171. }
  7172. static int lahaina_ssr_enable(struct device *dev, void *data)
  7173. {
  7174. struct platform_device *pdev = to_platform_device(dev);
  7175. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7176. int ret = 0;
  7177. if (!card) {
  7178. dev_err(dev, "%s: card is NULL\n", __func__);
  7179. ret = -EINVAL;
  7180. goto err;
  7181. }
  7182. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  7183. /* TODO */
  7184. dev_dbg(dev, "%s: TODO \n", __func__);
  7185. }
  7186. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  7187. snd_soc_card_change_online_state(card, 1);
  7188. #endif /* CONFIG_AUDIO_QGKI */
  7189. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  7190. err:
  7191. return ret;
  7192. }
  7193. static void lahaina_ssr_disable(struct device *dev, void *data)
  7194. {
  7195. struct platform_device *pdev = to_platform_device(dev);
  7196. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7197. if (!card) {
  7198. dev_err(dev, "%s: card is NULL\n", __func__);
  7199. return;
  7200. }
  7201. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  7202. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  7203. snd_soc_card_change_online_state(card, 0);
  7204. #endif /* CONFIG_AUDIO_QGKI */
  7205. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  7206. /* TODO */
  7207. dev_dbg(dev, "%s: TODO \n", __func__);
  7208. }
  7209. }
  7210. static const struct snd_event_ops lahaina_ssr_ops = {
  7211. .enable = lahaina_ssr_enable,
  7212. .disable = lahaina_ssr_disable,
  7213. };
  7214. static int msm_audio_ssr_compare(struct device *dev, void *data)
  7215. {
  7216. struct device_node *node = data;
  7217. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  7218. __func__, dev->of_node, node);
  7219. return (dev->of_node && dev->of_node == node);
  7220. }
  7221. static int msm_audio_ssr_register(struct device *dev)
  7222. {
  7223. struct device_node *np = dev->of_node;
  7224. struct snd_event_clients *ssr_clients = NULL;
  7225. struct device_node *node = NULL;
  7226. int ret = 0;
  7227. int i = 0;
  7228. for (i = 0; ; i++) {
  7229. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  7230. if (!node)
  7231. break;
  7232. snd_event_mstr_add_client(&ssr_clients,
  7233. msm_audio_ssr_compare, node);
  7234. }
  7235. ret = snd_event_master_register(dev, &lahaina_ssr_ops,
  7236. ssr_clients, NULL);
  7237. if (!ret)
  7238. snd_event_notify(dev, SND_EVENT_UP);
  7239. return ret;
  7240. }
  7241. static void parse_cps_configuration(struct platform_device *pdev,
  7242. struct msm_asoc_mach_data *pdata)
  7243. {
  7244. int ret = 0;
  7245. int i = 0, j = 0;
  7246. u32 dt_values[MAX_CPS_LEVELS];
  7247. if (!pdev || !pdata || !pdata->wsa_max_devs)
  7248. return;
  7249. pdata->get_wsa_dev_num = wsa883x_codec_get_dev_num;
  7250. pdata->cps_config.hw_reg_cfg.num_spkr = pdata->wsa_max_devs;
  7251. ret = of_property_read_u32_array(pdev->dev.of_node,
  7252. "qcom,cps_reg_phy_addr", dt_values,
  7253. sizeof(dt_values)/sizeof(dt_values[0]));
  7254. if (ret) {
  7255. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7256. __func__, "qcom,cps_reg_phy_addr");
  7257. } else {
  7258. pdata->cps_config.hw_reg_cfg.lpass_wr_cmd_reg_phy_addr =
  7259. dt_values[0];
  7260. pdata->cps_config.hw_reg_cfg.lpass_rd_cmd_reg_phy_addr =
  7261. dt_values[1];
  7262. pdata->cps_config.hw_reg_cfg.lpass_rd_fifo_reg_phy_addr =
  7263. dt_values[2];
  7264. }
  7265. ret = of_property_read_u32_array(pdev->dev.of_node,
  7266. "qcom,cps_threshold_levels", dt_values,
  7267. sizeof(dt_values)/sizeof(dt_values[0]) - 1);
  7268. if (ret) {
  7269. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7270. __func__, "qcom,cps_threshold_levels");
  7271. } else {
  7272. pdata->cps_config.hw_reg_cfg.vbatt_lower2_threshold =
  7273. dt_values[0];
  7274. pdata->cps_config.hw_reg_cfg.vbatt_lower1_threshold =
  7275. dt_values[1];
  7276. }
  7277. pdata->cps_config.spkr_dep_cfg = devm_kzalloc(&pdev->dev,
  7278. sizeof(struct lpass_swr_spkr_dep_cfg_t)
  7279. * pdata->wsa_max_devs, GFP_KERNEL);
  7280. if (!pdata->cps_config.spkr_dep_cfg) {
  7281. dev_err(&pdev->dev, "%s: spkr dep cfg alloc failed\n", __func__);
  7282. return;
  7283. }
  7284. ret = of_property_read_u32_array(pdev->dev.of_node,
  7285. "qcom,cps_wsa_vbatt_temp_reg_addr", dt_values,
  7286. sizeof(dt_values)/sizeof(dt_values[0]) - 1);
  7287. if (ret) {
  7288. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7289. __func__, "qcom,cps_wsa_vbatt_temp_reg_addr");
  7290. } else {
  7291. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7292. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr =
  7293. dt_values[0];
  7294. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr =
  7295. dt_values[1];
  7296. }
  7297. }
  7298. ret = of_property_read_u32_array(pdev->dev.of_node,
  7299. "qcom,cps_normal_values", dt_values,
  7300. sizeof(dt_values)/sizeof(dt_values[0]));
  7301. if (ret) {
  7302. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7303. __func__, "qcom,cps_normal_values");
  7304. } else {
  7305. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7306. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7307. pdata->cps_config.spkr_dep_cfg[i].
  7308. value_normal_thrsd[j] = dt_values[j];
  7309. }
  7310. }
  7311. }
  7312. ret = of_property_read_u32_array(pdev->dev.of_node,
  7313. "qcom,cps_lower1_values", dt_values,
  7314. sizeof(dt_values)/sizeof(dt_values[0]));
  7315. if (ret) {
  7316. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7317. __func__, "qcom,cps_lower1_values");
  7318. } else {
  7319. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7320. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7321. pdata->cps_config.spkr_dep_cfg[i].
  7322. value_low1_thrsd[j] = dt_values[j];
  7323. }
  7324. }
  7325. }
  7326. ret = of_property_read_u32_array(pdev->dev.of_node,
  7327. "qcom,cps_lower2_values", dt_values,
  7328. sizeof(dt_values)/sizeof(dt_values[0]));
  7329. if (ret) {
  7330. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7331. __func__, "qcom,cps_lower2_values");
  7332. } else {
  7333. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7334. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7335. pdata->cps_config.spkr_dep_cfg[i].
  7336. value_low2_thrsd[j] = dt_values[j];
  7337. }
  7338. }
  7339. }
  7340. }
  7341. static int msm_asoc_machine_probe(struct platform_device *pdev)
  7342. {
  7343. struct snd_soc_card *card = NULL;
  7344. struct msm_asoc_mach_data *pdata = NULL;
  7345. const char *mbhc_audio_jack_type = NULL;
  7346. int ret = 0;
  7347. uint index = 0;
  7348. struct clk *lpass_audio_hw_vote = NULL;
  7349. if (!pdev->dev.of_node) {
  7350. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  7351. return -EINVAL;
  7352. }
  7353. pdata = devm_kzalloc(&pdev->dev,
  7354. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  7355. if (!pdata)
  7356. return -ENOMEM;
  7357. of_property_read_u32(pdev->dev.of_node,
  7358. "qcom,lito-is-v2-enabled",
  7359. &pdata->lito_v2_enabled);
  7360. of_property_read_u32(pdev->dev.of_node,
  7361. "qcom,wcd-disabled",
  7362. &pdata->wcd_disabled);
  7363. card = populate_snd_card_dailinks(&pdev->dev);
  7364. if (!card) {
  7365. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  7366. ret = -EINVAL;
  7367. goto err;
  7368. }
  7369. card->dev = &pdev->dev;
  7370. platform_set_drvdata(pdev, card);
  7371. snd_soc_card_set_drvdata(card, pdata);
  7372. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  7373. if (ret) {
  7374. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  7375. __func__, ret);
  7376. goto err;
  7377. }
  7378. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  7379. if (ret) {
  7380. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  7381. __func__, ret);
  7382. goto err;
  7383. }
  7384. ret = msm_populate_dai_link_component_of_node(card);
  7385. if (ret) {
  7386. ret = -EPROBE_DEFER;
  7387. goto err;
  7388. }
  7389. /* Get maximum WSA device count for this platform */
  7390. ret = of_property_read_u32(pdev->dev.of_node,
  7391. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  7392. if (ret) {
  7393. dev_info(&pdev->dev,
  7394. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  7395. __func__, pdev->dev.of_node->full_name, ret);
  7396. pdata->wsa_max_devs = 0;
  7397. }
  7398. ret = devm_snd_soc_register_card(&pdev->dev, card);
  7399. if (ret == -EPROBE_DEFER) {
  7400. if (codec_reg_done)
  7401. ret = -EINVAL;
  7402. goto err;
  7403. } else if (ret) {
  7404. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  7405. __func__, ret);
  7406. goto err;
  7407. }
  7408. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  7409. __func__, card->name);
  7410. ret = of_property_read_u32(pdev->dev.of_node, "qcom,tdm-max-slots",
  7411. &pdata->tdm_max_slots);
  7412. if (ret) {
  7413. dev_err(&pdev->dev, "%s: No DT match for tdm max slots\n",
  7414. __func__);
  7415. }
  7416. if ((pdata->tdm_max_slots <= 0) || (pdata->tdm_max_slots >
  7417. TDM_MAX_SLOTS)) {
  7418. pdata->tdm_max_slots = TDM_MAX_SLOTS;
  7419. dev_err(&pdev->dev, "%s: Using default tdm max slot: %d\n",
  7420. __func__, pdata->tdm_max_slots);
  7421. }
  7422. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7423. "qcom,hph-en1-gpio", 0);
  7424. if (!pdata->hph_en1_gpio_p) {
  7425. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7426. __func__, "qcom,hph-en1-gpio",
  7427. pdev->dev.of_node->full_name);
  7428. }
  7429. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7430. "qcom,hph-en0-gpio", 0);
  7431. if (!pdata->hph_en0_gpio_p) {
  7432. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7433. __func__, "qcom,hph-en0-gpio",
  7434. pdev->dev.of_node->full_name);
  7435. }
  7436. ret = of_property_read_string(pdev->dev.of_node,
  7437. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  7438. if (ret) {
  7439. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  7440. __func__, "qcom,mbhc-audio-jack-type",
  7441. pdev->dev.of_node->full_name);
  7442. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  7443. } else {
  7444. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  7445. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7446. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  7447. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  7448. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7449. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  7450. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  7451. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7452. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  7453. } else {
  7454. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7455. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  7456. }
  7457. }
  7458. /*
  7459. * Parse US-Euro gpio info from DT. Report no error if us-euro
  7460. * entry is not found in DT file as some targets do not support
  7461. * US-Euro detection
  7462. */
  7463. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7464. "qcom,us-euro-gpios", 0);
  7465. if (!pdata->us_euro_gpio_p) {
  7466. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  7467. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  7468. } else {
  7469. dev_dbg(&pdev->dev, "%s detected\n",
  7470. "qcom,us-euro-gpios");
  7471. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  7472. }
  7473. if (wcd_mbhc_cfg.enable_usbc_analog)
  7474. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  7475. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  7476. "fsa4480-i2c-handle", 0);
  7477. if (!pdata->fsa_handle)
  7478. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  7479. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  7480. msm_i2s_auxpcm_init(pdev);
  7481. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7482. "qcom,cdc-dmic01-gpios",
  7483. 0);
  7484. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7485. "qcom,cdc-dmic23-gpios",
  7486. 0);
  7487. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7488. "qcom,cdc-dmic45-gpios",
  7489. 0);
  7490. if (pdata->dmic01_gpio_p)
  7491. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  7492. if (pdata->dmic23_gpio_p)
  7493. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  7494. if (pdata->dmic45_gpio_p)
  7495. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  7496. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7497. "qcom,pri-mi2s-gpios", 0);
  7498. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7499. "qcom,sec-mi2s-gpios", 0);
  7500. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7501. "qcom,tert-mi2s-gpios", 0);
  7502. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7503. "qcom,quat-mi2s-gpios", 0);
  7504. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7505. "qcom,quin-mi2s-gpios", 0);
  7506. pdata->mi2s_gpio_p[SEN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7507. "qcom,sen-mi2s-gpios", 0);
  7508. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  7509. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  7510. /* parse cps configuration from dt */
  7511. parse_cps_configuration(pdev, pdata);
  7512. /* Register LPASS audio hw vote */
  7513. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  7514. if (IS_ERR(lpass_audio_hw_vote)) {
  7515. ret = PTR_ERR(lpass_audio_hw_vote);
  7516. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  7517. __func__, "lpass_audio_hw_vote", ret);
  7518. lpass_audio_hw_vote = NULL;
  7519. ret = 0;
  7520. }
  7521. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  7522. pdata->core_audio_vote_count = 0;
  7523. ret = msm_audio_ssr_register(&pdev->dev);
  7524. if (ret)
  7525. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  7526. __func__, ret);
  7527. is_initial_boot = true;
  7528. /* Add QoS request for audio tasks */
  7529. msm_audio_add_qos_request();
  7530. return 0;
  7531. err:
  7532. devm_kfree(&pdev->dev, pdata);
  7533. return ret;
  7534. }
  7535. static int msm_asoc_machine_remove(struct platform_device *pdev)
  7536. {
  7537. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7538. snd_event_master_deregister(&pdev->dev);
  7539. snd_soc_unregister_card(card);
  7540. msm_i2s_auxpcm_deinit();
  7541. msm_audio_remove_qos_request();
  7542. return 0;
  7543. }
  7544. static struct platform_driver lahaina_asoc_machine_driver = {
  7545. .driver = {
  7546. .name = DRV_NAME,
  7547. .owner = THIS_MODULE,
  7548. .pm = &snd_soc_pm_ops,
  7549. .of_match_table = lahaina_asoc_machine_of_match,
  7550. .suppress_bind_attrs = true,
  7551. },
  7552. .probe = msm_asoc_machine_probe,
  7553. .remove = msm_asoc_machine_remove,
  7554. };
  7555. module_platform_driver(lahaina_asoc_machine_driver);
  7556. MODULE_SOFTDEP("pre: bt_fm_slim");
  7557. MODULE_DESCRIPTION("ALSA SoC msm");
  7558. MODULE_LICENSE("GPL v2");
  7559. MODULE_ALIAS("platform:" DRV_NAME);
  7560. MODULE_DEVICE_TABLE(of, lahaina_asoc_machine_of_match);