lahaina.c 225 KB

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