lahaina.c 235 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309
  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 int send_cps_config(struct snd_soc_pcm_runtime *rtd,
  4516. u32 num_ch, u32 ch_mask)
  4517. {
  4518. int i = 0;
  4519. int ret = 0;
  4520. int val = 0;
  4521. u8 dev_num = 0;
  4522. int param_size = 0;
  4523. int ch_configured = 0;
  4524. char wsa_cdc_name[DEV_NAME_STR_LEN];
  4525. struct snd_soc_component *component = NULL;
  4526. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4527. struct msm_asoc_mach_data *pdata =
  4528. snd_soc_card_get_drvdata(rtd->card);
  4529. if (!pdata) {
  4530. pr_err("%s: pdata is NULL\n", __func__);
  4531. return -EINVAL;
  4532. }
  4533. if (!num_ch) {
  4534. pr_err("%s: channel count is 0\n", __func__);
  4535. return -EINVAL;
  4536. }
  4537. if (!pdata->get_wsa_dev_num) {
  4538. pr_err("%s: get_wsa_dev_num is NULL\n", __func__);
  4539. return -EINVAL;
  4540. }
  4541. if (!pdata->cps_config.spkr_dep_cfg) {
  4542. pr_err("%s: spkr_dep_cfg is NULL\n", __func__);
  4543. return -EINVAL;
  4544. }
  4545. if (!pdata->cps_config.hw_reg_cfg.lpass_wr_cmd_reg_phy_addr ||
  4546. !pdata->cps_config.hw_reg_cfg.lpass_rd_cmd_reg_phy_addr ||
  4547. !pdata->cps_config.hw_reg_cfg.lpass_rd_fifo_reg_phy_addr) {
  4548. pr_err("%s: cps static configuration is not set\n", __func__);
  4549. return -EINVAL;
  4550. }
  4551. pdata->cps_config.lpass_hw_intf_cfg_mode = 1;
  4552. while (ch_configured < num_ch) {
  4553. if (!(ch_mask & (1 << i))) {
  4554. i++;
  4555. continue;
  4556. }
  4557. snprintf(wsa_cdc_name, sizeof(wsa_cdc_name), "wsa-codec.%d",
  4558. i+1);
  4559. component = snd_soc_rtdcom_lookup(rtd, wsa_cdc_name);
  4560. if (!component) {
  4561. pr_err("%s: %s component is NULL\n", __func__,
  4562. wsa_cdc_name);
  4563. return -EINVAL;
  4564. }
  4565. dev_num = pdata->get_wsa_dev_num(component);
  4566. if (dev_num < 0 || dev_num > SWR_MAX_SLAVE_DEVICES) {
  4567. pr_err("%s: invalid slave dev num : %d\n", __func__,
  4568. dev_num);
  4569. return -EINVAL;
  4570. }
  4571. /* Clear stale dev num info */
  4572. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr &= 0xFFFF;
  4573. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr &= 0xFFFF;
  4574. val = 0;
  4575. /* bits 20:23 carry swr device number */
  4576. val |= dev_num << 20;
  4577. /* bits 24:27 carry read length in bytes */
  4578. val |= 1 << 24;
  4579. /* Update dev num in packed reg addr */
  4580. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr |= val;
  4581. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr |= val;
  4582. i++;
  4583. ch_configured++;
  4584. }
  4585. param_size = sizeof(struct afe_cps_hw_intf_cfg) -
  4586. sizeof(pdata->cps_config.spkr_dep_cfg) +
  4587. (sizeof(struct lpass_swr_spkr_dep_cfg_t)
  4588. * pdata->cps_config.hw_reg_cfg.num_spkr);
  4589. ret = afe_send_cps_config(msm_get_port_id(dai_link->id),
  4590. &pdata->cps_config, param_size);
  4591. if (ret) {
  4592. pr_err("%s: afe_send_cps_cfg failed\n", __func__);
  4593. }
  4594. return ret;
  4595. }
  4596. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4597. struct snd_pcm_hw_params *params)
  4598. {
  4599. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4600. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4601. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4602. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4603. int ret = 0;
  4604. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4605. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4606. u32 user_set_tx_ch = 0;
  4607. u32 user_set_rx_ch = 0;
  4608. u32 ch_id;
  4609. ret = snd_soc_dai_get_channel_map(codec_dai,
  4610. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4611. &rx_ch_cdc_dma);
  4612. if (ret < 0) {
  4613. pr_err("%s: failed to get codec chan map, err:%d\n",
  4614. __func__, ret);
  4615. goto err;
  4616. }
  4617. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4618. switch (dai_link->id) {
  4619. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4620. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4621. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4622. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4623. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4624. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4625. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  4626. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4627. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  4628. {
  4629. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4630. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4631. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4632. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4633. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4634. user_set_rx_ch, &rx_ch_cdc_dma);
  4635. if (ret < 0) {
  4636. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4637. __func__, ret);
  4638. goto err;
  4639. }
  4640. if (dai_link->id == MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0 ||
  4641. dai_link->id == MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1) {
  4642. send_cps_config(rtd, user_set_rx_ch,
  4643. rx_ch_cdc_dma);
  4644. }
  4645. }
  4646. break;
  4647. }
  4648. } else {
  4649. switch (dai_link->id) {
  4650. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4651. {
  4652. user_set_tx_ch = msm_vi_feed_tx_ch;
  4653. }
  4654. break;
  4655. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4656. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4657. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4658. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4659. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4660. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4661. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4662. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4663. {
  4664. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4665. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4666. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4667. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4668. }
  4669. break;
  4670. }
  4671. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4672. &tx_ch_cdc_dma, 0, 0);
  4673. if (ret < 0) {
  4674. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4675. __func__, ret);
  4676. goto err;
  4677. }
  4678. }
  4679. err:
  4680. return ret;
  4681. }
  4682. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  4683. {
  4684. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  4685. pm_qos_remove_request(&substream->latency_pm_qos_req);
  4686. qos_client_active_cnt++;
  4687. if (qos_client_active_cnt == 1)
  4688. msm_audio_update_qos_request(MSM_LL_QOS_VALUE);
  4689. return 0;
  4690. }
  4691. static void msm_fe_qos_shutdown(struct snd_pcm_substream *substream)
  4692. {
  4693. (void)substream;
  4694. if (qos_client_active_cnt > 0)
  4695. qos_client_active_cnt--;
  4696. if (qos_client_active_cnt == 0)
  4697. msm_audio_update_qos_request(PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE);
  4698. }
  4699. void mi2s_disable_audio_vote(struct snd_pcm_substream *substream)
  4700. {
  4701. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4702. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4703. int index = cpu_dai->id;
  4704. struct snd_soc_card *card = rtd->card;
  4705. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4706. int sample_rate = 0;
  4707. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4708. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4709. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4710. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4711. } else {
  4712. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4713. return;
  4714. }
  4715. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4716. if (pdata->lpass_audio_hw_vote != NULL) {
  4717. if (--pdata->core_audio_vote_count == 0) {
  4718. clk_disable_unprepare(
  4719. pdata->lpass_audio_hw_vote);
  4720. } else if (pdata->core_audio_vote_count < 0) {
  4721. pr_err("%s: audio vote mismatch\n", __func__);
  4722. pdata->core_audio_vote_count = 0;
  4723. }
  4724. } else {
  4725. pr_err("%s: Invalid lpass audio hw node\n", __func__);
  4726. }
  4727. }
  4728. }
  4729. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  4730. {
  4731. int ret = 0;
  4732. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4733. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4734. int index = cpu_dai->id;
  4735. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  4736. struct snd_soc_card *card = rtd->card;
  4737. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4738. int sample_rate = 0;
  4739. dev_dbg(rtd->card->dev,
  4740. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  4741. __func__, substream->name, substream->stream,
  4742. cpu_dai->name, cpu_dai->id);
  4743. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4744. ret = -EINVAL;
  4745. dev_err(rtd->card->dev,
  4746. "%s: CPU DAI id (%d) out of range\n",
  4747. __func__, cpu_dai->id);
  4748. goto err;
  4749. }
  4750. /*
  4751. * Mutex protection in case the same MI2S
  4752. * interface using for both TX and RX so
  4753. * that the same clock won't be enable twice.
  4754. */
  4755. mutex_lock(&mi2s_intf_conf[index].lock);
  4756. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4757. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4758. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4759. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4760. } else {
  4761. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4762. ret = -EINVAL;
  4763. goto vote_err;
  4764. }
  4765. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4766. if (pdata->lpass_audio_hw_vote == NULL) {
  4767. dev_err(rtd->card->dev, "%s: Invalid lpass audio hw node\n",
  4768. __func__);
  4769. ret = -EINVAL;
  4770. goto vote_err;
  4771. }
  4772. if (pdata->core_audio_vote_count == 0) {
  4773. ret = clk_prepare_enable(pdata->lpass_audio_hw_vote);
  4774. if (ret < 0) {
  4775. dev_err(rtd->card->dev, "%s: audio vote error\n",
  4776. __func__);
  4777. goto vote_err;
  4778. }
  4779. }
  4780. pdata->core_audio_vote_count++;
  4781. }
  4782. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  4783. /* Check if msm needs to provide the clock to the interface */
  4784. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  4785. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  4786. fmt = SND_SOC_DAIFMT_CBM_CFM;
  4787. }
  4788. ret = msm_mi2s_set_sclk(substream, true);
  4789. if (ret < 0) {
  4790. dev_err(rtd->card->dev,
  4791. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  4792. __func__, ret);
  4793. goto clean_up;
  4794. }
  4795. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  4796. if (ret < 0) {
  4797. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  4798. __func__, index, ret);
  4799. goto clk_off;
  4800. }
  4801. if (pdata->mi2s_gpio_p[index]) {
  4802. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4803. == 0) {
  4804. ret = msm_cdc_pinctrl_select_active_state(
  4805. pdata->mi2s_gpio_p[index]);
  4806. if (ret) {
  4807. pr_err("%s: MI2S GPIO pinctrl set active failed with %d\n",
  4808. __func__, ret);
  4809. goto clk_off;
  4810. }
  4811. }
  4812. atomic_inc(&(pdata->mi2s_gpio_ref_count[index]));
  4813. }
  4814. }
  4815. clk_off:
  4816. if (ret < 0)
  4817. msm_mi2s_set_sclk(substream, false);
  4818. clean_up:
  4819. if (ret < 0) {
  4820. mi2s_intf_conf[index].ref_cnt--;
  4821. mi2s_disable_audio_vote(substream);
  4822. }
  4823. vote_err:
  4824. mutex_unlock(&mi2s_intf_conf[index].lock);
  4825. err:
  4826. return ret;
  4827. }
  4828. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  4829. {
  4830. int ret = 0;
  4831. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4832. int index = rtd->cpu_dai->id;
  4833. struct snd_soc_card *card = rtd->card;
  4834. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4835. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  4836. substream->name, substream->stream);
  4837. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4838. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  4839. return;
  4840. }
  4841. mutex_lock(&mi2s_intf_conf[index].lock);
  4842. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  4843. if (pdata->mi2s_gpio_p[index]) {
  4844. atomic_dec(&(pdata->mi2s_gpio_ref_count[index]));
  4845. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4846. == 0) {
  4847. ret = msm_cdc_pinctrl_select_sleep_state(
  4848. pdata->mi2s_gpio_p[index]);
  4849. if (ret)
  4850. pr_err("%s: MI2S GPIO pinctrl set sleep failed with %d\n",
  4851. __func__, ret);
  4852. }
  4853. }
  4854. ret = msm_mi2s_set_sclk(substream, false);
  4855. if (ret < 0)
  4856. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  4857. __func__, index, ret);
  4858. }
  4859. mi2s_disable_audio_vote(substream);
  4860. mutex_unlock(&mi2s_intf_conf[index].lock);
  4861. }
  4862. static int msm_wcn_hw_params_lito(struct snd_pcm_substream *substream,
  4863. struct snd_pcm_hw_params *params)
  4864. {
  4865. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4866. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4867. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4868. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4869. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO];
  4870. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4871. int ret = 0;
  4872. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4873. codec_dai->name, codec_dai->id);
  4874. ret = snd_soc_dai_get_channel_map(codec_dai,
  4875. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4876. if (ret) {
  4877. dev_err(rtd->dev,
  4878. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4879. __func__, ret);
  4880. goto err;
  4881. }
  4882. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4883. __func__, tx_ch_cnt, dai_link->id);
  4884. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4885. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4886. if (ret)
  4887. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4888. __func__, ret);
  4889. err:
  4890. return ret;
  4891. }
  4892. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4893. struct snd_pcm_hw_params *params)
  4894. {
  4895. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4896. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4897. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4898. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4899. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4900. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4901. int ret = 0;
  4902. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4903. codec_dai->name, codec_dai->id);
  4904. ret = snd_soc_dai_get_channel_map(codec_dai,
  4905. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4906. if (ret) {
  4907. dev_err(rtd->dev,
  4908. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4909. __func__, ret);
  4910. goto err;
  4911. }
  4912. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4913. __func__, tx_ch_cnt, dai_link->id);
  4914. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4915. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4916. if (ret)
  4917. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4918. __func__, ret);
  4919. err:
  4920. return ret;
  4921. }
  4922. static struct snd_soc_ops lahaina_aux_be_ops = {
  4923. .startup = lahaina_aux_snd_startup,
  4924. .shutdown = lahaina_aux_snd_shutdown
  4925. };
  4926. static struct snd_soc_ops lahaina_tdm_be_ops = {
  4927. .hw_params = lahaina_tdm_snd_hw_params,
  4928. .startup = lahaina_tdm_snd_startup,
  4929. .shutdown = lahaina_tdm_snd_shutdown
  4930. };
  4931. static struct snd_soc_ops msm_mi2s_be_ops = {
  4932. .startup = msm_mi2s_snd_startup,
  4933. .shutdown = msm_mi2s_snd_shutdown,
  4934. };
  4935. static struct snd_soc_ops msm_fe_qos_ops = {
  4936. .prepare = msm_fe_qos_prepare,
  4937. .shutdown = msm_fe_qos_shutdown,
  4938. };
  4939. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  4940. .startup = msm_snd_cdc_dma_startup,
  4941. .hw_params = msm_snd_cdc_dma_hw_params,
  4942. };
  4943. static struct snd_soc_ops msm_wcn_ops = {
  4944. .hw_params = msm_wcn_hw_params,
  4945. };
  4946. static struct snd_soc_ops msm_wcn_ops_lito = {
  4947. .hw_params = msm_wcn_hw_params_lito,
  4948. };
  4949. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  4950. struct snd_kcontrol *kcontrol, int event)
  4951. {
  4952. struct msm_asoc_mach_data *pdata = NULL;
  4953. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  4954. int ret = 0;
  4955. u32 dmic_idx;
  4956. int *dmic_gpio_cnt;
  4957. struct device_node *dmic_gpio;
  4958. char *wname;
  4959. wname = strpbrk(w->name, "012345");
  4960. if (!wname) {
  4961. dev_err(component->dev, "%s: widget not found\n", __func__);
  4962. return -EINVAL;
  4963. }
  4964. ret = kstrtouint(wname, 10, &dmic_idx);
  4965. if (ret < 0) {
  4966. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  4967. __func__);
  4968. return -EINVAL;
  4969. }
  4970. pdata = snd_soc_card_get_drvdata(component->card);
  4971. switch (dmic_idx) {
  4972. case 0:
  4973. case 1:
  4974. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  4975. dmic_gpio = pdata->dmic01_gpio_p;
  4976. break;
  4977. case 2:
  4978. case 3:
  4979. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  4980. dmic_gpio = pdata->dmic23_gpio_p;
  4981. break;
  4982. case 4:
  4983. case 5:
  4984. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  4985. dmic_gpio = pdata->dmic45_gpio_p;
  4986. break;
  4987. default:
  4988. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  4989. __func__);
  4990. return -EINVAL;
  4991. }
  4992. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  4993. __func__, event, dmic_idx, *dmic_gpio_cnt);
  4994. switch (event) {
  4995. case SND_SOC_DAPM_PRE_PMU:
  4996. (*dmic_gpio_cnt)++;
  4997. if (*dmic_gpio_cnt == 1) {
  4998. ret = msm_cdc_pinctrl_select_active_state(
  4999. dmic_gpio);
  5000. if (ret < 0) {
  5001. pr_err("%s: gpio set cannot be activated %sd",
  5002. __func__, "dmic_gpio");
  5003. return ret;
  5004. }
  5005. }
  5006. break;
  5007. case SND_SOC_DAPM_POST_PMD:
  5008. (*dmic_gpio_cnt)--;
  5009. if (*dmic_gpio_cnt == 0) {
  5010. ret = msm_cdc_pinctrl_select_sleep_state(
  5011. dmic_gpio);
  5012. if (ret < 0) {
  5013. pr_err("%s: gpio set cannot be de-activated %sd",
  5014. __func__, "dmic_gpio");
  5015. return ret;
  5016. }
  5017. }
  5018. break;
  5019. default:
  5020. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  5021. return -EINVAL;
  5022. }
  5023. return 0;
  5024. }
  5025. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  5026. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  5027. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  5028. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  5029. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  5030. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  5031. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  5032. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  5033. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  5034. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  5035. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  5036. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  5037. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  5038. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  5039. };
  5040. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  5041. {
  5042. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  5043. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  5044. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  5045. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  5046. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  5047. }
  5048. static int msm_wcn_init_lito(struct snd_soc_pcm_runtime *rtd)
  5049. {
  5050. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  5051. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO] = {159, 160, 161};
  5052. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  5053. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  5054. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  5055. }
  5056. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  5057. const char *name,
  5058. struct snd_info_entry *parent)
  5059. {
  5060. struct snd_info_entry *entry;
  5061. entry = snd_info_create_module_entry(mod, name, parent);
  5062. if (!entry)
  5063. return NULL;
  5064. entry->mode = S_IFDIR | 0555;
  5065. if (snd_info_register(entry) < 0) {
  5066. snd_info_free_entry(entry);
  5067. return NULL;
  5068. }
  5069. return entry;
  5070. }
  5071. static void *def_wcd_mbhc_cal(void)
  5072. {
  5073. void *wcd_mbhc_cal;
  5074. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  5075. u16 *btn_high;
  5076. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  5077. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  5078. if (!wcd_mbhc_cal)
  5079. return NULL;
  5080. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  5081. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  5082. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  5083. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  5084. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  5085. btn_high[0] = 75;
  5086. btn_high[1] = 150;
  5087. btn_high[2] = 237;
  5088. btn_high[3] = 500;
  5089. btn_high[4] = 500;
  5090. btn_high[5] = 500;
  5091. btn_high[6] = 500;
  5092. btn_high[7] = 500;
  5093. return wcd_mbhc_cal;
  5094. }
  5095. /* Digital audio interface glue - connects codec <---> CPU */
  5096. static struct snd_soc_dai_link msm_common_dai_links[] = {
  5097. /* FrontEnd DAI Links */
  5098. {/* hw:x,0 */
  5099. .name = MSM_DAILINK_NAME(Media1),
  5100. .stream_name = "MultiMedia1",
  5101. .dynamic = 1,
  5102. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5103. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5104. #endif /* CONFIG_AUDIO_QGKI */
  5105. .dpcm_playback = 1,
  5106. .dpcm_capture = 1,
  5107. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5108. SND_SOC_DPCM_TRIGGER_POST},
  5109. .ignore_suspend = 1,
  5110. /* this dainlink has playback support */
  5111. .ignore_pmdown_time = 1,
  5112. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  5113. SND_SOC_DAILINK_REG(multimedia1),
  5114. },
  5115. {/* hw:x,1 */
  5116. .name = MSM_DAILINK_NAME(Media2),
  5117. .stream_name = "MultiMedia2",
  5118. .dynamic = 1,
  5119. .dpcm_playback = 1,
  5120. .dpcm_capture = 1,
  5121. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5122. SND_SOC_DPCM_TRIGGER_POST},
  5123. .ignore_suspend = 1,
  5124. /* this dainlink has playback support */
  5125. .ignore_pmdown_time = 1,
  5126. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  5127. SND_SOC_DAILINK_REG(multimedia2),
  5128. },
  5129. {/* hw:x,2 */
  5130. .name = "VoiceMMode1",
  5131. .stream_name = "VoiceMMode1",
  5132. .dynamic = 1,
  5133. .dpcm_playback = 1,
  5134. .dpcm_capture = 1,
  5135. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5136. SND_SOC_DPCM_TRIGGER_POST},
  5137. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5138. .ignore_suspend = 1,
  5139. .ignore_pmdown_time = 1,
  5140. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  5141. SND_SOC_DAILINK_REG(voicemmode1),
  5142. },
  5143. {/* hw:x,3 */
  5144. .name = "MSM VoIP",
  5145. .stream_name = "VoIP",
  5146. .dynamic = 1,
  5147. .dpcm_playback = 1,
  5148. .dpcm_capture = 1,
  5149. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5150. SND_SOC_DPCM_TRIGGER_POST},
  5151. .ignore_suspend = 1,
  5152. /* this dainlink has playback support */
  5153. .ignore_pmdown_time = 1,
  5154. .id = MSM_FRONTEND_DAI_VOIP,
  5155. SND_SOC_DAILINK_REG(msmvoip),
  5156. },
  5157. {/* hw:x,4 */
  5158. .name = MSM_DAILINK_NAME(ULL),
  5159. .stream_name = "MultiMedia3",
  5160. .dynamic = 1,
  5161. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5162. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5163. #endif /* CONFIG_AUDIO_QGKI */
  5164. .dpcm_playback = 1,
  5165. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5166. SND_SOC_DPCM_TRIGGER_POST},
  5167. .ignore_suspend = 1,
  5168. /* this dainlink has playback support */
  5169. .ignore_pmdown_time = 1,
  5170. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  5171. SND_SOC_DAILINK_REG(multimedia3),
  5172. },
  5173. {/* hw:x,5 */
  5174. .name = "MSM AFE-PCM RX",
  5175. .stream_name = "AFE-PROXY RX",
  5176. .dpcm_playback = 1,
  5177. .ignore_suspend = 1,
  5178. /* this dainlink has playback support */
  5179. .ignore_pmdown_time = 1,
  5180. SND_SOC_DAILINK_REG(afepcm_rx),
  5181. },
  5182. {/* hw:x,6 */
  5183. .name = "MSM AFE-PCM TX",
  5184. .stream_name = "AFE-PROXY TX",
  5185. .dpcm_capture = 1,
  5186. .ignore_suspend = 1,
  5187. SND_SOC_DAILINK_REG(afepcm_tx),
  5188. },
  5189. {/* hw:x,7 */
  5190. .name = MSM_DAILINK_NAME(Compress1),
  5191. .stream_name = "Compress1",
  5192. .dynamic = 1,
  5193. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5194. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  5195. #endif /* CONFIG_AUDIO_QGKI */
  5196. .dpcm_playback = 1,
  5197. .dpcm_capture = 1,
  5198. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5199. SND_SOC_DPCM_TRIGGER_POST},
  5200. .ignore_suspend = 1,
  5201. .ignore_pmdown_time = 1,
  5202. /* this dainlink has playback support */
  5203. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  5204. SND_SOC_DAILINK_REG(multimedia4),
  5205. },
  5206. /* Hostless PCM purpose */
  5207. {/* hw:x,8 */
  5208. .name = "AUXPCM Hostless",
  5209. .stream_name = "AUXPCM Hostless",
  5210. .dynamic = 1,
  5211. .dpcm_playback = 1,
  5212. .dpcm_capture = 1,
  5213. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5214. SND_SOC_DPCM_TRIGGER_POST},
  5215. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5216. .ignore_suspend = 1,
  5217. /* this dainlink has playback support */
  5218. .ignore_pmdown_time = 1,
  5219. SND_SOC_DAILINK_REG(auxpcm_hostless),
  5220. },
  5221. {/* hw:x,9 */
  5222. .name = MSM_DAILINK_NAME(LowLatency),
  5223. .stream_name = "MultiMedia5",
  5224. .dynamic = 1,
  5225. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5226. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5227. #endif /* CONFIG_AUDIO_QGKI */
  5228. .dpcm_playback = 1,
  5229. .dpcm_capture = 1,
  5230. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5231. SND_SOC_DPCM_TRIGGER_POST},
  5232. .ignore_suspend = 1,
  5233. /* this dainlink has playback support */
  5234. .ignore_pmdown_time = 1,
  5235. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  5236. .ops = &msm_fe_qos_ops,
  5237. SND_SOC_DAILINK_REG(multimedia5),
  5238. },
  5239. {/* hw:x,10 */
  5240. .name = "Listen 1 Audio Service",
  5241. .stream_name = "Listen 1 Audio Service",
  5242. .dynamic = 1,
  5243. .dpcm_capture = 1,
  5244. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5245. SND_SOC_DPCM_TRIGGER_POST },
  5246. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5247. .ignore_suspend = 1,
  5248. .id = MSM_FRONTEND_DAI_LSM1,
  5249. SND_SOC_DAILINK_REG(listen1),
  5250. },
  5251. /* Multiple Tunnel instances */
  5252. {/* hw:x,11 */
  5253. .name = MSM_DAILINK_NAME(Compress2),
  5254. .stream_name = "Compress2",
  5255. .dynamic = 1,
  5256. .dpcm_playback = 1,
  5257. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5258. SND_SOC_DPCM_TRIGGER_POST},
  5259. .ignore_suspend = 1,
  5260. .ignore_pmdown_time = 1,
  5261. /* this dainlink has playback support */
  5262. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  5263. SND_SOC_DAILINK_REG(multimedia7),
  5264. },
  5265. {/* hw:x,12 */
  5266. .name = MSM_DAILINK_NAME(MultiMedia10),
  5267. .stream_name = "MultiMedia10",
  5268. .dynamic = 1,
  5269. .dpcm_playback = 1,
  5270. .dpcm_capture = 1,
  5271. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5272. SND_SOC_DPCM_TRIGGER_POST},
  5273. .ignore_suspend = 1,
  5274. .ignore_pmdown_time = 1,
  5275. /* this dainlink has playback support */
  5276. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5277. SND_SOC_DAILINK_REG(multimedia10),
  5278. },
  5279. {/* hw:x,13 */
  5280. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  5281. .stream_name = "MM_NOIRQ",
  5282. .dynamic = 1,
  5283. .dpcm_playback = 1,
  5284. .dpcm_capture = 1,
  5285. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5286. SND_SOC_DPCM_TRIGGER_POST},
  5287. .ignore_suspend = 1,
  5288. .ignore_pmdown_time = 1,
  5289. /* this dainlink has playback support */
  5290. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  5291. .ops = &msm_fe_qos_ops,
  5292. SND_SOC_DAILINK_REG(multimedia8),
  5293. },
  5294. /* HDMI Hostless */
  5295. {/* hw:x,14 */
  5296. .name = "HDMI_RX_HOSTLESS",
  5297. .stream_name = "HDMI_RX_HOSTLESS",
  5298. .dynamic = 1,
  5299. .dpcm_playback = 1,
  5300. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5301. SND_SOC_DPCM_TRIGGER_POST},
  5302. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5303. .ignore_suspend = 1,
  5304. .ignore_pmdown_time = 1,
  5305. SND_SOC_DAILINK_REG(hdmi_rx_hostless),
  5306. },
  5307. {/* hw:x,15 */
  5308. .name = "VoiceMMode2",
  5309. .stream_name = "VoiceMMode2",
  5310. .dynamic = 1,
  5311. .dpcm_playback = 1,
  5312. .dpcm_capture = 1,
  5313. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5314. SND_SOC_DPCM_TRIGGER_POST},
  5315. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5316. .ignore_suspend = 1,
  5317. .ignore_pmdown_time = 1,
  5318. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  5319. SND_SOC_DAILINK_REG(voicemmode2),
  5320. },
  5321. /* LSM FE */
  5322. {/* hw:x,16 */
  5323. .name = "Listen 2 Audio Service",
  5324. .stream_name = "Listen 2 Audio Service",
  5325. .dynamic = 1,
  5326. .dpcm_capture = 1,
  5327. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5328. SND_SOC_DPCM_TRIGGER_POST },
  5329. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5330. .ignore_suspend = 1,
  5331. .id = MSM_FRONTEND_DAI_LSM2,
  5332. SND_SOC_DAILINK_REG(listen2),
  5333. },
  5334. {/* hw:x,17 */
  5335. .name = "Listen 3 Audio Service",
  5336. .stream_name = "Listen 3 Audio Service",
  5337. .dynamic = 1,
  5338. .dpcm_capture = 1,
  5339. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5340. SND_SOC_DPCM_TRIGGER_POST },
  5341. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5342. .ignore_suspend = 1,
  5343. .id = MSM_FRONTEND_DAI_LSM3,
  5344. SND_SOC_DAILINK_REG(listen3),
  5345. },
  5346. {/* hw:x,18 */
  5347. .name = "Listen 4 Audio Service",
  5348. .stream_name = "Listen 4 Audio Service",
  5349. .dynamic = 1,
  5350. .dpcm_capture = 1,
  5351. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5352. SND_SOC_DPCM_TRIGGER_POST },
  5353. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5354. .ignore_suspend = 1,
  5355. .id = MSM_FRONTEND_DAI_LSM4,
  5356. SND_SOC_DAILINK_REG(listen4),
  5357. },
  5358. {/* hw:x,19 */
  5359. .name = "Listen 5 Audio Service",
  5360. .stream_name = "Listen 5 Audio Service",
  5361. .dynamic = 1,
  5362. .dpcm_capture = 1,
  5363. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5364. SND_SOC_DPCM_TRIGGER_POST },
  5365. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5366. .ignore_suspend = 1,
  5367. .id = MSM_FRONTEND_DAI_LSM5,
  5368. SND_SOC_DAILINK_REG(listen5),
  5369. },
  5370. {/* hw:x,20 */
  5371. .name = "Listen 6 Audio Service",
  5372. .stream_name = "Listen 6 Audio Service",
  5373. .dynamic = 1,
  5374. .dpcm_capture = 1,
  5375. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5376. SND_SOC_DPCM_TRIGGER_POST },
  5377. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5378. .ignore_suspend = 1,
  5379. .id = MSM_FRONTEND_DAI_LSM6,
  5380. SND_SOC_DAILINK_REG(listen6),
  5381. },
  5382. {/* hw:x,21 */
  5383. .name = "Listen 7 Audio Service",
  5384. .stream_name = "Listen 7 Audio Service",
  5385. .dynamic = 1,
  5386. .dpcm_capture = 1,
  5387. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5388. SND_SOC_DPCM_TRIGGER_POST },
  5389. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5390. .ignore_suspend = 1,
  5391. .id = MSM_FRONTEND_DAI_LSM7,
  5392. SND_SOC_DAILINK_REG(listen7),
  5393. },
  5394. {/* hw:x,22 */
  5395. .name = "Listen 8 Audio Service",
  5396. .stream_name = "Listen 8 Audio Service",
  5397. .dynamic = 1,
  5398. .dpcm_capture = 1,
  5399. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5400. SND_SOC_DPCM_TRIGGER_POST },
  5401. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5402. .ignore_suspend = 1,
  5403. .id = MSM_FRONTEND_DAI_LSM8,
  5404. SND_SOC_DAILINK_REG(listen8),
  5405. },
  5406. {/* hw:x,23 */
  5407. .name = MSM_DAILINK_NAME(Media9),
  5408. .stream_name = "MultiMedia9",
  5409. .dynamic = 1,
  5410. .dpcm_playback = 1,
  5411. .dpcm_capture = 1,
  5412. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5413. SND_SOC_DPCM_TRIGGER_POST},
  5414. .ignore_suspend = 1,
  5415. /* this dainlink has playback support */
  5416. .ignore_pmdown_time = 1,
  5417. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  5418. SND_SOC_DAILINK_REG(multimedia9),
  5419. },
  5420. {/* hw:x,24 */
  5421. .name = MSM_DAILINK_NAME(Compress4),
  5422. .stream_name = "Compress4",
  5423. .dynamic = 1,
  5424. .dpcm_playback = 1,
  5425. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5426. SND_SOC_DPCM_TRIGGER_POST},
  5427. .ignore_suspend = 1,
  5428. .ignore_pmdown_time = 1,
  5429. /* this dainlink has playback support */
  5430. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  5431. SND_SOC_DAILINK_REG(multimedia11),
  5432. },
  5433. {/* hw:x,25 */
  5434. .name = MSM_DAILINK_NAME(Compress5),
  5435. .stream_name = "Compress5",
  5436. .dynamic = 1,
  5437. .dpcm_playback = 1,
  5438. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5439. SND_SOC_DPCM_TRIGGER_POST},
  5440. .ignore_suspend = 1,
  5441. .ignore_pmdown_time = 1,
  5442. /* this dainlink has playback support */
  5443. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  5444. SND_SOC_DAILINK_REG(multimedia12),
  5445. },
  5446. {/* hw:x,26 */
  5447. .name = MSM_DAILINK_NAME(Compress6),
  5448. .stream_name = "Compress6",
  5449. .dynamic = 1,
  5450. .dpcm_playback = 1,
  5451. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5452. SND_SOC_DPCM_TRIGGER_POST},
  5453. .ignore_suspend = 1,
  5454. .ignore_pmdown_time = 1,
  5455. /* this dainlink has playback support */
  5456. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  5457. SND_SOC_DAILINK_REG(multimedia13),
  5458. },
  5459. {/* hw:x,27 */
  5460. .name = MSM_DAILINK_NAME(Compress7),
  5461. .stream_name = "Compress7",
  5462. .dynamic = 1,
  5463. .dpcm_playback = 1,
  5464. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5465. SND_SOC_DPCM_TRIGGER_POST},
  5466. .ignore_suspend = 1,
  5467. .ignore_pmdown_time = 1,
  5468. /* this dainlink has playback support */
  5469. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  5470. SND_SOC_DAILINK_REG(multimedia14),
  5471. },
  5472. {/* hw:x,28 */
  5473. .name = MSM_DAILINK_NAME(Compress8),
  5474. .stream_name = "Compress8",
  5475. .dynamic = 1,
  5476. .dpcm_playback = 1,
  5477. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5478. SND_SOC_DPCM_TRIGGER_POST},
  5479. .ignore_suspend = 1,
  5480. .ignore_pmdown_time = 1,
  5481. /* this dainlink has playback support */
  5482. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  5483. SND_SOC_DAILINK_REG(multimedia15),
  5484. },
  5485. {/* hw:x,29 */
  5486. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  5487. .stream_name = "MM_NOIRQ_2",
  5488. .dynamic = 1,
  5489. .dpcm_playback = 1,
  5490. .dpcm_capture = 1,
  5491. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5492. SND_SOC_DPCM_TRIGGER_POST},
  5493. .ignore_suspend = 1,
  5494. .ignore_pmdown_time = 1,
  5495. /* this dainlink has playback support */
  5496. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  5497. .ops = &msm_fe_qos_ops,
  5498. SND_SOC_DAILINK_REG(multimedia16),
  5499. },
  5500. {/* hw:x,30 */
  5501. .name = "CDC_DMA Hostless",
  5502. .stream_name = "CDC_DMA Hostless",
  5503. .dynamic = 1,
  5504. .dpcm_playback = 1,
  5505. .dpcm_capture = 1,
  5506. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5507. SND_SOC_DPCM_TRIGGER_POST},
  5508. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5509. .ignore_suspend = 1,
  5510. /* this dailink has playback support */
  5511. .ignore_pmdown_time = 1,
  5512. SND_SOC_DAILINK_REG(cdcdma_hostless),
  5513. },
  5514. {/* hw:x,31 */
  5515. .name = "TX3_CDC_DMA Hostless",
  5516. .stream_name = "TX3_CDC_DMA Hostless",
  5517. .dynamic = 1,
  5518. .dpcm_capture = 1,
  5519. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5520. SND_SOC_DPCM_TRIGGER_POST},
  5521. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5522. .ignore_suspend = 1,
  5523. SND_SOC_DAILINK_REG(tx3_cdcdma_hostless),
  5524. },
  5525. {/* hw:x,32 */
  5526. .name = "Tertiary MI2S TX_Hostless",
  5527. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  5528. .dynamic = 1,
  5529. .dpcm_capture = 1,
  5530. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5531. SND_SOC_DPCM_TRIGGER_POST},
  5532. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5533. .ignore_suspend = 1,
  5534. .ignore_pmdown_time = 1,
  5535. SND_SOC_DAILINK_REG(tert_mi2s_tx_hostless),
  5536. },
  5537. };
  5538. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  5539. {/* hw:x,33 */
  5540. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5541. .stream_name = "WSA CDC DMA0 Capture",
  5542. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5543. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5544. .ignore_suspend = 1,
  5545. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5546. .ops = &msm_cdc_dma_be_ops,
  5547. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture),
  5548. },
  5549. };
  5550. static struct snd_soc_dai_link msm_bolero_fe_stub_dai_links[] = {
  5551. {/* hw:x,33 */
  5552. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5553. .stream_name = "WSA CDC DMA0 Capture",
  5554. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5555. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5556. .ignore_suspend = 1,
  5557. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5558. .ops = &msm_cdc_dma_be_ops,
  5559. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture_stub),
  5560. },
  5561. };
  5562. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  5563. {/* hw:x,34 */
  5564. .name = MSM_DAILINK_NAME(ASM Loopback),
  5565. .stream_name = "MultiMedia6",
  5566. .dynamic = 1,
  5567. .dpcm_playback = 1,
  5568. .dpcm_capture = 1,
  5569. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5570. SND_SOC_DPCM_TRIGGER_POST},
  5571. .ignore_suspend = 1,
  5572. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5573. .ignore_pmdown_time = 1,
  5574. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  5575. SND_SOC_DAILINK_REG(multimedia6),
  5576. },
  5577. {/* hw:x,35 */
  5578. .name = "USB Audio Hostless",
  5579. .stream_name = "USB Audio Hostless",
  5580. .dynamic = 1,
  5581. .dpcm_playback = 1,
  5582. .dpcm_capture = 1,
  5583. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5584. SND_SOC_DPCM_TRIGGER_POST},
  5585. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5586. .ignore_suspend = 1,
  5587. .ignore_pmdown_time = 1,
  5588. SND_SOC_DAILINK_REG(usbaudio_hostless),
  5589. },
  5590. {/* hw:x,36 */
  5591. .name = "SLIMBUS_7 Hostless",
  5592. .stream_name = "SLIMBUS_7 Hostless",
  5593. .dynamic = 1,
  5594. .dpcm_capture = 1,
  5595. .dpcm_playback = 1,
  5596. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5597. SND_SOC_DPCM_TRIGGER_POST},
  5598. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5599. .ignore_suspend = 1,
  5600. .ignore_pmdown_time = 1,
  5601. SND_SOC_DAILINK_REG(slimbus7_hostless),
  5602. },
  5603. {/* hw:x,37 */
  5604. .name = "Compress Capture",
  5605. .stream_name = "Compress9",
  5606. .dynamic = 1,
  5607. .dpcm_capture = 1,
  5608. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5609. SND_SOC_DPCM_TRIGGER_POST},
  5610. .ignore_suspend = 1,
  5611. .ignore_pmdown_time = 1,
  5612. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5613. SND_SOC_DAILINK_REG(multimedia17),
  5614. },
  5615. {/* hw:x,38 */
  5616. .name = "SLIMBUS_8 Hostless",
  5617. .stream_name = "SLIMBUS_8 Hostless",
  5618. .dynamic = 1,
  5619. .dpcm_capture = 1,
  5620. .dpcm_playback = 1,
  5621. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5622. SND_SOC_DPCM_TRIGGER_POST},
  5623. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5624. .ignore_suspend = 1,
  5625. .ignore_pmdown_time = 1,
  5626. SND_SOC_DAILINK_REG(slimbus8_hostless),
  5627. },
  5628. {/* hw:x,39 */
  5629. .name = LPASS_BE_TX_CDC_DMA_TX_5,
  5630. .stream_name = "TX CDC DMA5 Capture",
  5631. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_5,
  5632. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5633. .ignore_suspend = 1,
  5634. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5635. .ops = &msm_cdc_dma_be_ops,
  5636. SND_SOC_DAILINK_REG(tx_cdcdma5_tx),
  5637. },
  5638. {/* hw:x,40 */
  5639. .name = MSM_DAILINK_NAME(Media31),
  5640. .stream_name = "MultiMedia31",
  5641. .dynamic = 1,
  5642. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5643. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5644. #endif /* CONFIG_AUDIO_QGKI */
  5645. .dpcm_playback = 1,
  5646. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5647. SND_SOC_DPCM_TRIGGER_POST},
  5648. .ignore_suspend = 1,
  5649. /* this dainlink has playback support */
  5650. .ignore_pmdown_time = 1,
  5651. .id = MSM_FRONTEND_DAI_MULTIMEDIA31,
  5652. SND_SOC_DAILINK_REG(multimedia31),
  5653. },
  5654. {/* hw:x,41 */
  5655. .name = MSM_DAILINK_NAME(Media32),
  5656. .stream_name = "MultiMedia32",
  5657. .dynamic = 1,
  5658. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5659. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5660. #endif /* CONFIG_AUDIO_QGKI */
  5661. .dpcm_playback = 1,
  5662. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5663. SND_SOC_DPCM_TRIGGER_POST},
  5664. .ignore_suspend = 1,
  5665. /* this dainlink has playback support */
  5666. .ignore_pmdown_time = 1,
  5667. .id = MSM_FRONTEND_DAI_MULTIMEDIA32,
  5668. SND_SOC_DAILINK_REG(multimedia32),
  5669. },
  5670. {/* hw:x,42 */
  5671. .name = "MSM AFE-PCM TX1",
  5672. .stream_name = "AFE-PROXY TX1",
  5673. .dpcm_capture = 1,
  5674. .ignore_suspend = 1,
  5675. SND_SOC_DAILINK_REG(afepcm_tx1),
  5676. },
  5677. {/* hw:x,43 */
  5678. .name = MSM_DAILINK_NAME(Compress3),
  5679. .stream_name = "Compress3",
  5680. .dynamic = 1,
  5681. .dpcm_playback = 1,
  5682. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5683. SND_SOC_DPCM_TRIGGER_POST},
  5684. .ignore_suspend = 1,
  5685. .ignore_pmdown_time = 1,
  5686. /* this dainlink has playback support */
  5687. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5688. SND_SOC_DAILINK_REG(multimedia10),
  5689. },
  5690. };
  5691. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  5692. /* Backend AFE DAI Links */
  5693. {
  5694. .name = LPASS_BE_AFE_PCM_RX,
  5695. .stream_name = "AFE Playback",
  5696. .no_pcm = 1,
  5697. .dpcm_playback = 1,
  5698. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  5699. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5700. /* this dainlink has playback support */
  5701. .ignore_pmdown_time = 1,
  5702. .ignore_suspend = 1,
  5703. SND_SOC_DAILINK_REG(afe_pcm_rx),
  5704. },
  5705. {
  5706. .name = LPASS_BE_AFE_PCM_TX,
  5707. .stream_name = "AFE Capture",
  5708. .no_pcm = 1,
  5709. .dpcm_capture = 1,
  5710. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  5711. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5712. .ignore_suspend = 1,
  5713. SND_SOC_DAILINK_REG(afe_pcm_tx),
  5714. },
  5715. /* Incall Record Uplink BACK END DAI Link */
  5716. {
  5717. .name = LPASS_BE_INCALL_RECORD_TX,
  5718. .stream_name = "Voice Uplink Capture",
  5719. .no_pcm = 1,
  5720. .dpcm_capture = 1,
  5721. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  5722. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5723. .ignore_suspend = 1,
  5724. SND_SOC_DAILINK_REG(incall_record_tx),
  5725. },
  5726. /* Incall Record Downlink BACK END DAI Link */
  5727. {
  5728. .name = LPASS_BE_INCALL_RECORD_RX,
  5729. .stream_name = "Voice Downlink Capture",
  5730. .no_pcm = 1,
  5731. .dpcm_capture = 1,
  5732. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  5733. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5734. .ignore_suspend = 1,
  5735. SND_SOC_DAILINK_REG(incall_record_rx),
  5736. },
  5737. /* Incall Music BACK END DAI Link */
  5738. {
  5739. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  5740. .stream_name = "Voice Farend Playback",
  5741. .no_pcm = 1,
  5742. .dpcm_playback = 1,
  5743. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  5744. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5745. .ignore_suspend = 1,
  5746. .ignore_pmdown_time = 1,
  5747. SND_SOC_DAILINK_REG(voice_playback_tx),
  5748. },
  5749. /* Incall Music 2 BACK END DAI Link */
  5750. {
  5751. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  5752. .stream_name = "Voice2 Farend Playback",
  5753. .no_pcm = 1,
  5754. .dpcm_playback = 1,
  5755. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  5756. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5757. .ignore_suspend = 1,
  5758. .ignore_pmdown_time = 1,
  5759. SND_SOC_DAILINK_REG(voice2_playback_tx),
  5760. },
  5761. /* Proxy Tx BACK END DAI Link */
  5762. {
  5763. .name = LPASS_BE_PROXY_TX,
  5764. .stream_name = "Proxy Capture",
  5765. .no_pcm = 1,
  5766. .dpcm_capture = 1,
  5767. .id = MSM_BACKEND_DAI_PROXY_TX,
  5768. .ignore_suspend = 1,
  5769. SND_SOC_DAILINK_REG(proxy_tx),
  5770. },
  5771. /* Proxy Rx BACK END DAI Link */
  5772. {
  5773. .name = LPASS_BE_PROXY_RX,
  5774. .stream_name = "Proxy Playback",
  5775. .no_pcm = 1,
  5776. .dpcm_playback = 1,
  5777. .id = MSM_BACKEND_DAI_PROXY_RX,
  5778. .ignore_pmdown_time = 1,
  5779. .ignore_suspend = 1,
  5780. SND_SOC_DAILINK_REG(proxy_rx),
  5781. },
  5782. {
  5783. .name = LPASS_BE_USB_AUDIO_RX,
  5784. .stream_name = "USB Audio Playback",
  5785. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5786. .dynamic_be = 1,
  5787. #endif /* CONFIG_AUDIO_QGKI */
  5788. .no_pcm = 1,
  5789. .dpcm_playback = 1,
  5790. .id = MSM_BACKEND_DAI_USB_RX,
  5791. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5792. .ignore_pmdown_time = 1,
  5793. .ignore_suspend = 1,
  5794. SND_SOC_DAILINK_REG(usb_audio_rx),
  5795. },
  5796. {
  5797. .name = LPASS_BE_USB_AUDIO_TX,
  5798. .stream_name = "USB Audio Capture",
  5799. .no_pcm = 1,
  5800. .dpcm_capture = 1,
  5801. .id = MSM_BACKEND_DAI_USB_TX,
  5802. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5803. .ignore_suspend = 1,
  5804. SND_SOC_DAILINK_REG(usb_audio_tx),
  5805. },
  5806. {
  5807. .name = LPASS_BE_PRI_TDM_RX_0,
  5808. .stream_name = "Primary TDM0 Playback",
  5809. .no_pcm = 1,
  5810. .dpcm_playback = 1,
  5811. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  5812. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5813. .ops = &lahaina_tdm_be_ops,
  5814. .ignore_suspend = 1,
  5815. .ignore_pmdown_time = 1,
  5816. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  5817. },
  5818. {
  5819. .name = LPASS_BE_PRI_TDM_TX_0,
  5820. .stream_name = "Primary TDM0 Capture",
  5821. .no_pcm = 1,
  5822. .dpcm_capture = 1,
  5823. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  5824. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5825. .ops = &lahaina_tdm_be_ops,
  5826. .ignore_suspend = 1,
  5827. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  5828. },
  5829. {
  5830. .name = LPASS_BE_SEC_TDM_RX_0,
  5831. .stream_name = "Secondary TDM0 Playback",
  5832. .no_pcm = 1,
  5833. .dpcm_playback = 1,
  5834. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  5835. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5836. .ops = &lahaina_tdm_be_ops,
  5837. .ignore_suspend = 1,
  5838. .ignore_pmdown_time = 1,
  5839. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  5840. },
  5841. {
  5842. .name = LPASS_BE_SEC_TDM_TX_0,
  5843. .stream_name = "Secondary TDM0 Capture",
  5844. .no_pcm = 1,
  5845. .dpcm_capture = 1,
  5846. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  5847. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5848. .ops = &lahaina_tdm_be_ops,
  5849. .ignore_suspend = 1,
  5850. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  5851. },
  5852. {
  5853. .name = LPASS_BE_TERT_TDM_RX_0,
  5854. .stream_name = "Tertiary TDM0 Playback",
  5855. .no_pcm = 1,
  5856. .dpcm_playback = 1,
  5857. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  5858. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5859. .ops = &lahaina_tdm_be_ops,
  5860. .ignore_suspend = 1,
  5861. .ignore_pmdown_time = 1,
  5862. SND_SOC_DAILINK_REG(tert_tdm_rx_0),
  5863. },
  5864. {
  5865. .name = LPASS_BE_TERT_TDM_TX_0,
  5866. .stream_name = "Tertiary TDM0 Capture",
  5867. .no_pcm = 1,
  5868. .dpcm_capture = 1,
  5869. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  5870. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5871. .ops = &lahaina_tdm_be_ops,
  5872. .ignore_suspend = 1,
  5873. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  5874. },
  5875. {
  5876. .name = LPASS_BE_QUAT_TDM_RX_0,
  5877. .stream_name = "Quaternary TDM0 Playback",
  5878. .no_pcm = 1,
  5879. .dpcm_playback = 1,
  5880. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  5881. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5882. .ops = &lahaina_tdm_be_ops,
  5883. .ignore_suspend = 1,
  5884. .ignore_pmdown_time = 1,
  5885. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  5886. },
  5887. {
  5888. .name = LPASS_BE_QUAT_TDM_TX_0,
  5889. .stream_name = "Quaternary TDM0 Capture",
  5890. .no_pcm = 1,
  5891. .dpcm_capture = 1,
  5892. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  5893. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5894. .ops = &lahaina_tdm_be_ops,
  5895. .ignore_suspend = 1,
  5896. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  5897. },
  5898. {
  5899. .name = LPASS_BE_QUIN_TDM_RX_0,
  5900. .stream_name = "Quinary TDM0 Playback",
  5901. .no_pcm = 1,
  5902. .dpcm_playback = 1,
  5903. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  5904. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5905. .ops = &lahaina_tdm_be_ops,
  5906. .ignore_suspend = 1,
  5907. .ignore_pmdown_time = 1,
  5908. SND_SOC_DAILINK_REG(quin_tdm_rx_0),
  5909. },
  5910. {
  5911. .name = LPASS_BE_QUIN_TDM_TX_0,
  5912. .stream_name = "Quinary TDM0 Capture",
  5913. .no_pcm = 1,
  5914. .dpcm_capture = 1,
  5915. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  5916. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5917. .ops = &lahaina_tdm_be_ops,
  5918. .ignore_suspend = 1,
  5919. SND_SOC_DAILINK_REG(quin_tdm_tx_0),
  5920. },
  5921. {
  5922. .name = LPASS_BE_SEN_TDM_RX_0,
  5923. .stream_name = "Senary TDM0 Playback",
  5924. .no_pcm = 1,
  5925. .dpcm_playback = 1,
  5926. .id = MSM_BACKEND_DAI_SEN_TDM_RX_0,
  5927. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5928. .ops = &lahaina_tdm_be_ops,
  5929. .ignore_suspend = 1,
  5930. .ignore_pmdown_time = 1,
  5931. SND_SOC_DAILINK_REG(sen_tdm_rx_0),
  5932. },
  5933. {
  5934. .name = LPASS_BE_SEN_TDM_TX_0,
  5935. .stream_name = "Senary TDM0 Capture",
  5936. .no_pcm = 1,
  5937. .dpcm_capture = 1,
  5938. .id = MSM_BACKEND_DAI_SEN_TDM_TX_0,
  5939. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5940. .ops = &lahaina_tdm_be_ops,
  5941. .ignore_suspend = 1,
  5942. SND_SOC_DAILINK_REG(sen_tdm_tx_0),
  5943. },
  5944. };
  5945. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  5946. {
  5947. .name = LPASS_BE_SLIMBUS_7_RX,
  5948. .stream_name = "Slimbus7 Playback",
  5949. .no_pcm = 1,
  5950. .dpcm_playback = 1,
  5951. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5952. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5953. .init = &msm_wcn_init,
  5954. .ops = &msm_wcn_ops,
  5955. /* dai link has playback support */
  5956. .ignore_pmdown_time = 1,
  5957. .ignore_suspend = 1,
  5958. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5959. },
  5960. {
  5961. .name = LPASS_BE_SLIMBUS_7_TX,
  5962. .stream_name = "Slimbus7 Capture",
  5963. .no_pcm = 1,
  5964. .dpcm_capture = 1,
  5965. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5966. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5967. .ops = &msm_wcn_ops,
  5968. .ignore_suspend = 1,
  5969. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5970. },
  5971. };
  5972. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  5973. {
  5974. .name = LPASS_BE_SLIMBUS_7_RX,
  5975. .stream_name = "Slimbus7 Playback",
  5976. .no_pcm = 1,
  5977. .dpcm_playback = 1,
  5978. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5979. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5980. .init = &msm_wcn_init_lito,
  5981. .ops = &msm_wcn_ops_lito,
  5982. /* dai link has playback support */
  5983. .ignore_pmdown_time = 1,
  5984. .ignore_suspend = 1,
  5985. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5986. },
  5987. {
  5988. .name = LPASS_BE_SLIMBUS_7_TX,
  5989. .stream_name = "Slimbus7 Capture",
  5990. .no_pcm = 1,
  5991. .dpcm_capture = 1,
  5992. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5993. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5994. .ops = &msm_wcn_ops_lito,
  5995. .ignore_suspend = 1,
  5996. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5997. },
  5998. {
  5999. .name = LPASS_BE_SLIMBUS_8_TX,
  6000. .stream_name = "Slimbus8 Capture",
  6001. .no_pcm = 1,
  6002. .dpcm_capture = 1,
  6003. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  6004. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6005. .ops = &msm_wcn_ops_lito,
  6006. .ignore_suspend = 1,
  6007. SND_SOC_DAILINK_REG(slimbus_8_tx),
  6008. },
  6009. };
  6010. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6011. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  6012. /* DISP PORT BACK END DAI Link */
  6013. {
  6014. .name = LPASS_BE_DISPLAY_PORT,
  6015. .stream_name = "Display Port Playback",
  6016. .no_pcm = 1,
  6017. .dpcm_playback = 1,
  6018. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  6019. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6020. .ignore_pmdown_time = 1,
  6021. .ignore_suspend = 1,
  6022. SND_SOC_DAILINK_REG(display_port),
  6023. },
  6024. /* DISP PORT 1 BACK END DAI Link */
  6025. {
  6026. .name = LPASS_BE_DISPLAY_PORT1,
  6027. .stream_name = "Display Port1 Playback",
  6028. .no_pcm = 1,
  6029. .dpcm_playback = 1,
  6030. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  6031. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6032. .ignore_pmdown_time = 1,
  6033. .ignore_suspend = 1,
  6034. SND_SOC_DAILINK_REG(display_port1),
  6035. },
  6036. };
  6037. #endif
  6038. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  6039. {
  6040. .name = LPASS_BE_PRI_MI2S_RX,
  6041. .stream_name = "Primary MI2S Playback",
  6042. .no_pcm = 1,
  6043. .dpcm_playback = 1,
  6044. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  6045. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6046. .ops = &msm_mi2s_be_ops,
  6047. .ignore_suspend = 1,
  6048. .ignore_pmdown_time = 1,
  6049. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  6050. },
  6051. {
  6052. .name = LPASS_BE_PRI_MI2S_TX,
  6053. .stream_name = "Primary MI2S Capture",
  6054. .no_pcm = 1,
  6055. .dpcm_capture = 1,
  6056. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  6057. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6058. .ops = &msm_mi2s_be_ops,
  6059. .ignore_suspend = 1,
  6060. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  6061. },
  6062. {
  6063. .name = LPASS_BE_SEC_MI2S_RX,
  6064. .stream_name = "Secondary MI2S Playback",
  6065. .no_pcm = 1,
  6066. .dpcm_playback = 1,
  6067. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  6068. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6069. .ops = &msm_mi2s_be_ops,
  6070. .ignore_suspend = 1,
  6071. .ignore_pmdown_time = 1,
  6072. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  6073. },
  6074. {
  6075. .name = LPASS_BE_SEC_MI2S_TX,
  6076. .stream_name = "Secondary MI2S Capture",
  6077. .no_pcm = 1,
  6078. .dpcm_capture = 1,
  6079. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  6080. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6081. .ops = &msm_mi2s_be_ops,
  6082. .ignore_suspend = 1,
  6083. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  6084. },
  6085. {
  6086. .name = LPASS_BE_TERT_MI2S_RX,
  6087. .stream_name = "Tertiary MI2S Playback",
  6088. .no_pcm = 1,
  6089. .dpcm_playback = 1,
  6090. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  6091. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6092. .ops = &msm_mi2s_be_ops,
  6093. .ignore_suspend = 1,
  6094. .ignore_pmdown_time = 1,
  6095. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  6096. },
  6097. {
  6098. .name = LPASS_BE_TERT_MI2S_TX,
  6099. .stream_name = "Tertiary MI2S Capture",
  6100. .no_pcm = 1,
  6101. .dpcm_capture = 1,
  6102. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  6103. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6104. .ops = &msm_mi2s_be_ops,
  6105. .ignore_suspend = 1,
  6106. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  6107. },
  6108. {
  6109. .name = LPASS_BE_QUAT_MI2S_RX,
  6110. .stream_name = "Quaternary MI2S Playback",
  6111. .no_pcm = 1,
  6112. .dpcm_playback = 1,
  6113. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  6114. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6115. .ops = &msm_mi2s_be_ops,
  6116. .ignore_suspend = 1,
  6117. .ignore_pmdown_time = 1,
  6118. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  6119. },
  6120. {
  6121. .name = LPASS_BE_QUAT_MI2S_TX,
  6122. .stream_name = "Quaternary MI2S Capture",
  6123. .no_pcm = 1,
  6124. .dpcm_capture = 1,
  6125. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  6126. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6127. .ops = &msm_mi2s_be_ops,
  6128. .ignore_suspend = 1,
  6129. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  6130. },
  6131. {
  6132. .name = LPASS_BE_QUIN_MI2S_RX,
  6133. .stream_name = "Quinary MI2S Playback",
  6134. .no_pcm = 1,
  6135. .dpcm_playback = 1,
  6136. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  6137. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6138. .ops = &msm_mi2s_be_ops,
  6139. .ignore_suspend = 1,
  6140. .ignore_pmdown_time = 1,
  6141. SND_SOC_DAILINK_REG(quin_mi2s_rx),
  6142. },
  6143. {
  6144. .name = LPASS_BE_QUIN_MI2S_TX,
  6145. .stream_name = "Quinary MI2S Capture",
  6146. .no_pcm = 1,
  6147. .dpcm_capture = 1,
  6148. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  6149. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6150. .ops = &msm_mi2s_be_ops,
  6151. .ignore_suspend = 1,
  6152. SND_SOC_DAILINK_REG(quin_mi2s_tx),
  6153. },
  6154. {
  6155. .name = LPASS_BE_SENARY_MI2S_RX,
  6156. .stream_name = "Senary MI2S Playback",
  6157. .no_pcm = 1,
  6158. .dpcm_playback = 1,
  6159. .id = MSM_BACKEND_DAI_SENARY_MI2S_RX,
  6160. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6161. .ops = &msm_mi2s_be_ops,
  6162. .ignore_suspend = 1,
  6163. .ignore_pmdown_time = 1,
  6164. SND_SOC_DAILINK_REG(sen_mi2s_rx),
  6165. },
  6166. {
  6167. .name = LPASS_BE_SENARY_MI2S_TX,
  6168. .stream_name = "Senary MI2S Capture",
  6169. .no_pcm = 1,
  6170. .dpcm_capture = 1,
  6171. .id = MSM_BACKEND_DAI_SENARY_MI2S_TX,
  6172. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6173. .ops = &msm_mi2s_be_ops,
  6174. .ignore_suspend = 1,
  6175. SND_SOC_DAILINK_REG(sen_mi2s_tx),
  6176. },
  6177. };
  6178. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  6179. /* Primary AUX PCM Backend DAI Links */
  6180. {
  6181. .name = LPASS_BE_AUXPCM_RX,
  6182. .stream_name = "AUX PCM Playback",
  6183. .no_pcm = 1,
  6184. .dpcm_playback = 1,
  6185. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6186. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6187. .ops = &lahaina_aux_be_ops,
  6188. .ignore_pmdown_time = 1,
  6189. .ignore_suspend = 1,
  6190. SND_SOC_DAILINK_REG(auxpcm_rx),
  6191. },
  6192. {
  6193. .name = LPASS_BE_AUXPCM_TX,
  6194. .stream_name = "AUX PCM Capture",
  6195. .no_pcm = 1,
  6196. .dpcm_capture = 1,
  6197. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6198. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6199. .ops = &lahaina_aux_be_ops,
  6200. .ignore_suspend = 1,
  6201. SND_SOC_DAILINK_REG(auxpcm_tx),
  6202. },
  6203. /* Secondary AUX PCM Backend DAI Links */
  6204. {
  6205. .name = LPASS_BE_SEC_AUXPCM_RX,
  6206. .stream_name = "Sec AUX PCM Playback",
  6207. .no_pcm = 1,
  6208. .dpcm_playback = 1,
  6209. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  6210. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6211. .ops = &lahaina_aux_be_ops,
  6212. .ignore_pmdown_time = 1,
  6213. .ignore_suspend = 1,
  6214. SND_SOC_DAILINK_REG(sec_auxpcm_rx),
  6215. },
  6216. {
  6217. .name = LPASS_BE_SEC_AUXPCM_TX,
  6218. .stream_name = "Sec AUX PCM Capture",
  6219. .no_pcm = 1,
  6220. .dpcm_capture = 1,
  6221. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  6222. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6223. .ops = &lahaina_aux_be_ops,
  6224. .ignore_suspend = 1,
  6225. SND_SOC_DAILINK_REG(sec_auxpcm_tx),
  6226. },
  6227. /* Tertiary AUX PCM Backend DAI Links */
  6228. {
  6229. .name = LPASS_BE_TERT_AUXPCM_RX,
  6230. .stream_name = "Tert AUX PCM Playback",
  6231. .no_pcm = 1,
  6232. .dpcm_playback = 1,
  6233. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  6234. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6235. .ops = &lahaina_aux_be_ops,
  6236. .ignore_suspend = 1,
  6237. SND_SOC_DAILINK_REG(tert_auxpcm_rx),
  6238. },
  6239. {
  6240. .name = LPASS_BE_TERT_AUXPCM_TX,
  6241. .stream_name = "Tert AUX PCM Capture",
  6242. .no_pcm = 1,
  6243. .dpcm_capture = 1,
  6244. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  6245. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6246. .ops = &lahaina_aux_be_ops,
  6247. .ignore_suspend = 1,
  6248. SND_SOC_DAILINK_REG(tert_auxpcm_tx),
  6249. },
  6250. /* Quaternary AUX PCM Backend DAI Links */
  6251. {
  6252. .name = LPASS_BE_QUAT_AUXPCM_RX,
  6253. .stream_name = "Quat AUX PCM Playback",
  6254. .no_pcm = 1,
  6255. .dpcm_playback = 1,
  6256. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  6257. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6258. .ops = &lahaina_aux_be_ops,
  6259. .ignore_suspend = 1,
  6260. SND_SOC_DAILINK_REG(quat_auxpcm_rx),
  6261. },
  6262. {
  6263. .name = LPASS_BE_QUAT_AUXPCM_TX,
  6264. .stream_name = "Quat AUX PCM Capture",
  6265. .no_pcm = 1,
  6266. .dpcm_capture = 1,
  6267. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  6268. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6269. .ops = &lahaina_aux_be_ops,
  6270. .ignore_suspend = 1,
  6271. SND_SOC_DAILINK_REG(quat_auxpcm_tx),
  6272. },
  6273. /* Quinary AUX PCM Backend DAI Links */
  6274. {
  6275. .name = LPASS_BE_QUIN_AUXPCM_RX,
  6276. .stream_name = "Quin AUX PCM Playback",
  6277. .no_pcm = 1,
  6278. .dpcm_playback = 1,
  6279. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  6280. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6281. .ops = &lahaina_aux_be_ops,
  6282. .ignore_suspend = 1,
  6283. SND_SOC_DAILINK_REG(quin_auxpcm_rx),
  6284. },
  6285. {
  6286. .name = LPASS_BE_QUIN_AUXPCM_TX,
  6287. .stream_name = "Quin AUX PCM Capture",
  6288. .no_pcm = 1,
  6289. .dpcm_capture = 1,
  6290. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  6291. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6292. .ops = &lahaina_aux_be_ops,
  6293. .ignore_suspend = 1,
  6294. SND_SOC_DAILINK_REG(quin_auxpcm_tx),
  6295. },
  6296. /* Senary AUX PCM Backend DAI Links */
  6297. {
  6298. .name = LPASS_BE_SEN_AUXPCM_RX,
  6299. .stream_name = "Sen AUX PCM Playback",
  6300. .no_pcm = 1,
  6301. .dpcm_playback = 1,
  6302. .id = MSM_BACKEND_DAI_SEN_AUXPCM_RX,
  6303. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6304. .ops = &lahaina_aux_be_ops,
  6305. .ignore_suspend = 1,
  6306. SND_SOC_DAILINK_REG(sen_auxpcm_rx),
  6307. },
  6308. {
  6309. .name = LPASS_BE_SEN_AUXPCM_TX,
  6310. .stream_name = "Sen AUX PCM Capture",
  6311. .no_pcm = 1,
  6312. .dpcm_capture = 1,
  6313. .id = MSM_BACKEND_DAI_SEN_AUXPCM_TX,
  6314. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6315. .ops = &lahaina_aux_be_ops,
  6316. .ignore_suspend = 1,
  6317. SND_SOC_DAILINK_REG(sen_auxpcm_tx),
  6318. },
  6319. };
  6320. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  6321. /* WSA CDC DMA Backend DAI Links */
  6322. {
  6323. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  6324. .stream_name = "WSA CDC DMA0 Playback",
  6325. .no_pcm = 1,
  6326. .dpcm_playback = 1,
  6327. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  6328. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6329. .ignore_pmdown_time = 1,
  6330. .ignore_suspend = 1,
  6331. .ops = &msm_cdc_dma_be_ops,
  6332. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  6333. .init = &msm_int_audrx_init,
  6334. },
  6335. {
  6336. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  6337. .stream_name = "WSA CDC DMA1 Playback",
  6338. .no_pcm = 1,
  6339. .dpcm_playback = 1,
  6340. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  6341. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6342. .ignore_pmdown_time = 1,
  6343. .ignore_suspend = 1,
  6344. .ops = &msm_cdc_dma_be_ops,
  6345. SND_SOC_DAILINK_REG(wsa_dma_rx1),
  6346. },
  6347. {
  6348. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  6349. .stream_name = "WSA CDC DMA1 Capture",
  6350. .no_pcm = 1,
  6351. .dpcm_capture = 1,
  6352. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  6353. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6354. .ignore_suspend = 1,
  6355. .ops = &msm_cdc_dma_be_ops,
  6356. SND_SOC_DAILINK_REG(wsa_dma_tx1),
  6357. },
  6358. {
  6359. .name = LPASS_BE_WSA_CDC_DMA_TX_0_VI,
  6360. .stream_name = "WSA CDC DMA0 Capture",
  6361. .no_pcm = 1,
  6362. .dpcm_capture = 1,
  6363. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  6364. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6365. .ops = &msm_cdc_dma_be_ops,
  6366. .ignore_suspend = 1,
  6367. SND_SOC_DAILINK_REG(wsa_dma_tx0_vi),
  6368. },
  6369. };
  6370. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  6371. /* RX CDC DMA Backend DAI Links */
  6372. {
  6373. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  6374. .stream_name = "RX CDC DMA0 Playback",
  6375. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6376. .dynamic_be = 1,
  6377. #endif /* CONFIG_AUDIO_QGKI */
  6378. .no_pcm = 1,
  6379. .dpcm_playback = 1,
  6380. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  6381. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6382. .ignore_pmdown_time = 1,
  6383. .ignore_suspend = 1,
  6384. .ops = &msm_cdc_dma_be_ops,
  6385. SND_SOC_DAILINK_REG(rx_dma_rx0),
  6386. .init = &msm_aux_codec_init,
  6387. },
  6388. {
  6389. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  6390. .stream_name = "RX CDC DMA1 Playback",
  6391. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6392. .dynamic_be = 1,
  6393. #endif /* CONFIG_AUDIO_QGKI */
  6394. .no_pcm = 1,
  6395. .dpcm_playback = 1,
  6396. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  6397. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6398. .ignore_pmdown_time = 1,
  6399. .ignore_suspend = 1,
  6400. .ops = &msm_cdc_dma_be_ops,
  6401. SND_SOC_DAILINK_REG(rx_dma_rx1),
  6402. .init = &msm_int_audrx_init,
  6403. },
  6404. {
  6405. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  6406. .stream_name = "RX CDC DMA2 Playback",
  6407. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6408. .dynamic_be = 1,
  6409. #endif /* CONFIG_AUDIO_QGKI */
  6410. .no_pcm = 1,
  6411. .dpcm_playback = 1,
  6412. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  6413. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6414. .ignore_pmdown_time = 1,
  6415. .ignore_suspend = 1,
  6416. .ops = &msm_cdc_dma_be_ops,
  6417. SND_SOC_DAILINK_REG(rx_dma_rx2),
  6418. },
  6419. {
  6420. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  6421. .stream_name = "RX CDC DMA3 Playback",
  6422. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6423. .dynamic_be = 1,
  6424. #endif /* CONFIG_AUDIO_QGKI */
  6425. .no_pcm = 1,
  6426. .dpcm_playback = 1,
  6427. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  6428. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6429. .ignore_pmdown_time = 1,
  6430. .ignore_suspend = 1,
  6431. .ops = &msm_cdc_dma_be_ops,
  6432. SND_SOC_DAILINK_REG(rx_dma_rx3),
  6433. },
  6434. {
  6435. .name = LPASS_BE_RX_CDC_DMA_RX_5,
  6436. .stream_name = "RX CDC DMA5 Playback",
  6437. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6438. .dynamic_be = 1,
  6439. #endif /* CONFIG_AUDIO_QGKI */
  6440. .no_pcm = 1,
  6441. .dpcm_playback = 1,
  6442. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_5,
  6443. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6444. .ignore_pmdown_time = 1,
  6445. .ignore_suspend = 1,
  6446. .ops = &msm_cdc_dma_be_ops,
  6447. SND_SOC_DAILINK_REG(rx_dma_rx5),
  6448. },
  6449. {
  6450. .name = LPASS_BE_RX_CDC_DMA_RX_6,
  6451. .stream_name = "RX CDC DMA6 Playback",
  6452. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6453. .dynamic_be = 1,
  6454. #endif /* CONFIG_AUDIO_QGKI */
  6455. .no_pcm = 1,
  6456. .dpcm_playback = 1,
  6457. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_6,
  6458. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6459. .ignore_pmdown_time = 1,
  6460. .ignore_suspend = 1,
  6461. .ops = &msm_cdc_dma_be_ops,
  6462. SND_SOC_DAILINK_REG(rx_dma_rx6),
  6463. },
  6464. /* TX CDC DMA Backend DAI Links */
  6465. {
  6466. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  6467. .stream_name = "TX CDC DMA3 Capture",
  6468. .no_pcm = 1,
  6469. .dpcm_capture = 1,
  6470. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  6471. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6472. .ignore_suspend = 1,
  6473. .ops = &msm_cdc_dma_be_ops,
  6474. SND_SOC_DAILINK_REG(tx_dma_tx3),
  6475. },
  6476. {
  6477. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  6478. .stream_name = "TX CDC DMA4 Capture",
  6479. .no_pcm = 1,
  6480. .dpcm_capture = 1,
  6481. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  6482. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6483. .ignore_suspend = 1,
  6484. .ops = &msm_cdc_dma_be_ops,
  6485. SND_SOC_DAILINK_REG(tx_dma_tx4),
  6486. },
  6487. };
  6488. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  6489. {
  6490. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  6491. .stream_name = "VA CDC DMA0 Capture",
  6492. .no_pcm = 1,
  6493. .dpcm_capture = 1,
  6494. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  6495. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6496. .ignore_suspend = 1,
  6497. .ops = &msm_cdc_dma_be_ops,
  6498. SND_SOC_DAILINK_REG(va_dma_tx0),
  6499. },
  6500. {
  6501. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  6502. .stream_name = "VA CDC DMA1 Capture",
  6503. .no_pcm = 1,
  6504. .dpcm_capture = 1,
  6505. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  6506. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6507. .ignore_suspend = 1,
  6508. .ops = &msm_cdc_dma_be_ops,
  6509. SND_SOC_DAILINK_REG(va_dma_tx1),
  6510. },
  6511. {
  6512. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  6513. .stream_name = "VA CDC DMA2 Capture",
  6514. .no_pcm = 1,
  6515. .dpcm_capture = 1,
  6516. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  6517. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6518. .ignore_suspend = 1,
  6519. .ops = &msm_cdc_dma_be_ops,
  6520. SND_SOC_DAILINK_REG(va_dma_tx2),
  6521. },
  6522. };
  6523. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  6524. {
  6525. .name = LPASS_BE_AFE_LOOPBACK_TX,
  6526. .stream_name = "AFE Loopback Capture",
  6527. .no_pcm = 1,
  6528. .dpcm_capture = 1,
  6529. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  6530. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6531. .ignore_pmdown_time = 1,
  6532. .ignore_suspend = 1,
  6533. SND_SOC_DAILINK_REG(afe_loopback_tx),
  6534. },
  6535. };
  6536. static struct snd_soc_dai_link msm_lahaina_dai_links[
  6537. ARRAY_SIZE(msm_common_dai_links) +
  6538. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  6539. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6540. ARRAY_SIZE(msm_common_be_dai_links) +
  6541. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6542. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  6543. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  6544. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  6545. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  6546. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6547. ARRAY_SIZE(ext_disp_be_dai_link) +
  6548. #endif
  6549. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6550. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link) +
  6551. ARRAY_SIZE(msm_wcn_btfm_be_dai_links)];
  6552. static int msm_populate_dai_link_component_of_node(
  6553. struct snd_soc_card *card)
  6554. {
  6555. int i, j, index, ret = 0;
  6556. struct device *cdev = card->dev;
  6557. struct snd_soc_dai_link *dai_link = card->dai_link;
  6558. struct device_node *np = NULL;
  6559. int codecs_enabled = 0;
  6560. struct snd_soc_dai_link_component *codecs_comp = NULL;
  6561. if (!cdev) {
  6562. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  6563. return -ENODEV;
  6564. }
  6565. for (i = 0; i < card->num_links; i++) {
  6566. if (dai_link[i].platforms->of_node && dai_link[i].cpus->of_node)
  6567. continue;
  6568. /* populate platform_of_node for snd card dai links */
  6569. if (dai_link[i].platforms->name &&
  6570. !dai_link[i].platforms->of_node) {
  6571. index = of_property_match_string(cdev->of_node,
  6572. "asoc-platform-names",
  6573. dai_link[i].platforms->name);
  6574. if (index < 0) {
  6575. dev_err(cdev, "%s: No match found for platform name: %s\n",
  6576. __func__, dai_link[i].platforms->name);
  6577. ret = index;
  6578. goto err;
  6579. }
  6580. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  6581. index);
  6582. if (!np) {
  6583. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  6584. __func__, dai_link[i].platforms->name,
  6585. index);
  6586. ret = -ENODEV;
  6587. goto err;
  6588. }
  6589. dai_link[i].platforms->of_node = np;
  6590. dai_link[i].platforms->name = NULL;
  6591. }
  6592. /* populate cpu_of_node for snd card dai links */
  6593. if (dai_link[i].cpus->dai_name && !dai_link[i].cpus->of_node) {
  6594. index = of_property_match_string(cdev->of_node,
  6595. "asoc-cpu-names",
  6596. dai_link[i].cpus->dai_name);
  6597. if (index >= 0) {
  6598. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  6599. index);
  6600. if (!np) {
  6601. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  6602. __func__,
  6603. dai_link[i].cpus->dai_name);
  6604. ret = -ENODEV;
  6605. goto err;
  6606. }
  6607. dai_link[i].cpus->of_node = np;
  6608. dai_link[i].cpus->dai_name = NULL;
  6609. }
  6610. }
  6611. /* populate codec_of_node for snd card dai links */
  6612. if (dai_link[i].num_codecs > 0) {
  6613. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6614. if (dai_link[i].codecs[j].of_node ||
  6615. !dai_link[i].codecs[j].name)
  6616. continue;
  6617. index = of_property_match_string(cdev->of_node,
  6618. "asoc-codec-names",
  6619. dai_link[i].codecs[j].name);
  6620. if (index < 0)
  6621. continue;
  6622. np = of_parse_phandle(cdev->of_node,
  6623. "asoc-codec",
  6624. index);
  6625. if (!np) {
  6626. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  6627. __func__,
  6628. dai_link[i].codecs[j].name);
  6629. ret = -ENODEV;
  6630. goto err;
  6631. }
  6632. dai_link[i].codecs[j].of_node = np;
  6633. dai_link[i].codecs[j].name = NULL;
  6634. }
  6635. }
  6636. }
  6637. /* In multi-codec scenario, check if codecs are enabled for this platform */
  6638. for (i = 0; i < card->num_links; i++) {
  6639. codecs_enabled = 0;
  6640. if (dai_link[i].num_codecs > 1) {
  6641. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6642. if (!dai_link[i].codecs[j].of_node)
  6643. continue;
  6644. np = dai_link[i].codecs[j].of_node;
  6645. if (!of_device_is_available(np)) {
  6646. dev_dbg(cdev, "%s: codec is disabled: %s\n",
  6647. __func__,
  6648. np->full_name);
  6649. dai_link[i].codecs[j].of_node = NULL;
  6650. continue;
  6651. }
  6652. codecs_enabled++;
  6653. }
  6654. if (codecs_enabled > 0 &&
  6655. codecs_enabled < dai_link[i].num_codecs) {
  6656. codecs_comp = devm_kzalloc(cdev,
  6657. sizeof(struct snd_soc_dai_link_component)
  6658. * codecs_enabled, GFP_KERNEL);
  6659. if (!codecs_comp) {
  6660. dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
  6661. __func__, dai_link[i].name);
  6662. ret = -ENOMEM;
  6663. goto err;
  6664. }
  6665. index = 0;
  6666. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6667. if(dai_link[i].codecs[j].of_node) {
  6668. codecs_comp[index].of_node =
  6669. dai_link[i].codecs[j].of_node;
  6670. codecs_comp[index].dai_name =
  6671. dai_link[i].codecs[j].dai_name;
  6672. codecs_comp[index].name = NULL;
  6673. index++;
  6674. }
  6675. }
  6676. dai_link[i].codecs = codecs_comp;
  6677. dai_link[i].num_codecs = codecs_enabled;
  6678. }
  6679. }
  6680. }
  6681. err:
  6682. return ret;
  6683. }
  6684. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  6685. {
  6686. int ret = -EINVAL;
  6687. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  6688. if (!component) {
  6689. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  6690. return ret;
  6691. }
  6692. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  6693. ARRAY_SIZE(msm_snd_controls));
  6694. if (ret < 0) {
  6695. dev_err(component->dev,
  6696. "%s: add_codec_controls failed, err = %d\n",
  6697. __func__, ret);
  6698. return ret;
  6699. }
  6700. return ret;
  6701. }
  6702. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  6703. struct snd_pcm_hw_params *params)
  6704. {
  6705. return 0;
  6706. }
  6707. static struct snd_soc_ops msm_stub_be_ops = {
  6708. .hw_params = msm_snd_stub_hw_params,
  6709. };
  6710. struct snd_soc_card snd_soc_card_stub_msm = {
  6711. .name = "lahaina-stub-snd-card",
  6712. };
  6713. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  6714. /* FrontEnd DAI Links */
  6715. {
  6716. .name = "MSMSTUB Media1",
  6717. .stream_name = "MultiMedia1",
  6718. .dynamic = 1,
  6719. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6720. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6721. #endif /* CONFIG_AUDIO_QGKI */
  6722. .dpcm_playback = 1,
  6723. .dpcm_capture = 1,
  6724. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6725. SND_SOC_DPCM_TRIGGER_POST},
  6726. .ignore_suspend = 1,
  6727. /* this dainlink has playback support */
  6728. .ignore_pmdown_time = 1,
  6729. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  6730. SND_SOC_DAILINK_REG(multimedia1),
  6731. },
  6732. };
  6733. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  6734. /* Backend DAI Links */
  6735. {
  6736. .name = LPASS_BE_AUXPCM_RX,
  6737. .stream_name = "AUX PCM Playback",
  6738. .no_pcm = 1,
  6739. .dpcm_playback = 1,
  6740. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6741. .init = &msm_audrx_stub_init,
  6742. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6743. .ignore_pmdown_time = 1,
  6744. .ignore_suspend = 1,
  6745. .ops = &msm_stub_be_ops,
  6746. SND_SOC_DAILINK_REG(auxpcm_rx),
  6747. },
  6748. {
  6749. .name = LPASS_BE_AUXPCM_TX,
  6750. .stream_name = "AUX PCM Capture",
  6751. .no_pcm = 1,
  6752. .dpcm_capture = 1,
  6753. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6754. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6755. .ignore_suspend = 1,
  6756. .ops = &msm_stub_be_ops,
  6757. SND_SOC_DAILINK_REG(auxpcm_tx),
  6758. },
  6759. };
  6760. static struct snd_soc_dai_link msm_stub_dai_links[
  6761. ARRAY_SIZE(msm_stub_fe_dai_links) +
  6762. ARRAY_SIZE(msm_stub_be_dai_links)];
  6763. static const struct of_device_id lahaina_asoc_machine_of_match[] = {
  6764. { .compatible = "qcom,lahaina-asoc-snd",
  6765. .data = "codec"},
  6766. { .compatible = "qcom,lahaina-asoc-snd-stub",
  6767. .data = "stub_codec"},
  6768. {},
  6769. };
  6770. static int msm_snd_card_late_probe(struct snd_soc_card *card)
  6771. {
  6772. struct snd_soc_component *component = NULL;
  6773. const char *be_dl_name = LPASS_BE_RX_CDC_DMA_RX_0;
  6774. struct snd_soc_pcm_runtime *rtd;
  6775. struct msm_asoc_mach_data *pdata;
  6776. int ret = 0;
  6777. void *mbhc_calibration;
  6778. pdata = snd_soc_card_get_drvdata(card);
  6779. if (!pdata)
  6780. return -EINVAL;
  6781. if (pdata->wcd_disabled)
  6782. return 0;
  6783. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  6784. if (!rtd) {
  6785. dev_err(card->dev,
  6786. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  6787. __func__, be_dl_name);
  6788. return -EINVAL;
  6789. }
  6790. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  6791. if (!component) {
  6792. pr_err("%s component is NULL\n", __func__);
  6793. return -EINVAL;
  6794. }
  6795. mbhc_calibration = def_wcd_mbhc_cal();
  6796. if (!mbhc_calibration)
  6797. return -ENOMEM;
  6798. wcd_mbhc_cfg.calibration = mbhc_calibration;
  6799. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  6800. if (ret) {
  6801. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  6802. __func__, ret);
  6803. goto err_hs_detect;
  6804. }
  6805. return 0;
  6806. err_hs_detect:
  6807. kfree(mbhc_calibration);
  6808. return ret;
  6809. }
  6810. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  6811. {
  6812. struct snd_soc_card *card = NULL;
  6813. struct snd_soc_dai_link *dailink = NULL;
  6814. int len_1 = 0;
  6815. int len_2 = 0;
  6816. int total_links = 0;
  6817. int rc = 0;
  6818. u32 mi2s_audio_intf = 0;
  6819. u32 auxpcm_audio_intf = 0;
  6820. u32 val = 0;
  6821. u32 wcn_btfm_intf = 0;
  6822. const struct of_device_id *match;
  6823. u32 wsa_max_devs = 0;
  6824. match = of_match_node(lahaina_asoc_machine_of_match, dev->of_node);
  6825. if (!match) {
  6826. dev_err(dev, "%s: No DT match found for sound card\n",
  6827. __func__);
  6828. return NULL;
  6829. }
  6830. if (!strcmp(match->data, "codec")) {
  6831. card = &snd_soc_card_lahaina_msm;
  6832. memcpy(msm_lahaina_dai_links + total_links,
  6833. msm_common_dai_links,
  6834. sizeof(msm_common_dai_links));
  6835. total_links += ARRAY_SIZE(msm_common_dai_links);
  6836. rc = of_property_read_u32(dev->of_node,
  6837. "qcom,wsa-max-devs", &wsa_max_devs);
  6838. if (rc) {
  6839. dev_info(dev,
  6840. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  6841. __func__, dev->of_node->full_name, rc);
  6842. wsa_max_devs = 0;
  6843. }
  6844. if (!wsa_max_devs) {
  6845. memcpy(msm_lahaina_dai_links + total_links,
  6846. msm_bolero_fe_stub_dai_links,
  6847. sizeof(msm_bolero_fe_stub_dai_links));
  6848. total_links +=
  6849. ARRAY_SIZE(msm_bolero_fe_stub_dai_links);
  6850. } else {
  6851. memcpy(msm_lahaina_dai_links + total_links,
  6852. msm_bolero_fe_dai_links,
  6853. sizeof(msm_bolero_fe_dai_links));
  6854. total_links +=
  6855. ARRAY_SIZE(msm_bolero_fe_dai_links);
  6856. }
  6857. memcpy(msm_lahaina_dai_links + total_links,
  6858. msm_common_misc_fe_dai_links,
  6859. sizeof(msm_common_misc_fe_dai_links));
  6860. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6861. memcpy(msm_lahaina_dai_links + total_links,
  6862. msm_common_be_dai_links,
  6863. sizeof(msm_common_be_dai_links));
  6864. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  6865. memcpy(msm_lahaina_dai_links + total_links,
  6866. msm_rx_tx_cdc_dma_be_dai_links,
  6867. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  6868. total_links +=
  6869. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  6870. if (wsa_max_devs) {
  6871. memcpy(msm_lahaina_dai_links + total_links,
  6872. msm_wsa_cdc_dma_be_dai_links,
  6873. sizeof(msm_wsa_cdc_dma_be_dai_links));
  6874. total_links +=
  6875. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  6876. }
  6877. memcpy(msm_lahaina_dai_links + total_links,
  6878. msm_va_cdc_dma_be_dai_links,
  6879. sizeof(msm_va_cdc_dma_be_dai_links));
  6880. total_links +=
  6881. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  6882. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  6883. &mi2s_audio_intf);
  6884. if (rc) {
  6885. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  6886. __func__);
  6887. } else {
  6888. if (mi2s_audio_intf) {
  6889. memcpy(msm_lahaina_dai_links + total_links,
  6890. msm_mi2s_be_dai_links,
  6891. sizeof(msm_mi2s_be_dai_links));
  6892. total_links +=
  6893. ARRAY_SIZE(msm_mi2s_be_dai_links);
  6894. }
  6895. }
  6896. rc = of_property_read_u32(dev->of_node,
  6897. "qcom,auxpcm-audio-intf",
  6898. &auxpcm_audio_intf);
  6899. if (rc) {
  6900. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  6901. __func__);
  6902. } else {
  6903. if (auxpcm_audio_intf) {
  6904. memcpy(msm_lahaina_dai_links + total_links,
  6905. msm_auxpcm_be_dai_links,
  6906. sizeof(msm_auxpcm_be_dai_links));
  6907. total_links +=
  6908. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6909. }
  6910. }
  6911. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6912. rc = of_property_read_u32(dev->of_node,
  6913. "qcom,ext-disp-audio-rx", &val);
  6914. if (!rc && val) {
  6915. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6916. __func__);
  6917. memcpy(msm_lahaina_dai_links + total_links,
  6918. ext_disp_be_dai_link,
  6919. sizeof(ext_disp_be_dai_link));
  6920. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6921. }
  6922. #endif
  6923. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  6924. if (!rc && val) {
  6925. dev_dbg(dev, "%s(): WCN BT support present\n",
  6926. __func__);
  6927. memcpy(msm_lahaina_dai_links + total_links,
  6928. msm_wcn_be_dai_links,
  6929. sizeof(msm_wcn_be_dai_links));
  6930. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6931. }
  6932. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  6933. &val);
  6934. if (!rc && val) {
  6935. memcpy(msm_lahaina_dai_links + total_links,
  6936. msm_afe_rxtx_lb_be_dai_link,
  6937. sizeof(msm_afe_rxtx_lb_be_dai_link));
  6938. total_links +=
  6939. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  6940. }
  6941. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  6942. &wcn_btfm_intf);
  6943. if (rc) {
  6944. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  6945. __func__);
  6946. } else {
  6947. if (wcn_btfm_intf) {
  6948. memcpy(msm_lahaina_dai_links + total_links,
  6949. msm_wcn_btfm_be_dai_links,
  6950. sizeof(msm_wcn_btfm_be_dai_links));
  6951. total_links +=
  6952. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  6953. }
  6954. }
  6955. dailink = msm_lahaina_dai_links;
  6956. } else if(!strcmp(match->data, "stub_codec")) {
  6957. card = &snd_soc_card_stub_msm;
  6958. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  6959. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  6960. memcpy(msm_stub_dai_links,
  6961. msm_stub_fe_dai_links,
  6962. sizeof(msm_stub_fe_dai_links));
  6963. memcpy(msm_stub_dai_links + len_1,
  6964. msm_stub_be_dai_links,
  6965. sizeof(msm_stub_be_dai_links));
  6966. dailink = msm_stub_dai_links;
  6967. total_links = len_2;
  6968. }
  6969. if (card) {
  6970. card->dai_link = dailink;
  6971. card->num_links = total_links;
  6972. card->late_probe = msm_snd_card_late_probe;
  6973. }
  6974. return card;
  6975. }
  6976. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  6977. {
  6978. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6979. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6980. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  6981. SPKR_L_BOOST, SPKR_L_VI};
  6982. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  6983. SPKR_R_BOOST, SPKR_R_VI};
  6984. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  6985. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  6986. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  6987. struct snd_soc_component *component = NULL;
  6988. struct snd_soc_dapm_context *dapm = NULL;
  6989. struct snd_card *card = NULL;
  6990. struct snd_info_entry *entry = NULL;
  6991. struct msm_asoc_mach_data *pdata =
  6992. snd_soc_card_get_drvdata(rtd->card);
  6993. int ret = 0;
  6994. int wsa_active_devs = 0;
  6995. if (codec_reg_done) {
  6996. return 0;
  6997. }
  6998. if (pdata->wsa_max_devs > 0) {
  6999. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  7000. if (component) {
  7001. dapm = snd_soc_component_get_dapm(component);
  7002. wsa883x_set_channel_map(component, &spkleft_ports[0],
  7003. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  7004. &ch_rate[0], &spkleft_port_types[0]);
  7005. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  7006. component);
  7007. wsa_active_devs++;
  7008. } else {
  7009. pr_info("%s: wsa-codec.1 component is NULL\n", __func__);
  7010. }
  7011. }
  7012. /* If current platform has more than one WSA */
  7013. if (pdata->wsa_max_devs > wsa_active_devs) {
  7014. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  7015. if (!component) {
  7016. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  7017. pr_err("%s: %d WSA is found. Expect %d WSA.",
  7018. __func__, wsa_active_devs, pdata->wsa_max_devs);
  7019. return -EINVAL;
  7020. }
  7021. dapm = snd_soc_component_get_dapm(component);
  7022. wsa883x_set_channel_map(component, &spkright_ports[0],
  7023. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  7024. &ch_rate[0], &spkright_port_types[0]);
  7025. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  7026. component);
  7027. }
  7028. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  7029. if (!component) {
  7030. pr_err("%s: could not find component for bolero_codec\n",
  7031. __func__);
  7032. return ret;
  7033. }
  7034. dapm = snd_soc_component_get_dapm(component);
  7035. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  7036. ARRAY_SIZE(msm_int_snd_controls));
  7037. if (ret < 0) {
  7038. pr_err("%s: add_component_controls failed: %d\n",
  7039. __func__, ret);
  7040. return ret;
  7041. }
  7042. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  7043. ARRAY_SIZE(msm_common_snd_controls));
  7044. if (ret < 0) {
  7045. pr_err("%s: add common snd controls failed: %d\n",
  7046. __func__, ret);
  7047. return ret;
  7048. }
  7049. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  7050. ARRAY_SIZE(msm_int_dapm_widgets));
  7051. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  7052. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  7053. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  7054. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  7055. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  7056. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  7057. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  7058. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  7059. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  7060. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  7061. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  7062. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  7063. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  7064. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  7065. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  7066. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  7067. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  7068. snd_soc_dapm_sync(dapm);
  7069. card = rtd->card->snd_card;
  7070. if (strnstr(rtd->card->name, "shima", 5) != NULL)
  7071. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map_shima),
  7072. sm_port_map_shima);
  7073. else
  7074. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  7075. sm_port_map);
  7076. if (!pdata->codec_root) {
  7077. entry = msm_snd_info_create_subdir(card->module, "codecs",
  7078. card->proc_root);
  7079. if (!entry) {
  7080. pr_debug("%s: Cannot create codecs module entry\n",
  7081. __func__);
  7082. ret = 0;
  7083. goto err;
  7084. }
  7085. pdata->codec_root = entry;
  7086. }
  7087. bolero_info_create_codec_entry(pdata->codec_root, component);
  7088. bolero_register_wake_irq(component, false);
  7089. codec_reg_done = true;
  7090. err:
  7091. return ret;
  7092. }
  7093. static int msm_aux_codec_init(struct snd_soc_pcm_runtime *rtd)
  7094. {
  7095. struct snd_soc_component *component = NULL;
  7096. struct snd_soc_dapm_context *dapm = NULL;
  7097. int ret = 0;
  7098. int codec_variant = -1;
  7099. struct snd_info_entry *entry;
  7100. struct snd_card *card = NULL;
  7101. struct msm_asoc_mach_data *pdata;
  7102. pdata = snd_soc_card_get_drvdata(rtd->card);
  7103. if(!pdata)
  7104. return -EINVAL;
  7105. if (pdata->wcd_disabled)
  7106. return 0;
  7107. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  7108. if (!component) {
  7109. pr_err("%s component is NULL\n", __func__);
  7110. return -EINVAL;
  7111. }
  7112. dapm = snd_soc_component_get_dapm(component);
  7113. card = component->card->snd_card;
  7114. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  7115. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  7116. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  7117. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  7118. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  7119. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  7120. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  7121. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  7122. snd_soc_dapm_sync(dapm);
  7123. if (!pdata->codec_root) {
  7124. entry = msm_snd_info_create_subdir(card->module, "codecs",
  7125. card->proc_root);
  7126. if (!entry) {
  7127. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  7128. __func__);
  7129. return 0;
  7130. }
  7131. pdata->codec_root = entry;
  7132. }
  7133. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  7134. codec_variant = wcd938x_get_codec_variant(component);
  7135. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  7136. if (codec_variant == WCD9380)
  7137. ret = snd_soc_add_component_controls(component,
  7138. msm_int_wcd9380_snd_controls,
  7139. ARRAY_SIZE(msm_int_wcd9380_snd_controls));
  7140. else if (codec_variant == WCD9385)
  7141. ret = snd_soc_add_component_controls(component,
  7142. msm_int_wcd9385_snd_controls,
  7143. ARRAY_SIZE(msm_int_wcd9385_snd_controls));
  7144. if (ret < 0) {
  7145. dev_err(component->dev, "%s: add codec specific snd controls failed: %d\n",
  7146. __func__, ret);
  7147. return ret;
  7148. }
  7149. return 0;
  7150. }
  7151. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  7152. {
  7153. int count = 0;
  7154. u32 mi2s_master_slave[MI2S_MAX];
  7155. int ret = 0;
  7156. for (count = 0; count < MI2S_MAX; count++) {
  7157. mutex_init(&mi2s_intf_conf[count].lock);
  7158. mi2s_intf_conf[count].ref_cnt = 0;
  7159. }
  7160. ret = of_property_read_u32_array(pdev->dev.of_node,
  7161. "qcom,msm-mi2s-master",
  7162. mi2s_master_slave, MI2S_MAX);
  7163. if (ret) {
  7164. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  7165. __func__);
  7166. } else {
  7167. for (count = 0; count < MI2S_MAX; count++) {
  7168. mi2s_intf_conf[count].msm_is_mi2s_master =
  7169. mi2s_master_slave[count];
  7170. }
  7171. }
  7172. }
  7173. static void msm_i2s_auxpcm_deinit(void)
  7174. {
  7175. int count = 0;
  7176. for (count = 0; count < MI2S_MAX; count++) {
  7177. mutex_destroy(&mi2s_intf_conf[count].lock);
  7178. mi2s_intf_conf[count].ref_cnt = 0;
  7179. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  7180. }
  7181. }
  7182. static int lahaina_ssr_enable(struct device *dev, void *data)
  7183. {
  7184. struct platform_device *pdev = to_platform_device(dev);
  7185. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7186. int ret = 0;
  7187. if (!card) {
  7188. dev_err(dev, "%s: card is NULL\n", __func__);
  7189. ret = -EINVAL;
  7190. goto err;
  7191. }
  7192. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  7193. /* TODO */
  7194. dev_dbg(dev, "%s: TODO \n", __func__);
  7195. }
  7196. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  7197. snd_soc_card_change_online_state(card, 1);
  7198. #endif /* CONFIG_AUDIO_QGKI */
  7199. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  7200. err:
  7201. return ret;
  7202. }
  7203. static void lahaina_ssr_disable(struct device *dev, void *data)
  7204. {
  7205. struct platform_device *pdev = to_platform_device(dev);
  7206. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7207. if (!card) {
  7208. dev_err(dev, "%s: card is NULL\n", __func__);
  7209. return;
  7210. }
  7211. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  7212. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  7213. snd_soc_card_change_online_state(card, 0);
  7214. #endif /* CONFIG_AUDIO_QGKI */
  7215. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  7216. /* TODO */
  7217. dev_dbg(dev, "%s: TODO \n", __func__);
  7218. }
  7219. }
  7220. static const struct snd_event_ops lahaina_ssr_ops = {
  7221. .enable = lahaina_ssr_enable,
  7222. .disable = lahaina_ssr_disable,
  7223. };
  7224. static int msm_audio_ssr_compare(struct device *dev, void *data)
  7225. {
  7226. struct device_node *node = data;
  7227. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  7228. __func__, dev->of_node, node);
  7229. return (dev->of_node && dev->of_node == node);
  7230. }
  7231. static int msm_audio_ssr_register(struct device *dev)
  7232. {
  7233. struct device_node *np = dev->of_node;
  7234. struct snd_event_clients *ssr_clients = NULL;
  7235. struct device_node *node = NULL;
  7236. int ret = 0;
  7237. int i = 0;
  7238. for (i = 0; ; i++) {
  7239. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  7240. if (!node)
  7241. break;
  7242. snd_event_mstr_add_client(&ssr_clients,
  7243. msm_audio_ssr_compare, node);
  7244. }
  7245. ret = snd_event_master_register(dev, &lahaina_ssr_ops,
  7246. ssr_clients, NULL);
  7247. if (!ret)
  7248. snd_event_notify(dev, SND_EVENT_UP);
  7249. return ret;
  7250. }
  7251. static void parse_cps_configuration(struct platform_device *pdev,
  7252. struct msm_asoc_mach_data *pdata)
  7253. {
  7254. int ret = 0;
  7255. int i = 0, j = 0;
  7256. u32 dt_values[MAX_CPS_LEVELS];
  7257. if (!pdev || !pdata || !pdata->wsa_max_devs)
  7258. return;
  7259. pdata->get_wsa_dev_num = wsa883x_codec_get_dev_num;
  7260. pdata->cps_config.hw_reg_cfg.num_spkr = pdata->wsa_max_devs;
  7261. ret = of_property_read_u32_array(pdev->dev.of_node,
  7262. "qcom,cps_reg_phy_addr", dt_values,
  7263. sizeof(dt_values)/sizeof(dt_values[0]));
  7264. if (ret) {
  7265. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7266. __func__, "qcom,cps_reg_phy_addr");
  7267. } else {
  7268. pdata->cps_config.hw_reg_cfg.lpass_wr_cmd_reg_phy_addr =
  7269. dt_values[0];
  7270. pdata->cps_config.hw_reg_cfg.lpass_rd_cmd_reg_phy_addr =
  7271. dt_values[1];
  7272. pdata->cps_config.hw_reg_cfg.lpass_rd_fifo_reg_phy_addr =
  7273. dt_values[2];
  7274. }
  7275. ret = of_property_read_u32_array(pdev->dev.of_node,
  7276. "qcom,cps_threshold_levels", dt_values,
  7277. sizeof(dt_values)/sizeof(dt_values[0]) - 1);
  7278. if (ret) {
  7279. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7280. __func__, "qcom,cps_threshold_levels");
  7281. } else {
  7282. pdata->cps_config.hw_reg_cfg.vbatt_lower2_threshold =
  7283. dt_values[0];
  7284. pdata->cps_config.hw_reg_cfg.vbatt_lower1_threshold =
  7285. dt_values[1];
  7286. }
  7287. pdata->cps_config.spkr_dep_cfg = devm_kzalloc(&pdev->dev,
  7288. sizeof(struct lpass_swr_spkr_dep_cfg_t)
  7289. * pdata->wsa_max_devs, GFP_KERNEL);
  7290. if (!pdata->cps_config.spkr_dep_cfg) {
  7291. dev_err(&pdev->dev, "%s: spkr dep cfg alloc failed\n", __func__);
  7292. return;
  7293. }
  7294. ret = of_property_read_u32_array(pdev->dev.of_node,
  7295. "qcom,cps_wsa_vbatt_temp_reg_addr", dt_values,
  7296. sizeof(dt_values)/sizeof(dt_values[0]) - 1);
  7297. if (ret) {
  7298. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7299. __func__, "qcom,cps_wsa_vbatt_temp_reg_addr");
  7300. } else {
  7301. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7302. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr =
  7303. dt_values[0];
  7304. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr =
  7305. dt_values[1];
  7306. }
  7307. }
  7308. ret = of_property_read_u32_array(pdev->dev.of_node,
  7309. "qcom,cps_normal_values", dt_values,
  7310. sizeof(dt_values)/sizeof(dt_values[0]));
  7311. if (ret) {
  7312. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7313. __func__, "qcom,cps_normal_values");
  7314. } else {
  7315. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7316. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7317. pdata->cps_config.spkr_dep_cfg[i].
  7318. value_normal_thrsd[j] = dt_values[j];
  7319. }
  7320. }
  7321. }
  7322. ret = of_property_read_u32_array(pdev->dev.of_node,
  7323. "qcom,cps_lower1_values", dt_values,
  7324. sizeof(dt_values)/sizeof(dt_values[0]));
  7325. if (ret) {
  7326. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7327. __func__, "qcom,cps_lower1_values");
  7328. } else {
  7329. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7330. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7331. pdata->cps_config.spkr_dep_cfg[i].
  7332. value_low1_thrsd[j] = dt_values[j];
  7333. }
  7334. }
  7335. }
  7336. ret = of_property_read_u32_array(pdev->dev.of_node,
  7337. "qcom,cps_lower2_values", dt_values,
  7338. sizeof(dt_values)/sizeof(dt_values[0]));
  7339. if (ret) {
  7340. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7341. __func__, "qcom,cps_lower2_values");
  7342. } else {
  7343. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7344. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7345. pdata->cps_config.spkr_dep_cfg[i].
  7346. value_low2_thrsd[j] = dt_values[j];
  7347. }
  7348. }
  7349. }
  7350. }
  7351. static int msm_asoc_machine_probe(struct platform_device *pdev)
  7352. {
  7353. struct snd_soc_card *card = NULL;
  7354. struct msm_asoc_mach_data *pdata = NULL;
  7355. const char *mbhc_audio_jack_type = NULL;
  7356. int ret = 0;
  7357. uint index = 0;
  7358. struct clk *lpass_audio_hw_vote = NULL;
  7359. if (!pdev->dev.of_node) {
  7360. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  7361. return -EINVAL;
  7362. }
  7363. pdata = devm_kzalloc(&pdev->dev,
  7364. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  7365. if (!pdata)
  7366. return -ENOMEM;
  7367. of_property_read_u32(pdev->dev.of_node,
  7368. "qcom,lito-is-v2-enabled",
  7369. &pdata->lito_v2_enabled);
  7370. of_property_read_u32(pdev->dev.of_node,
  7371. "qcom,wcd-disabled",
  7372. &pdata->wcd_disabled);
  7373. card = populate_snd_card_dailinks(&pdev->dev);
  7374. if (!card) {
  7375. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  7376. ret = -EINVAL;
  7377. goto err;
  7378. }
  7379. card->dev = &pdev->dev;
  7380. platform_set_drvdata(pdev, card);
  7381. snd_soc_card_set_drvdata(card, pdata);
  7382. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  7383. if (ret) {
  7384. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  7385. __func__, ret);
  7386. goto err;
  7387. }
  7388. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  7389. if (ret) {
  7390. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  7391. __func__, ret);
  7392. goto err;
  7393. }
  7394. ret = msm_populate_dai_link_component_of_node(card);
  7395. if (ret) {
  7396. ret = -EPROBE_DEFER;
  7397. goto err;
  7398. }
  7399. /* Get maximum WSA device count for this platform */
  7400. ret = of_property_read_u32(pdev->dev.of_node,
  7401. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  7402. if (ret) {
  7403. dev_info(&pdev->dev,
  7404. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  7405. __func__, pdev->dev.of_node->full_name, ret);
  7406. pdata->wsa_max_devs = 0;
  7407. }
  7408. ret = devm_snd_soc_register_card(&pdev->dev, card);
  7409. if (ret == -EPROBE_DEFER) {
  7410. if (codec_reg_done)
  7411. ret = -EINVAL;
  7412. goto err;
  7413. } else if (ret) {
  7414. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  7415. __func__, ret);
  7416. goto err;
  7417. }
  7418. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  7419. __func__, card->name);
  7420. ret = of_property_read_u32(pdev->dev.of_node, "qcom,tdm-max-slots",
  7421. &pdata->tdm_max_slots);
  7422. if (ret) {
  7423. dev_err(&pdev->dev, "%s: No DT match for tdm max slots\n",
  7424. __func__);
  7425. }
  7426. if ((pdata->tdm_max_slots <= 0) || (pdata->tdm_max_slots >
  7427. TDM_MAX_SLOTS)) {
  7428. pdata->tdm_max_slots = TDM_MAX_SLOTS;
  7429. dev_err(&pdev->dev, "%s: Using default tdm max slot: %d\n",
  7430. __func__, pdata->tdm_max_slots);
  7431. }
  7432. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7433. "qcom,hph-en1-gpio", 0);
  7434. if (!pdata->hph_en1_gpio_p) {
  7435. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7436. __func__, "qcom,hph-en1-gpio",
  7437. pdev->dev.of_node->full_name);
  7438. }
  7439. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7440. "qcom,hph-en0-gpio", 0);
  7441. if (!pdata->hph_en0_gpio_p) {
  7442. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7443. __func__, "qcom,hph-en0-gpio",
  7444. pdev->dev.of_node->full_name);
  7445. }
  7446. ret = of_property_read_string(pdev->dev.of_node,
  7447. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  7448. if (ret) {
  7449. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  7450. __func__, "qcom,mbhc-audio-jack-type",
  7451. pdev->dev.of_node->full_name);
  7452. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  7453. } else {
  7454. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  7455. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7456. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  7457. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  7458. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7459. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  7460. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  7461. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7462. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  7463. } else {
  7464. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7465. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  7466. }
  7467. }
  7468. /*
  7469. * Parse US-Euro gpio info from DT. Report no error if us-euro
  7470. * entry is not found in DT file as some targets do not support
  7471. * US-Euro detection
  7472. */
  7473. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7474. "qcom,us-euro-gpios", 0);
  7475. if (!pdata->us_euro_gpio_p) {
  7476. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  7477. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  7478. } else {
  7479. dev_dbg(&pdev->dev, "%s detected\n",
  7480. "qcom,us-euro-gpios");
  7481. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  7482. }
  7483. if (wcd_mbhc_cfg.enable_usbc_analog)
  7484. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  7485. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  7486. "fsa4480-i2c-handle", 0);
  7487. if (!pdata->fsa_handle)
  7488. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  7489. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  7490. msm_i2s_auxpcm_init(pdev);
  7491. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7492. "qcom,cdc-dmic01-gpios",
  7493. 0);
  7494. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7495. "qcom,cdc-dmic23-gpios",
  7496. 0);
  7497. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7498. "qcom,cdc-dmic45-gpios",
  7499. 0);
  7500. if (pdata->dmic01_gpio_p)
  7501. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  7502. if (pdata->dmic23_gpio_p)
  7503. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  7504. if (pdata->dmic45_gpio_p)
  7505. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  7506. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7507. "qcom,pri-mi2s-gpios", 0);
  7508. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7509. "qcom,sec-mi2s-gpios", 0);
  7510. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7511. "qcom,tert-mi2s-gpios", 0);
  7512. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7513. "qcom,quat-mi2s-gpios", 0);
  7514. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7515. "qcom,quin-mi2s-gpios", 0);
  7516. pdata->mi2s_gpio_p[SEN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7517. "qcom,sen-mi2s-gpios", 0);
  7518. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  7519. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  7520. /* parse cps configuration from dt */
  7521. parse_cps_configuration(pdev, pdata);
  7522. /* Register LPASS audio hw vote */
  7523. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  7524. if (IS_ERR(lpass_audio_hw_vote)) {
  7525. ret = PTR_ERR(lpass_audio_hw_vote);
  7526. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  7527. __func__, "lpass_audio_hw_vote", ret);
  7528. lpass_audio_hw_vote = NULL;
  7529. ret = 0;
  7530. }
  7531. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  7532. pdata->core_audio_vote_count = 0;
  7533. ret = msm_audio_ssr_register(&pdev->dev);
  7534. if (ret)
  7535. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  7536. __func__, ret);
  7537. is_initial_boot = true;
  7538. /* Add QoS request for audio tasks */
  7539. msm_audio_add_qos_request();
  7540. return 0;
  7541. err:
  7542. devm_kfree(&pdev->dev, pdata);
  7543. return ret;
  7544. }
  7545. static int msm_asoc_machine_remove(struct platform_device *pdev)
  7546. {
  7547. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7548. snd_event_master_deregister(&pdev->dev);
  7549. snd_soc_unregister_card(card);
  7550. msm_i2s_auxpcm_deinit();
  7551. msm_audio_remove_qos_request();
  7552. return 0;
  7553. }
  7554. static struct platform_driver lahaina_asoc_machine_driver = {
  7555. .driver = {
  7556. .name = DRV_NAME,
  7557. .owner = THIS_MODULE,
  7558. .pm = &snd_soc_pm_ops,
  7559. .of_match_table = lahaina_asoc_machine_of_match,
  7560. .suppress_bind_attrs = true,
  7561. },
  7562. .probe = msm_asoc_machine_probe,
  7563. .remove = msm_asoc_machine_remove,
  7564. };
  7565. module_platform_driver(lahaina_asoc_machine_driver);
  7566. MODULE_SOFTDEP("pre: bt_fm_slim");
  7567. MODULE_DESCRIPTION("ALSA SoC msm");
  7568. MODULE_LICENSE("GPL v2");
  7569. MODULE_ALIAS("platform:" DRV_NAME);
  7570. MODULE_DEVICE_TABLE(of, lahaina_asoc_machine_of_match);