lahaina.c 223 KB

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